From 4276683b5af2d9777a63703f9e3dee4ae41bf8ce Mon Sep 17 00:00:00 2001 From: "Mateusz \"Serafin\" Gajewski" Date: Mon, 3 Apr 2023 15:03:44 +0200 Subject: [PATCH] Use snakeyaml to write configured features --- testing/trino-product-tests-launcher/pom.xml | 16 +++++-------- .../product/launcher/env/Environment.java | 23 ++++++++++--------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/testing/trino-product-tests-launcher/pom.xml b/testing/trino-product-tests-launcher/pom.xml index 25a439da57d1..b912d7c4c1ff 100644 --- a/testing/trino-product-tests-launcher/pom.xml +++ b/testing/trino-product-tests-launcher/pom.xml @@ -71,16 +71,6 @@ jackson-annotations - - com.fasterxml.jackson.core - jackson-databind - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - - com.github.docker-java docker-java-api @@ -132,6 +122,12 @@ testcontainers + + org.yaml + snakeyaml + 2.0 + + io.confluent kafka-protobuf-provider diff --git a/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/Environment.java b/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/Environment.java index 30e7c139d724..6c764c3f8539 100644 --- a/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/Environment.java +++ b/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/Environment.java @@ -14,8 +14,6 @@ package io.trino.tests.product.launcher.env; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import com.github.dockerjava.api.command.CreateContainerCmd; import com.github.dockerjava.api.command.InspectContainerResponse; import com.github.dockerjava.api.model.Bind; @@ -38,6 +36,7 @@ import org.testcontainers.containers.output.OutputFrame; import org.testcontainers.lifecycle.Startables; import org.testcontainers.utility.MountableFile; +import org.yaml.snakeyaml.Yaml; import java.io.File; import java.io.FileDescriptor; @@ -45,6 +44,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream; +import java.io.PrintWriter; import java.io.UncheckedIOException; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; @@ -657,18 +657,19 @@ private void addConfiguredFeaturesConfig() DockerContainer testContainer = containers.get(TESTS); // write a custom tempto config with list of connectors the environment declares to have configured // since it's needed in TestConfiguredFeatures - ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory()); File tempFile; try { tempFile = File.createTempFile("tempto-configured-features-", ".yaml"); - objectMapper.writeValue(tempFile, - Map.of("databases", - Map.of("presto", - Map.of( - "configured_connectors", - configuredFeatures.asMap().getOrDefault(CONNECTOR, ImmutableList.of()), - "configured_password_authenticators", - configuredFeatures.asMap().getOrDefault(PASSWORD_AUTHENTICATOR, ImmutableList.of()))))); + try (PrintWriter writer = new PrintWriter(tempFile)) { + Yaml yaml = new Yaml(); + yaml.dump(Map.of("databases", + Map.of("presto", + Map.of( + "configured_connectors", + configuredFeatures.asMap().getOrDefault(CONNECTOR, ImmutableList.of()), + "configured_password_authenticators", + configuredFeatures.asMap().getOrDefault(PASSWORD_AUTHENTICATOR, ImmutableList.of())))), writer); + } } catch (IOException e) { throw new RuntimeException(e);