From 756fd7832d97f22b781a517ed87cc0f5ec7e781c Mon Sep 17 00:00:00 2001 From: "Mateusz \"Serafin\" Gajewski" Date: Tue, 24 Oct 2023 15:46:11 +0200 Subject: [PATCH] Resolve Temurin JDK archives using adoptium API --- ...a => AdoptiumApiResolvingJdkProvider.java} | 27 +++++++-------- .../env/jdk/Temurin19JdkProvider.java | 19 ++--------- .../env/jdk/Temurin20JdkProvider.java | 19 ++--------- .../env/jdk/Temurin21JdkProvider.java | 33 +++++++++++++++++++ 4 files changed, 51 insertions(+), 47 deletions(-) rename testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/{Temurin21RcJdkProvider.java => AdoptiumApiResolvingJdkProvider.java} (52%) create mode 100644 testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/Temurin21JdkProvider.java diff --git a/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/Temurin21RcJdkProvider.java b/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/AdoptiumApiResolvingJdkProvider.java similarity index 52% rename from testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/Temurin21RcJdkProvider.java rename to testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/AdoptiumApiResolvingJdkProvider.java index 380dccab083c..f84fba2a112a 100644 --- a/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/Temurin21RcJdkProvider.java +++ b/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/AdoptiumApiResolvingJdkProvider.java @@ -13,35 +13,32 @@ */ package io.trino.tests.product.launcher.env.jdk; -import com.google.inject.Inject; import io.trino.testing.containers.TestContainers; import io.trino.tests.product.launcher.env.EnvironmentOptions; -public class Temurin21RcJdkProvider +public abstract class AdoptiumApiResolvingJdkProvider extends TarDownloadingJdkProvider { - // build 35 is considered the first release candidate per https://mail.openjdk.org/pipermail/jdk-dev/2023-August/008059.html - private static final String VERSION = "21-35-ea-beta"; - - @Inject - public Temurin21RcJdkProvider(EnvironmentOptions environmentOptions) + public AdoptiumApiResolvingJdkProvider(EnvironmentOptions environmentOptions) { super(environmentOptions); } + protected abstract String getReleaseName(); + @Override - protected String getDownloadUri(TestContainers.DockerArchitecture architecture) + public String getDescription() { - return switch (architecture) { - case AMD64 -> "https://github.com/adoptium/temurin21-binaries/releases/download/jdk-%s/OpenJDK21U-jdk_x64_linux_hotspot_ea_21-0-35.tar.gz".formatted(VERSION.replaceFirst("-", "%2B")); - case ARM64 -> "https://github.com/adoptium/temurin21-binaries/releases/download/jdk-%s/OpenJDK21U-jdk_aarch64_linux_hotspot_ea_21-0-35.tar.gz".formatted(VERSION.replaceFirst("-", "%2B")); - default -> throw new IllegalArgumentException("Architecture %s is not supported for Temurin 21-ea-beta distribution".formatted(architecture)); - }; + return "Temurin " + getReleaseName(); } @Override - public String getDescription() + protected String getDownloadUri(TestContainers.DockerArchitecture architecture) { - return "Temurin " + VERSION; + return switch (architecture) { + case AMD64 -> "https://api.adoptium.net/v3/binary/version/%s/linux/%s/jdk/hotspot/normal/eclipse?project=jdk".formatted(getReleaseName(), "x64"); + case ARM64 -> "https://api.adoptium.net/v3/binary/version/%s/linux/%s/jdk/hotspot/normal/eclipse?project=jdk".formatted(getReleaseName(), "aarch64"); + default -> throw new UnsupportedOperationException("Fetching Temurin JDK for arch " + architecture + " is not supported"); + }; } } diff --git a/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/Temurin19JdkProvider.java b/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/Temurin19JdkProvider.java index 39223a7bd926..45d3c727536f 100644 --- a/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/Temurin19JdkProvider.java +++ b/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/Temurin19JdkProvider.java @@ -14,14 +14,11 @@ package io.trino.tests.product.launcher.env.jdk; import com.google.inject.Inject; -import io.trino.testing.containers.TestContainers; import io.trino.tests.product.launcher.env.EnvironmentOptions; public class Temurin19JdkProvider - extends TarDownloadingJdkProvider + extends AdoptiumApiResolvingJdkProvider { - private static final String VERSION = "19.0.2-7"; - @Inject public Temurin19JdkProvider(EnvironmentOptions environmentOptions) { @@ -29,18 +26,8 @@ public Temurin19JdkProvider(EnvironmentOptions environmentOptions) } @Override - protected String getDownloadUri(TestContainers.DockerArchitecture architecture) - { - return switch (architecture) { - case AMD64 -> "https://github.com/adoptium/temurin19-binaries/releases/download/jdk-%s/OpenJDK19U-jdk_x64_linux_hotspot_19.0.2_7.tar.gz".formatted(VERSION.replace("-", "%2B")); - case ARM64 -> "https://github.com/adoptium/temurin19-binaries/releases/download/jdk-%s/OpenJDK19U-jdk_aarch64_linux_hotspot_19.0.2_7.tar.gz".formatted(VERSION.replace("-", "%2B")); - default -> throw new IllegalArgumentException("Architecture %s is not supported for Temurin 19 distribution".formatted(architecture)); - }; - } - - @Override - public String getDescription() + protected String getReleaseName() { - return "Temurin " + VERSION; + return "jdk-19.0.2+7"; } } diff --git a/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/Temurin20JdkProvider.java b/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/Temurin20JdkProvider.java index 1eafcfa315af..65ae7713e642 100644 --- a/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/Temurin20JdkProvider.java +++ b/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/Temurin20JdkProvider.java @@ -14,14 +14,11 @@ package io.trino.tests.product.launcher.env.jdk; import com.google.inject.Inject; -import io.trino.testing.containers.TestContainers.DockerArchitecture; import io.trino.tests.product.launcher.env.EnvironmentOptions; public class Temurin20JdkProvider - extends TarDownloadingJdkProvider + extends AdoptiumApiResolvingJdkProvider { - private static final String VERSION = "20.0.1-9"; - @Inject public Temurin20JdkProvider(EnvironmentOptions environmentOptions) { @@ -29,18 +26,8 @@ public Temurin20JdkProvider(EnvironmentOptions environmentOptions) } @Override - protected String getDownloadUri(DockerArchitecture architecture) - { - return switch (architecture) { - case AMD64 -> "https://github.com/adoptium/temurin20-binaries/releases/download/jdk-%s/OpenJDK20U-jdk_x64_linux_hotspot_20.0.1_9.tar.gz".formatted(VERSION.replace("-", "%2B")); - case ARM64 -> "https://github.com/adoptium/temurin20-binaries/releases/download/jdk-%s/OpenJDK20U-jdk_aarch64_linux_hotspot_20.0.1_9.tar.gz".formatted(VERSION.replace("-", "%2B")); - default -> throw new IllegalArgumentException("Architecture %s is not supported for Temurin 20 distribution".formatted(architecture)); - }; - } - - @Override - public String getDescription() + protected String getReleaseName() { - return "Temurin " + VERSION; + return "jdk-20.0.2+9"; } } diff --git a/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/Temurin21JdkProvider.java b/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/Temurin21JdkProvider.java new file mode 100644 index 000000000000..a29d12cae591 --- /dev/null +++ b/testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/Temurin21JdkProvider.java @@ -0,0 +1,33 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.trino.tests.product.launcher.env.jdk; + +import com.google.inject.Inject; +import io.trino.tests.product.launcher.env.EnvironmentOptions; + +public class Temurin21JdkProvider + extends AdoptiumApiResolvingJdkProvider +{ + @Inject + public Temurin21JdkProvider(EnvironmentOptions environmentOptions) + { + super(environmentOptions); + } + + @Override + protected String getReleaseName() + { + return "jdk-21.0.1+12"; + } +}