Skip to content

Conversation

jozala
Copy link
Contributor

@jozala jozala commented Sep 11, 2025

Introduce a new property to indicate if the version is a custom build not tied to any release. This was previously handled by specifying version as 0.0.0, but caused problems when comparing versions (e.g., to decide on configuration).

In the tests, which support the bcUpgradeTest task it means that they need to:

  • apply the elasticsearch.bc-upgrade-test (this was already required),
  • configure the version of the cluster/node using the ElasticsearchCluster JUnit rule (It was already required, but after this change it can be read from tests.bwc.main.version or tests.old_cluster_version since both are the same. Previously, sometimes version had to be applied from tests.old_cluster_version which could be 0.0.0 to be able to support special cases.)
  • set detachedVersion to true using the ElasticsearchCluster JUnit rule when the cluster should resolve to the version not tied to any released version nor the current HEAD (This is new. This setting is currently tied to the existence of the tests.bwc.refspec.main system property).

I haven't found any of the legacy rest/yaml tests supporting bcUpgradeTest (none applies elasticsearch.bc-upgrade-test plugin), so I haven't been implementing any support for detached version for the legacy test framework.

@jozala jozala added >non-issue >test Issues or PRs that are addressing/adding tests :Delivery/Build Build or test infrastructure auto-backport Automatically create backport pull requests when merged v9.2.0 v8.19.5 v9.1.5 v8.18.8 v9.0.8 labels Sep 11, 2025
@jozala jozala force-pushed the detached-property-on-esdistro branch 4 times, most recently from 93d9153 to c0bb3d6 Compare September 16, 2025 12:10
@jozala jozala force-pushed the detached-property-on-esdistro branch from b571c5c to 18c721b Compare September 19, 2025 10:05
@elasticsearchmachine elasticsearchmachine added the serverless-linked Added by automation, don't add manually label Sep 19, 2025
Comment on lines 14 to 25
doFirst {
if (System.getProperty("tests.bwc.refspec.main") == null) {
throw new GradleException("You must set the `tests.bwc.refspec.main` system property to run bcUpgradeTest")
}
if (System.getProperty("tests.bwc.main.version") == null) {
throw new GradleException("You must set the `tests.bwc.main.version` system property to run bcUpgradeTest")
}
}
if (System.getProperty("tests.bwc.refspec.main") != null && System.getProperty("tests.bwc.main.version") != null) {
usesBwcDistributionFromRef(System.getProperty("tests.bwc.refspec.main"), Version.fromString(System.getProperty("tests.bwc.main.version")))
systemProperty("tests.old_cluster_version", System.getProperty("tests.bwc.main.version"))
}
Copy link
Contributor Author

@jozala jozala Sep 19, 2025

Choose a reason for hiding this comment

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

This and usesBwcDistributionFromRef implementation in RestTestBasePlugin are the core changes of this PR. Instead of setting the 0.0.0 version, the correct version from required tests.bwc.main.version is used.

Comment on lines +249 to 250
if (version.before(bwcVersions.getMinimumWireCompatibleVersion())) {
// If we are upgrade testing older versions we also need to upgrade to 7.last
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The above usesBwcDistribution is now simplified, because handling of 0.0.0 (now "detached") has been moved to the usesBwcDistributionFromRef implementation below.

Comment on lines +96 to +108
/**
* Informs if the version is not tied to any Elasticsearch release and is a custom build.
* This is true when the distribution is not from HEAD but also not any known released version.
* In that case the detached source build needs to be prepared by `usedBwcDistributionFromRef(ref, version)`.
*/
public boolean isDetachedVersion() {
return detachedVersion.get();
}

public void setDetachedVersion(boolean detachedVersion) {
this.detachedVersion.set(detachedVersion);
}

Copy link
Contributor Author

@jozala jozala Sep 19, 2025

Choose a reason for hiding this comment

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

I refrained from using "snapshot" and used "detached" instead, because "snapshot" seems to be overloaded term. However, I'm interested in your opinion on that and any suggestions for better naming.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like the term detatched. I certainly can't think of a better one and I agree "snapshot" is both overloaded and not really appropriate here.

Comment on lines 26 to 37
doFirst {
if (System.getProperty("tests.bwc.refspec.main") == null) {
throw new GradleException("You must set the `tests.bwc.refspec.main` system property to run luceneBwcTest")
}
if (System.getProperty("tests.bwc.main.version") == null) {
throw new GradleException("You must set the `tests.bwc.main.version` system property to run luceneBwcTest")
}
}
if (System.getProperty("tests.bwc.refspec.main") != null && System.getProperty("tests.bwc.main.version") != null) {
usesBwcDistributionFromRef(System.getProperty("tests.bwc.refspec.main"), Version.fromString(System.getProperty("tests.bwc.main.version")))
systemProperty("tests.old_cluster_version", System.getProperty("tests.bwc.main.version"))
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same logic change as in /elasticsearch.bc-upgrade-test.gradle

Node node = nodes.get(index);
node.stop(false);
LOGGER.info("Upgrading node '{}' to version {}", node.getName(), version);
node.getSpec().setDetachedVersion(false);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is needed for the cluster to be upgraded to the actual specified version and not keep using the same detached version as before.
It has a limitation of not being able to upgrade to the detached version, but there is no such test case currently.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, this separation is what makes this somewhat awkward. Which is why I originally envisioned the notion of "detached" here to be captured by Version itself. All the test clusters stuff uses it's own Version class, so we could add a detached property to it. It would save us having to muck with all these method signatures and API that already accept a Version while still being able to pass that knowledge down to things that care about that.

So how about we add detached to Version. We'll then add some factory methods that take the additional boolean argument. We can do the same on LocalSpecBuilder by adding a version(String, boolean) method. If unspecified the default will be to set detached = false. That way this all "just works". We just look at the detached property of the passed Version to figure out what to do. This also allows us in the future to have tests that upgrade to detached versions as well. As this is written that wouldn't be possible.

@jozala jozala changed the title WIP: [Test] Replace 0.0.0 version with "detached" property on ElasticsearchDistibution [Test] Replace 0.0.0 version with "detached" property on ElasticsearchDistibution Sep 19, 2025
@jozala jozala marked this pull request as ready for review September 19, 2025 14:56
@jozala jozala requested a review from a team as a code owner September 19, 2025 14:56
@elasticsearchmachine elasticsearchmachine added the Team:Delivery Meta label for Delivery team label Sep 19, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-delivery (Team:Delivery)

ElasticsearchDistibution for tests

Introduce a new property to indicate if the version is a custom build
not tied to any release. This was previously handled by specifying
version as 0.0.0, but caused problems when comparing versions (e.g., to
decide on configuration).
Added
`.detachedVersion(System.getProperty("tests.bwc.refspec.main") != null)`
to all the tests which apply 'elasticsearch.bc-upgrade-test' plugin to
make them properly resolve distribution (previously configured by
specifying `0.0.0` version).
In the bcUpgradeTests these tests were previously skipped because
version was set to `0.0.0` which was outside the supported range.
Now, when `tests.old_cluster_version` has correct version they run, but
fail just because `9.2.0-SNAPSHOT` was considered unsupported version
format with the "SNAPSHOT".
@jozala jozala merged commit 664a604 into elastic:main Oct 3, 2025
34 checks passed
jozala added a commit to jozala/elasticsearch that referenced this pull request Oct 3, 2025
…hDistibution (elastic#134584)

Introduce a new `detached` property to indicate if the version is a custom build
not tied to any release. This was previously handled by specifying
version as 0.0.0, but caused problems when comparing versions (e.g., to
decide on configuration).
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.19 Commit could not be cherrypicked due to conflicts
9.1
9.0 Commit could not be cherrypicked due to conflicts
8.18 Commit could not be cherrypicked due to conflicts
9.2

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 134584

jozala added a commit to jozala/elasticsearch that referenced this pull request Oct 3, 2025
…hDistibution (elastic#134584)

Introduce a new `detached` property to indicate if the version is a custom build
not tied to any release. This was previously handled by specifying
version as 0.0.0, but caused problems when comparing versions (e.g., to
decide on configuration).
elasticsearchmachine pushed a commit that referenced this pull request Oct 3, 2025
…hDistibution (#134584) (#135903)

Introduce a new `detached` property to indicate if the version is a custom build
not tied to any release. This was previously handled by specifying
version as 0.0.0, but caused problems when comparing versions (e.g., to
decide on configuration).
elasticsearchmachine pushed a commit that referenced this pull request Oct 3, 2025
…hDistibution (#134584) (#135904)

Introduce a new `detached` property to indicate if the version is a custom build
not tied to any release. This was previously handled by specifying
version as 0.0.0, but caused problems when comparing versions (e.g., to
decide on configuration).
jozala added a commit to jozala/elasticsearch that referenced this pull request Oct 3, 2025
…hDistibution (elastic#134584)

Introduce a new `detached` property to indicate if the version is a custom build
not tied to any release. This was previously handled by specifying
version as 0.0.0, but caused problems when comparing versions (e.g., to
decide on configuration).

(cherry picked from commit 664a604)

# Conflicts:
#	qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/AbstractRollingUpgradeWithSecurityTestCase.java
#	test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java
#	x-pack/plugin/logsdb/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/StandardToLogsDbIndexModeRollingUpgradeIT.java
@jozala
Copy link
Contributor Author

jozala commented Oct 3, 2025

💔 Some backports could not be created

Status Branch Result
9.0
8.19 Conflict resolution was aborted by the user
8.18 Conflict resolution was aborted by the user

Manual backport

To create the backport manually run:

backport --pr 134584

Questions ?

Please refer to the Backport tool documentation

@jozala
Copy link
Contributor Author

jozala commented Oct 3, 2025

This doesn't need to be backported to 8.19 and 8.18 because bcUpgradeTest and version 0.0.0 was never introduced on these branches.

elasticsearchmachine pushed a commit that referenced this pull request Oct 3, 2025
…hDistibution (#134584) (#135924)

Introduce a new `detached` property to indicate if the version is a custom build
not tied to any release. This was previously handled by specifying
version as 0.0.0, but caused problems when comparing versions (e.g., to
decide on configuration).

(cherry picked from commit 664a604)

# Conflicts:
#	qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/AbstractRollingUpgradeWithSecurityTestCase.java
#	test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java
#	x-pack/plugin/logsdb/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/StandardToLogsDbIndexModeRollingUpgradeIT.java
jozala added a commit to jozala/elasticsearch that referenced this pull request Oct 7, 2025
These asserts have been enabled for the lucene compat because
`oldVersion` is now correctly set after elastic#134584 which removed `0.0.0`
version.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged :Delivery/Build Build or test infrastructure >non-issue serverless-linked Added by automation, don't add manually Team:Delivery Meta label for Delivery team >test Issues or PRs that are addressing/adding tests v9.0.9 v9.1.6 v9.2.1 v9.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants