Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use snakeyaml to write configured features #16857

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions testing/trino-product-tests-launcher/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,6 @@
<artifactId>jackson-annotations</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
</dependency>

<dependency>
<groupId>com.github.docker-java</groupId>
<artifactId>docker-java-api</artifactId>
Expand Down Expand Up @@ -132,6 +122,12 @@
<artifactId>testcontainers</artifactId>
</dependency>

<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>2.0</version>
</dependency>

<dependency>
<groupId>io.confluent</groupId>
<artifactId>kafka-protobuf-provider</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -38,13 +36,15 @@
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;
import java.io.FileNotFoundException;
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;
Expand Down Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super nit: can you move the writer to the next line? It's hard to spot that yaml.dump() actually takes two arguments.

}
}
catch (IOException e) {
throw new RuntimeException(e);
Expand Down