Skip to content

Commit 2bbe19e

Browse files
committed
Support installing only Temurin releases in product tests
There is no point in keeping the existing code extensible as we only test with Temurin releases. Instead of adding new class representing a given Temurin release, allow passing a --trino-jdk-version that is now interpreted as Temurin release name. This supports both GA and EA builds. For consistency by default the same release is used as installed in the Docker image.
1 parent 9b03964 commit 2bbe19e

File tree

14 files changed

+90
-233
lines changed

14 files changed

+90
-233
lines changed

testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/Configurations.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import io.trino.tests.product.launcher.env.EnvironmentProvider;
2020
import io.trino.tests.product.launcher.env.Environments;
2121
import io.trino.tests.product.launcher.env.common.TestsEnvironment;
22-
import io.trino.tests.product.launcher.env.jdk.JdkProvider;
2322
import io.trino.tests.product.launcher.suite.Suite;
2423

2524
import java.io.IOException;
@@ -62,21 +61,6 @@ public static List<Class<? extends EnvironmentConfig>> findConfigsByBasePackage(
6261
}
6362
}
6463

65-
public static List<Class<? extends JdkProvider>> findJdkProvidersByBasePackage(String packageName)
66-
{
67-
try {
68-
return ClassPath.from(Environments.class.getClassLoader()).getTopLevelClassesRecursive(packageName).stream()
69-
.map(ClassPath.ClassInfo::load)
70-
.filter(clazz -> !isAbstract(clazz.getModifiers()))
71-
.filter(JdkProvider.class::isAssignableFrom)
72-
.map(clazz -> (Class<? extends JdkProvider>) clazz.asSubclass(JdkProvider.class))
73-
.collect(toImmutableList());
74-
}
75-
catch (IOException e) {
76-
throw new RuntimeException(e);
77-
}
78-
}
79-
8064
public static List<Class<? extends Suite>> findSuitesByPackageName(String packageName)
8165
{
8266
try {
@@ -106,13 +90,6 @@ public static String nameForConfigClass(Class<? extends EnvironmentConfig> clazz
10690
return canonicalConfigName(className);
10791
}
10892

109-
public static String nameForJdkProvider(Class<? extends JdkProvider> clazz)
110-
{
111-
String className = clazz.getSimpleName();
112-
checkArgument(className.matches("^[A-Z].*JdkProvider$"), "Name of %s should end with 'JdkProvider'", clazz);
113-
return canonicalJdkProviderName(className);
114-
}
115-
11693
public static String nameForSuiteClass(Class<? extends Suite> clazz)
11794
{
11895
String className = clazz.getSimpleName();
@@ -129,15 +106,6 @@ public static String canonicalEnvironmentName(String name)
129106
return canonicalName(name);
130107
}
131108

132-
public static String canonicalJdkProviderName(String name)
133-
{
134-
if (name.matches("^.*?JdkProvider$")) {
135-
name = name.replaceFirst("JdkProvider$", "");
136-
}
137-
138-
return canonicalName(name);
139-
}
140-
141109
public static String canonicalConfigName(String name)
142110
{
143111
return canonicalName(name);

testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/cli/Launcher.java

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525

2626
import java.io.FileDescriptor;
2727
import java.io.FileOutputStream;
28+
import java.io.IOException;
2829
import java.io.OutputStream;
30+
import java.io.UncheckedIOException;
31+
import java.nio.file.Files;
2932
import java.nio.file.Path;
3033
import java.nio.file.Paths;
3134
import java.util.ListResourceBundle;
@@ -167,15 +170,38 @@ static class LauncherBundle
167170
@Override
168171
protected Object[][] getContents()
169172
{
170-
return new Object[][] {
171-
{"project.version", TestingProperties.getProjectVersion()},
172-
{"product-tests.module", "testing/trino-product-tests"},
173-
{"product-tests.name", "trino-product-tests"},
174-
{"server.module", "core/trino-server"},
175-
{"server.name", "trino-server"},
176-
{"launcher.bin", "testing/trino-product-tests-launcher/bin/run-launcher"},
177-
{"cli.bin", format("client/trino-cli/target/trino-cli-%s-executable.jar", TestingProperties.getProjectVersion())}
178-
};
173+
try {
174+
return new Object[][] {
175+
{"project.version", TestingProperties.getProjectVersion()},
176+
{"product-tests.module", "testing/trino-product-tests"},
177+
{"product-tests.name", "trino-product-tests"},
178+
{"server.module", "core/trino-server"},
179+
{"server.name", "trino-server"},
180+
{"launcher.bin", "testing/trino-product-tests-launcher/bin/run-launcher"},
181+
{"cli.bin", format("client/trino-cli/target/trino-cli-%s-executable.jar", TestingProperties.getProjectVersion())},
182+
{"temurin.release", Files.readString(findTemurinRelease()).trim()}
183+
};
184+
}
185+
catch (IOException e) {
186+
throw new UncheckedIOException(e);
187+
}
188+
}
189+
190+
protected Path findTemurinRelease()
191+
{
192+
String searchFor = ".temurin-release";
193+
Path currentWorkingDirectory = Paths.get("").toAbsolutePath();
194+
Path current = currentWorkingDirectory; // current working directory
195+
196+
while (current != null) {
197+
if (Files.exists(current.resolve(searchFor))) {
198+
return current.resolve(searchFor);
199+
}
200+
201+
current = current.getParent();
202+
}
203+
204+
throw new RuntimeException("Could not find %s in the directory %s and its' parents".formatted(searchFor, currentWorkingDirectory));
179205
}
180206
}
181207
}

testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/cli/SuiteRun.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import io.trino.tests.product.launcher.env.EnvironmentFactory;
2828
import io.trino.tests.product.launcher.env.EnvironmentModule;
2929
import io.trino.tests.product.launcher.env.EnvironmentOptions;
30-
import io.trino.tests.product.launcher.env.jdk.JdkProviderFactory;
30+
import io.trino.tests.product.launcher.env.jdk.JdkProvider;
3131
import io.trino.tests.product.launcher.suite.Suite;
3232
import io.trino.tests.product.launcher.suite.SuiteFactory;
3333
import io.trino.tests.product.launcher.suite.SuiteModule;
@@ -141,7 +141,7 @@ public static class Execution
141141
// TODO do not store mutable state
142142
private final EnvironmentOptions environmentOptions;
143143
private final SuiteFactory suiteFactory;
144-
private final JdkProviderFactory jdkProviderFactory;
144+
private final JdkProvider jdkProvider;
145145
private final EnvironmentFactory environmentFactory;
146146
private final EnvironmentConfigFactory configFactory;
147147
private final PrintStream printStream;
@@ -152,15 +152,15 @@ public Execution(
152152
SuiteRunOptions suiteRunOptions,
153153
EnvironmentOptions environmentOptions,
154154
SuiteFactory suiteFactory,
155-
JdkProviderFactory jdkProviderFactory,
155+
JdkProvider jdkProvider,
156156
EnvironmentFactory environmentFactory,
157157
EnvironmentConfigFactory configFactory,
158158
PrintStream printStream)
159159
{
160160
this.suiteRunOptions = requireNonNull(suiteRunOptions, "suiteRunOptions is null");
161161
this.environmentOptions = requireNonNull(environmentOptions, "environmentOptions is null");
162162
this.suiteFactory = requireNonNull(suiteFactory, "suiteFactory is null");
163-
this.jdkProviderFactory = requireNonNull(jdkProviderFactory, "jdkProviderFactory is null");
163+
this.jdkProvider = requireNonNull(jdkProvider, "jdkProvider is null");
164164
this.environmentFactory = requireNonNull(environmentFactory, "environmentFactory is null");
165165
this.configFactory = requireNonNull(configFactory, "configFactory is null");
166166
this.printStream = requireNonNull(printStream, "printStream is null");
@@ -297,7 +297,7 @@ private static String generateRandomRunId()
297297

298298
private int runTest(String runId, EnvironmentConfig environmentConfig, TestRun.TestRunOptions testRunOptions)
299299
{
300-
TestRun.Execution execution = new TestRun.Execution(environmentFactory, jdkProviderFactory, environmentOptions, environmentConfig, testRunOptions, printStream);
300+
TestRun.Execution execution = new TestRun.Execution(environmentFactory, jdkProvider, environmentOptions, environmentConfig, testRunOptions, printStream);
301301

302302
log.info("Test run %s started", runId);
303303
int exitCode = execution.call();

testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/cli/TestRun.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import io.trino.tests.product.launcher.env.EnvironmentModule;
3333
import io.trino.tests.product.launcher.env.EnvironmentOptions;
3434
import io.trino.tests.product.launcher.env.jdk.JdkProvider;
35-
import io.trino.tests.product.launcher.env.jdk.JdkProviderFactory;
3635
import io.trino.tests.product.launcher.testcontainers.ExistingNetwork;
3736
import picocli.CommandLine.ExitCode;
3837
import picocli.CommandLine.Mixin;
@@ -177,7 +176,7 @@ public static class Execution
177176
@Inject
178177
public Execution(
179178
EnvironmentFactory environmentFactory,
180-
JdkProviderFactory jdkProviderFactory,
179+
JdkProvider jdkProvider,
181180
EnvironmentOptions environmentOptions,
182181
EnvironmentConfig environmentConfig,
183182
TestRunOptions testRunOptions,
@@ -187,7 +186,7 @@ public Execution(
187186
requireNonNull(environmentOptions, "environmentOptions is null");
188187
this.debug = environmentOptions.debug;
189188
this.debugSuspend = testRunOptions.debugSuspend;
190-
this.jdkProvider = jdkProviderFactory.get(requireNonNull(environmentOptions.jdkProvider, "environmentOptions.jdkProvider is null"));
189+
this.jdkProvider = requireNonNull(jdkProvider, "jdkProvider is null");
191190
this.testJar = requireNonNull(testRunOptions.testJar, "testRunOptions.testJar is null");
192191
this.cliJar = requireNonNull(testRunOptions.cliJar, "testRunOptions.cliJar is null");
193192
this.testArguments = ImmutableList.copyOf(requireNonNull(testRunOptions.testArguments, "testRunOptions.testArguments is null"));

testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/EnvironmentModule.java

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,22 @@
3030
import io.trino.tests.product.launcher.env.common.Minio;
3131
import io.trino.tests.product.launcher.env.common.Standard;
3232
import io.trino.tests.product.launcher.env.common.StandardMultinode;
33+
import io.trino.tests.product.launcher.env.jdk.BuiltInJdkProvider;
3334
import io.trino.tests.product.launcher.env.jdk.JdkProvider;
34-
import io.trino.tests.product.launcher.env.jdk.JdkProviderFactory;
35+
import io.trino.tests.product.launcher.env.jdk.TemurinReleaseJdkProvider;
3536
import io.trino.tests.product.launcher.testcontainers.PortBinder;
3637

3738
import java.io.File;
3839

40+
import static com.google.common.base.MoreObjects.firstNonNull;
3941
import static com.google.inject.Scopes.SINGLETON;
4042
import static com.google.inject.multibindings.MapBinder.newMapBinder;
4143
import static io.trino.tests.product.launcher.Configurations.findConfigsByBasePackage;
4244
import static io.trino.tests.product.launcher.Configurations.findEnvironmentsByBasePackage;
43-
import static io.trino.tests.product.launcher.Configurations.findJdkProvidersByBasePackage;
4445
import static io.trino.tests.product.launcher.Configurations.nameForConfigClass;
4546
import static io.trino.tests.product.launcher.Configurations.nameForEnvironmentClass;
46-
import static io.trino.tests.product.launcher.Configurations.nameForJdkProvider;
47+
import static io.trino.tests.product.launcher.env.jdk.BuiltInJdkProvider.BUILT_IN_NAME;
48+
import static java.util.Locale.ENGLISH;
4749
import static java.util.Objects.requireNonNull;
4850
import static java.util.Objects.requireNonNullElse;
4951

@@ -53,7 +55,6 @@ public final class EnvironmentModule
5355
private static final String LAUNCHER_PACKAGE = "io.trino.tests.product.launcher";
5456
private static final String ENVIRONMENT_PACKAGE = LAUNCHER_PACKAGE + ".env.environment";
5557
private static final String CONFIG_PACKAGE = LAUNCHER_PACKAGE + ".env.configs";
56-
private static final String JDK_PACKAGE = LAUNCHER_PACKAGE + ".env.jdk";
5758

5859
private final EnvironmentOptions environmentOptions;
5960
private final Module additionalEnvironments;
@@ -91,10 +92,6 @@ public void configure(Binder binder)
9192
findConfigsByBasePackage(CONFIG_PACKAGE).forEach(clazz -> environmentConfigs.addBinding(nameForConfigClass(clazz)).to(clazz).in(SINGLETON));
9293

9394
binder.install(additionalEnvironments);
94-
95-
binder.bind(JdkProviderFactory.class).in(SINGLETON);
96-
MapBinder<String, JdkProvider> providers = newMapBinder(binder, String.class, JdkProvider.class);
97-
findJdkProvidersByBasePackage(JDK_PACKAGE).forEach(clazz -> providers.addBinding(nameForJdkProvider(clazz)).to(clazz).in(SINGLETON));
9895
}
9996

10097
@Provides
@@ -104,6 +101,21 @@ public EnvironmentConfig provideEnvironmentConfig(EnvironmentOptions options, En
104101
return factory.getConfig(options.config);
105102
}
106103

104+
@Provides
105+
@Singleton
106+
public JdkProvider provideJdk(EnvironmentOptions options)
107+
{
108+
String version = firstNonNull(options.jdkVersion, "").trim().toLowerCase(ENGLISH);
109+
if (version.isBlank()) {
110+
throw new IllegalArgumentException("Expected non-empty --trino-jdk-version");
111+
}
112+
113+
if (version.equals(BUILT_IN_NAME)) {
114+
return new BuiltInJdkProvider();
115+
}
116+
return new TemurinReleaseJdkProvider(version, options.jdkDownloadPath);
117+
}
118+
107119
@Provides
108120
@Singleton
109121
public PortBinder providePortBinder(EnvironmentOptions options)
@@ -128,13 +140,6 @@ public File provideServerPackage(EnvironmentOptions options)
128140
return requireNonNullElse(options.serverPackage, new File("dummy.tar.gz"));
129141
}
130142

131-
@Provides
132-
@Singleton
133-
public JdkProvider provideJdkProvider(JdkProviderFactory factory, EnvironmentOptions options)
134-
{
135-
return factory.get(requireNonNull(options.jdkProvider, "options.jdkProvider is null"));
136-
}
137-
138143
@Provides
139144
@Singleton
140145
@Debug

testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/EnvironmentOptions.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import static com.google.common.base.Preconditions.checkArgument;
2525
import static io.trino.tests.product.launcher.env.EnvironmentContainers.COORDINATOR;
26+
import static io.trino.tests.product.launcher.env.jdk.BuiltInJdkProvider.BUILT_IN_NAME;
2627
import static java.util.Locale.ENGLISH;
2728
import static picocli.CommandLine.Option;
2829

@@ -59,8 +60,8 @@ public final class EnvironmentOptions
5960
@Option(names = "--launcher-bin", paramLabel = "<launcher bin>", description = "Launcher bin path (used to display run commands)", defaultValue = "${launcher.bin}", hidden = true)
6061
public String launcherBin;
6162

62-
@Option(names = "--trino-jdk-version", paramLabel = "<trino-jdk-version>", description = "JDK to use for running Trino " + DEFAULT_VALUE)
63-
public String jdkProvider = "temurin22";
63+
@Option(names = {"--trino-jdk-version", "--temurin-release"}, paramLabel = "<release-name>", description = {"Temurin JDK release to run Trino with " + DEFAULT_VALUE, "See: https://api.adoptium.net/q/swagger-ui/#/Release%20Info/getReleaseNames"}, defaultValue = "${temurin.release}")
64+
public String jdkVersion = BUILT_IN_NAME;
6465

6566
@Option(names = "--jdk-tmp-download-path", paramLabel = "<jdk-tmp-download-path>", defaultValue = "${env:PTL_TMP_DOWNLOAD_PATH:-${sys:java.io.tmpdir}/ptl-tmp-download}", description = "Path to use to download JDK distributions " + DEFAULT_VALUE)
6667
@Nullable

testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/BuiltInJdkProvider.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@
1515

1616
import io.trino.tests.product.launcher.env.DockerContainer;
1717

18-
import static io.trino.tests.product.launcher.Configurations.nameForJdkProvider;
19-
2018
public class BuiltInJdkProvider
2119
implements JdkProvider
2220
{
23-
public static final String BUILT_IN_NAME = nameForJdkProvider(BuiltInJdkProvider.class);
21+
public static final String BUILT_IN_NAME = "builtin";
2422

2523
@Override
2624
public DockerContainer applyTo(DockerContainer container)

testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/JdkProvider.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
import io.trino.tests.product.launcher.env.DockerContainer;
1717

18-
import static io.trino.tests.product.launcher.Configurations.nameForJdkProvider;
19-
2018
public interface JdkProvider
2119
{
2220
DockerContainer applyTo(DockerContainer container);
@@ -29,9 +27,4 @@ default String getJavaCommand()
2927
{
3028
return getJavaHome() + "/bin/java";
3129
}
32-
33-
default String getName()
34-
{
35-
return nameForJdkProvider(this.getClass());
36-
}
3730
}

testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/JdkProviderFactory.java

Lines changed: 0 additions & 46 deletions
This file was deleted.

testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/TarDownloadingJdkProvider.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import io.trino.testing.containers.TestContainers.DockerArchitecture;
2121
import io.trino.testing.containers.TestContainers.DockerArchitectureInfo;
2222
import io.trino.tests.product.launcher.env.DockerContainer;
23-
import io.trino.tests.product.launcher.env.EnvironmentOptions;
2423
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
2524
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
2625
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
@@ -55,10 +54,10 @@ public abstract class TarDownloadingJdkProvider
5554
private final Path downloadPath;
5655
private final Logger log = Logger.get(getClass());
5756

58-
public TarDownloadingJdkProvider(EnvironmentOptions environmentOptions)
57+
public TarDownloadingJdkProvider(Path jdkDownloadPath)
5958
{
6059
try {
61-
this.downloadPath = firstNonNull(environmentOptions.jdkDownloadPath, Files.createTempDirectory("ptl-temp-path"));
60+
this.downloadPath = firstNonNull(jdkDownloadPath, Files.createTempDirectory("ptl-temp-path"));
6261
}
6362
catch (IOException e) {
6463
throw new UncheckedIOException(e);
@@ -67,6 +66,8 @@ public TarDownloadingJdkProvider(EnvironmentOptions environmentOptions)
6766

6867
protected abstract String getDownloadUri(DockerArchitecture architecture);
6968

69+
protected abstract String getName();
70+
7071
@Override
7172
public String getJavaHome()
7273
{

0 commit comments

Comments
 (0)