Skip to content

Conversation

@wendigo
Copy link
Contributor

@wendigo wendigo commented Oct 9, 2025

We only use Temurin for both testing and while producing docker images so there is no point in keeping more complicated implementation if it's not used.

Description

Additional context and related issues

Release notes

(x) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

## Section
* Fix some things. ({issue}`issuenumber`)

Summary by Sourcery

Switch JDK provisioning to use Temurin exclusively and remove legacy JDK provider logic

New Features:

  • Add TemurinJdkProvider for downloading and providing Temurin JDKs in test environments

Enhancements:

  • Simplify Docker build script to read .temurin-release and construct Temurin download URLs dynamically
  • Refactor test launcher to replace --trino-jdk-version and distribution paths with --trino-jdk-release and use TemurinJdkProvider

Tests:

  • Update JDK provider naming test to expect temurin as the canonical provider name

Chores:

  • Remove legacy core/jdk distribution directories and obsolete JDK provider classes

@wendigo wendigo requested a review from losipiuk October 9, 2025 10:59
@cla-bot cla-bot bot added the cla-signed label Oct 9, 2025
@sourcery-ai
Copy link

sourcery-ai bot commented Oct 9, 2025

Reviewer's Guide

This PR simplifies JDK handling by removing legacy built-in and custom distribution providers, unifying downloads to use Temurin across both Docker build scripts and the product tests launcher.

Flow diagram for unified Temurin JDK download in Docker build script

flowchart TD
    A["Read Temurin release from .temurin-release"] --> B["Select architecture (arm64, amd64, ppc64le)"]
    B --> C["Generate Temurin download URL"]
    C --> D["Pass JDK download link to docker build"]
Loading

File-Level Changes

Change Details Files
Unify and simplify JDK download in core/docker/build.sh to use Temurin
  • Replace JDK_RELEASE and JDKS_PATH with TEMURIN_RELEASE and TEMURIN_DOWNLOAD_URL
  • Remove prop and jdk_download_link functions
  • Add temurin_download_uri function
  • Update docker build-arg settings to use temurin_download_uri output
core/docker/build.sh
Rename and update JDK properties and options in product-tests launcher
  • Rename --trino-jdk-version and jdkDistributions to --trino-jdk-release
  • Update config keys jdk.current and jdk.distributions to jdk.current.release
  • Adjust findJdkDistribution to read from .temurin-release
testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/EnvironmentOptions.java
testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/cli/Launcher.java
Replace DistributionDownloadingJdkProvider with TemurinJdkProvider
  • Delete BuiltInJdkProvider and DistributionDownloadingJdkProvider classes
  • Add new TemurinJdkProvider class extending TarDownloadingJdkProvider
  • Update EnvironmentModule to bind TemurinJdkProvider for downloads
testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/EnvironmentModule.java
testing/trino-product-tests-launcher/src/main/java/io/trino/tests/product/launcher/env/jdk/TemurinJdkProvider.java
Update tests to expect 'temurin' provider name
  • Change assertion to use TemurinJdkProvider class in TestConfigurations
testing/trino-product-tests-launcher/src/test/java/io/trino/tests/product/launcher/env/TestConfigurations.java
Remove obsolete core JDK directories and add .temurin-release marker
  • Delete core/jdk/current and core/jdk/temurin subdirectories
  • Add core/.temurin-release file
core/.temurin-release
core/jdk/current
core/jdk/temurin/jdk-25+36/amd64
core/jdk/temurin/jdk-25+36/arm64
core/jdk/temurin/jdk-25+36/ppc64le

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • In build.sh, add a check to ensure TEMURIN_RELEASE (and the .temurin-release file) is present and non‐empty before attempting to build images to avoid silent failures.
  • Add unit tests for TemurinJdkProvider#getDownloadUri to assert that it generates the correct download URLs for each supported architecture.
  • Consider consolidating the architecture‐to‐name mappings (aarch64/x64/ppc64le) into a shared utility or config to avoid duplicating the logic in both the shell script and Java provider.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In build.sh, add a check to ensure TEMURIN_RELEASE (and the .temurin-release file) is present and non‐empty before attempting to build images to avoid silent failures.
- Add unit tests for TemurinJdkProvider#getDownloadUri to assert that it generates the correct download URLs for each supported architecture.
- Consider consolidating the architecture‐to‐name mappings (aarch64/x64/ppc64le) into a shared utility or config to avoid duplicating the logic in both the shell script and Java provider.

## Individual Comments

### Comment 1
<location> `testing/trino-product-tests-launcher/src/test/java/io/trino/tests/product/launcher/env/TestConfigurations.java:64` </location>
<code_context>
     public void testJdkProviderName()
     {
-        assertThat(nameForJdkProviderName(BuiltInJdkProvider.class)).isEqualTo("builtin");
+        assertThat(nameForJdkProviderName(TemurinJdkProvider.class)).isEqualTo("temurin");
         assertThat(canonicalJdkProviderName("BuiltIN")).isEqualTo("builtin");
         assertThat(canonicalJdkProviderName("built-IN")).isEqualTo("builtin");
</code_context>

<issue_to_address>
**suggestion (testing):** Missing tests for TemurinJdkProvider edge cases and error handling.

Please add tests for invalid release names, null download paths, and unsupported architectures to improve coverage of error handling.

Suggested implementation:

```java
    @Test
    public void testJdkProviderName()
    {
        assertThat(nameForJdkProviderName(TemurinJdkProvider.class)).isEqualTo("temurin");
        assertThat(canonicalJdkProviderName("BuiltIN")).isEqualTo("builtin");
        assertThat(canonicalJdkProviderName("built-IN")).isEqualTo("builtin");
    }

    @Test
    public void testTemurinJdkProviderInvalidReleaseName()
    {
        TemurinJdkProvider provider = new TemurinJdkProvider();
        Exception exception = assertThrows(IllegalArgumentException.class, () -> {
            provider.getDownloadUrl("invalid-release", "linux-x64");
        });
        assertThat(exception.getMessage()).contains("Invalid release name");
    }

    @Test
    public void testTemurinJdkProviderNullDownloadPath()
    {
        TemurinJdkProvider provider = new TemurinJdkProvider();
        Exception exception = assertThrows(NullPointerException.class, () -> {
            provider.getDownloadUrl(null, "linux-x64");
        });
        assertThat(exception.getMessage()).contains("release name is null");
    }

    @Test
    public void testTemurinJdkProviderUnsupportedArchitecture()
    {
        TemurinJdkProvider provider = new TemurinJdkProvider();
        Exception exception = assertThrows(IllegalArgumentException.class, () -> {
            provider.getDownloadUrl("17", "unsupported-arch");
        });
        assertThat(exception.getMessage()).contains("Unsupported architecture");
    }

```

- Ensure that TemurinJdkProvider#getDownloadUrl(String release, String arch) throws appropriate exceptions for invalid release names, null release names, and unsupported architectures.
- If the method signatures or exception messages differ, adjust the test cases accordingly.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@wendigo wendigo requested review from ebyhr and raunaqmorarka October 9, 2025 11:25
@wendigo
Copy link
Contributor Author

wendigo commented Oct 9, 2025

This makes it easier to forward test new JDK version (and upgrade these too)

We only use Temurin for both testing and while producing docker images
so there is no point in keeping more complicated implementation
if it's not used.
@wendigo wendigo force-pushed the serafin/java-cleanup branch from 0449f86 to 041dc20 Compare October 9, 2025 11:34
@wendigo wendigo merged commit cad440a into master Oct 9, 2025
95 of 107 checks passed
@wendigo wendigo deleted the serafin/java-cleanup branch October 9, 2025 12:18
@github-actions github-actions bot added this to the 478 milestone Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants