Skip to content

Conversation

breskeby
Copy link
Contributor

@breskeby breskeby commented Aug 29, 2025

This ensures we provide a new test seed per build invocation when running
with configuration cache enabled while still ensuring the configuration cache
can be reused.

basically test seed beeing ignored as cc input.

@breskeby breskeby added >non-issue :Delivery/Build Build or test infrastructure Team:Delivery Meta label for Delivery team labels Aug 29, 2025
@breskeby breskeby requested a review from a team as a code owner August 29, 2025 12:39
@breskeby breskeby added auto-backport Automatically create backport pull requests when merged v9.2.0 v9.1.4 v9.0.7 v8.18.7 v8.19.4 labels Aug 29, 2025
@breskeby breskeby self-assigned this Aug 29, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@breskeby breskeby changed the title Fix testseed handling when running with cc Fix test seed handling when running with cc Aug 29, 2025
}

// randomise between sniff and proxy modes
boolean proxyMode = buildParams.random.nextBoolean()
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 resolves test seed early basically breaking configuration cache reusability every time

testSeed = testSeedProperty;
}
return testSeed;
private Provider<String> getTestSeed() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In order to be able to pass a changing value to Test tasks without breaking configuration cache reuse, we have to rely on a ValueSource here that we pass down all the way to "noninputproperties" CommandLineProvider we configure for tests tasks. ValueSource allows being opaque to the configuration cache. Other providers or plain string would always be interpreted as inputs to the configuration cache, resulting in the test seed not changing between multiple build invocation without configuration cache change

}

// randomise between sniff and proxy modes
boolean proxyMode = buildParams.random.nextBoolean()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

since we only use this in deprecated TestCluster settings I did not invest to much time to sugar code that api here for now. Ultimately this moves into tests at one point 🤞

@breskeby breskeby changed the title Fix test seed handling when running with cc [Gradle] Fix test seed handling when running with cc Aug 29, 2025
@elasticsearchmachine elasticsearchmachine added the serverless-linked Added by automation, don't add manually label Aug 29, 2025
This ensures we provide a new test seed per build invocation when running
with configuration cache enabled while still ensuring the configuration cache
can be reused.

basically test seed beeing ignored as cc input.
javaRestTestImplementation project(':x-pack:plugin:security')
}

boolean literalUsername = buildParams.random.nextBoolean()
Copy link
Contributor Author

@breskeby breskeby Sep 4, 2025

Choose a reason for hiding this comment

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

buildParams.random resolves the TestSeed and breaks configuration-cache. by moving this into the task configuration block we defer that. for this particular test cc will always be out of date. Longterm we might wand a more deterministic way of testing this behaviour

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 altenative would be to split the random from the testseed,, but this would break reproducability.

this.javaInstallationRegistry = javaInstallationRegistry;
this.metadataDetector = new ErrorTraceMetadataDetector(metadataDetector);
this.providers = providers;
this.branchesFileParser = new BranchesFileParser(new ObjectMapper());
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 seems only used at one point. therefore I removed the field property.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point. I got the impression that it belongs in constructor, to avoid creating it on every method call, but the apply method will be called only once anyway.

this.project = project;
project.getPlugins().apply(JvmToolchainsPlugin.class);
project.getPlugins().apply(JdkDownloadPlugin.class);
project.getPlugins().apply(VersionPropertiesPlugin.class);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tend to follow the pattern of applying nested plugins as early as possible (there are edge cases where you might only do it on certain conditions) in the apply method. that makes reading way simpler and I think its common practice


if (buildFeatures.getConfigurationCache().getActive().get() == false) {
// if configuration cache is enabled, resolving the test seed early breaks configuration cache reuse
LOGGER.quiet(" Random Testing Seed : " + buildParams.getTestSeed());
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 test seed printing resolves the ValueSource early and breaks configuration cache. therefore only print if not running in cc

import java.util.Locale;
import java.util.Random;

public abstract class TestSeedValueSource implements ValueSource<String, ValueSourceParameters.None> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to model the TestSeed resolution as ValueSource as this allows passing the parameter transparently for the configuration cache down to the consumers (test cases, testcluster).

Taking this from the according javadoc:

Represents an external source of information used by a Gradle build. Examples of external sources include client environment variables, system properties, configuration files, shell commands, network services, among others.
Representing external sources as [ValueSource](https://docs.gradle.org/current/javadoc/org/gradle/api/provider/ValueSource.html)s allows Gradle to transparently manage [the configuration cache](https://docs.gradle.org/current/userguide/configuration_cache.html) as values obtained from those sources change. For example, a build might run a different set of tasks depending on whether the CI environment variable is set or not.

@breskeby breskeby merged commit 8097c1a into elastic:main Sep 4, 2025
33 checks passed
breskeby added a commit to breskeby/elasticsearch that referenced this pull request Sep 4, 2025
This ensures we provide a new test seed per build invocation when running
with configuration cache enabled while still ensuring the configuration cache
can be reused.

basically test seed beeing ignored as cc input.
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

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

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

breskeby added a commit to breskeby/elasticsearch that referenced this pull request Sep 4, 2025
This ensures we provide a new test seed per build invocation when running
with configuration cache enabled while still ensuring the configuration cache
can be reused.

basically test seed beeing ignored as cc input.

(cherry picked from commit 8097c1a)

# Conflicts:
#	x-pack/plugin/security/qa/profile/build.gradle
breskeby added a commit to breskeby/elasticsearch that referenced this pull request Sep 4, 2025
This ensures we provide a new test seed per build invocation when running
with configuration cache enabled while still ensuring the configuration cache
can be reused.

basically test seed beeing ignored as cc input.

(cherry picked from commit 8097c1a)

# Conflicts:
#	x-pack/plugin/security/qa/profile/build.gradle
breskeby added a commit to breskeby/elasticsearch that referenced this pull request Sep 4, 2025
This ensures we provide a new test seed per build invocation when running
with configuration cache enabled while still ensuring the configuration cache
can be reused.

basically test seed beeing ignored as cc input.

(cherry picked from commit 8097c1a)

# Conflicts:
#	x-pack/plugin/security/qa/profile/build.gradle
@breskeby
Copy link
Contributor Author

breskeby commented Sep 4, 2025

💔 Some backports could not be created

Status Branch Result
9.0
8.19
8.18 Could not create pull request: fetch failed

Manual backport

To create the backport manually run:

backport --pr 133811

Questions ?

Please refer to the Backport tool documentation

breskeby added a commit to breskeby/elasticsearch that referenced this pull request Sep 4, 2025
This ensures we provide a new test seed per build invocation when running
with configuration cache enabled while still ensuring the configuration cache
can be reused.

basically test seed beeing ignored as cc input.

(cherry picked from commit 8097c1a)

# Conflicts:
#	x-pack/plugin/security/qa/profile/build.gradle
@breskeby
Copy link
Contributor Author

breskeby commented Sep 4, 2025

💚 All backports created successfully

Status Branch Result
8.18

Questions ?

Please refer to the Backport tool documentation

elasticsearchmachine pushed a commit that referenced this pull request Sep 4, 2025
This ensures we provide a new test seed per build invocation when running
with configuration cache enabled while still ensuring the configuration cache
can be reused.

basically test seed beeing ignored as cc input.
breskeby added a commit to breskeby/elasticsearch that referenced this pull request Sep 6, 2025
This ensures we provide a new test seed per build invocation when running
with configuration cache enabled while still ensuring the configuration cache
can be reused.

basically test seed beeing ignored as cc input.

(cherry picked from commit 8097c1a)

# Conflicts:
#	x-pack/plugin/security/qa/profile/build.gradle
breskeby added a commit that referenced this pull request Sep 6, 2025
This ensures we provide a new test seed per build invocation when running
with configuration cache enabled while still ensuring the configuration cache
can be reused.

basically test seed beeing ignored as cc input.

(cherry picked from commit 8097c1a)

# Conflicts:
#	x-pack/plugin/security/qa/profile/build.gradle
breskeby added a commit that referenced this pull request Sep 6, 2025
This ensures we provide a new test seed per build invocation when running
with configuration cache enabled while still ensuring the configuration cache
can be reused.

basically test seed beeing ignored as cc input.

(cherry picked from commit 8097c1a)

# Conflicts:
#	x-pack/plugin/security/qa/profile/build.gradle
breskeby added a commit that referenced this pull request Sep 8, 2025
…#134149)

* [Gradle] Fix test seed handling when running with cc (#133811)

This ensures we provide a new test seed per build invocation when running
with configuration cache enabled while still ensuring the configuration cache
can be reused.

basically test seed beeing ignored as cc input.

(cherry picked from commit 8097c1a)

# Conflicts:
#	x-pack/plugin/security/qa/profile/build.gradle

* Fix merge issue
phananh1010 added a commit to phananh1010/elasticsearch that referenced this pull request Sep 11, 2025
BASE=24bd70b9d1eb60747a7ba3b7c971e2096da843fd
HEAD=a25ede51f680602cdeeae9b45d1540ca9fbcc04f
Branch=main
phananh1010 added a commit to phananh1010/elasticsearch that referenced this pull request Sep 11, 2025
BASE=24bd70b9d1eb60747a7ba3b7c971e2096da843fd
HEAD=a25ede51f680602cdeeae9b45d1540ca9fbcc04f
Branch=main
sarog pushed a commit to portsbuild/elasticsearch that referenced this pull request Sep 11, 2025
…elastic#134147)

This ensures we provide a new test seed per build invocation when running
with configuration cache enabled while still ensuring the configuration cache
can be reused.

basically test seed beeing ignored as cc input.

(cherry picked from commit 8097c1a)

# Conflicts:
#	x-pack/plugin/security/qa/profile/build.gradle
phananh1010 added a commit to phananh1010/elasticsearch that referenced this pull request Sep 16, 2025
BASE=24bd70b9d1eb60747a7ba3b7c971e2096da843fd
HEAD=a25ede51f680602cdeeae9b45d1540ca9fbcc04f
Branch=main
phananh1010 added a commit to phananh1010/elasticsearch that referenced this pull request Sep 16, 2025
BASE=24bd70b9d1eb60747a7ba3b7c971e2096da843fd
HEAD=a25ede51f680602cdeeae9b45d1540ca9fbcc04f
Branch=main
phananh1010 added a commit to phananh1010/elasticsearch that referenced this pull request Sep 16, 2025
BASE=24bd70b9d1eb60747a7ba3b7c971e2096da843fd
HEAD=a25ede51f680602cdeeae9b45d1540ca9fbcc04f
Branch=main
sarog pushed a commit to portsbuild/elasticsearch that referenced this pull request Sep 19, 2025
…elastic#134147)

This ensures we provide a new test seed per build invocation when running
with configuration cache enabled while still ensuring the configuration cache
can be reused.

basically test seed beeing ignored as cc input.

(cherry picked from commit 8097c1a)

# Conflicts:
#	x-pack/plugin/security/qa/profile/build.gradle
phananh1010 added a commit to phananh1010/elasticsearch that referenced this pull request Oct 8, 2025
BASE=24bd70b9d1eb60747a7ba3b7c971e2096da843fd
HEAD=a25ede51f680602cdeeae9b45d1540ca9fbcc04f
Branch=main
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 backport pending :Delivery/Build Build or test infrastructure >non-issue serverless-linked Added by automation, don't add manually Team:Delivery Meta label for Delivery team v8.18.7 v8.19.4 v9.0.7 v9.1.4 v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants