Skip to content

Automatically determine appropriate URL based off platform in VersionDownloadSource - #96

Merged
bodowd merged 1 commit into
masterfrom
automatically-determine-url-for-sys-arch
Aug 5, 2026
Merged

Automatically determine appropriate URL based off platform in VersionDownloadSource#96
bodowd merged 1 commit into
masterfrom
automatically-determine-url-for-sys-arch

Conversation

@bodowd

@bodowd bodowd commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary of the changes / Why this is an improvement

Related to this issue: crate/jmx_exporter#102
Related to PR: crate/jmx_exporter#104 so that jmx_exporter can simply pass a desired CrateDB version for download to crate-java-testing. This PR makes it easier to test different releases on jmx_exporter from different systems, not only Linux.

Currently, CrateTestCluster.fromVersion will download from https://cdn.crate.io/downloads/releases/crate-%s.tar.gz

However, if the client is running on aarch64_mac, for example, the releases at this URL are not suitable for the client's system. There are releases for specific architectures that should be used instead. For example: https://cdn2.crate.io/downloads/releases/nightly/aarch64_mac/

Currently, the client must work around this by browsing https://cdn2.crate.io/downloads/releases/ to find the url to the release they want and then call CrateTestCluster.fromURL.

This PR allows the client to simply pass the desired version they want to download and it abstracts away figuring out the appropriate CrateDB release to download.

Note

This PR does not yet address making tests run locally from aarch64_mac. Further changes would be necessary for that, for example here:

public class ShutdownTest {
@Test
public void test() throws Throwable {
CrateTestCluster testCluster = CrateTestCluster.fromURL("https://cdn.crate.io/downloads/releases/nightly/crate-latest.tar.gz")
.keepWorkingDir(false)
.build();
testCluster.before();
assertThat(testCluster.isAlive(), is(true));
testCluster.after();
assertThat(testCluster.isAlive(), is(false));
}
}

This still has a hardcoded URL. The workaround in DEVELOP.rst is still necessary if developers want to run local tests on macos

Checklist

@bodowd
bodowd marked this pull request as draft August 5, 2026 11:56
@bodowd
bodowd marked this pull request as ready for review August 5, 2026 12:05
@bodowd bodowd changed the title WIP: Automatically determine appropriate URL based off platform in VersionDownloadSource Automatically determine appropriate URL based off platform in VersionDownloadSource Aug 5, 2026
@bodowd
bodowd force-pushed the automatically-determine-url-for-sys-arch branch from 9b4feba to 8f2b025 Compare August 5, 2026 12:13
@bodowd
bodowd requested a review from mfussenegger August 5, 2026 12:22
@Override
public URL downloadUrl() throws MalformedURLException {
return new URL(String.format(Locale.ENGLISH, VERSION_DOWNLOAD_URL, version));
return buildDownloadUrl(this.version, platform(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This bit of indirection made it easier to write unit tests on buildDownloadUrl and platform

System.getProperty("os.arch")));
}

static URL buildDownloadUrl(String version, String platform) throws MalformedURLException {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This and platform could potentially be in Utils and re-used for other tests like ShutdownTest. What do you think?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could be done later when/if we adjust ShutdownTest to be able to run locally from aarch64_mac

…DownloadSource

Currently, downloading the cratedb releases assumes the following URL
"https://cdn.crate.io/downloads/releases/crate-%s.tar.gz"

However, this will not work if the user is running on aarch64_mac, and
potentially other platforms.

We now check the architecture of the system running the code and then
determine the appropriate URL for downloading the desired cratedb
release.
@bodowd
bodowd force-pushed the automatically-determine-url-for-sys-arch branch from 8f2b025 to 467b8de Compare August 5, 2026 12:30
@bodowd
bodowd merged commit df9dd45 into master Aug 5, 2026
1 check passed
@bodowd
bodowd deleted the automatically-determine-url-for-sys-arch branch August 5, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants