Skip to content

Support entitlements in internal cluster tests #130710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

mosche
Copy link
Contributor

@mosche mosche commented Jul 7, 2025

This PR enables entitlement enforcement in internalClusterTests.

  • To prevent an implicit grant-all if storing node homes inside the Java temp dir, the temporary folder of ESTestCase is configured separately from the Java temp dir in internalClusterTests (by means of the system property tempDir, see TestRuleTemporaryFilesCleanup)

    • This requires moving ReloadingDatabasesWhilePerformingGeoLookupsIT from internalClusterTest to test, file permissions in internalClusterTest only grant file permissions on node base dirs - but not for the entire Lucene test temp dir overall.
  • This adds support to trivially allow test utility classes if annotated with @WithoutEntitlements by walking the entire stack. For example, see SecurityTestUtils which uses IOUtils to work with files.

    • This alternative uses an annotation (@EntitledTestUtilities) on the test suite similar to @EntitledTestPackages. This way stack walks can be limited to cases where such an annotation is present on the test suite.

Relates to ES-11586
Relates to ES-12042

@mosche mosche added >refactoring test-windows Trigger CI checks on Windows :Core/Infra/Entitlements Entitlements infrastructure test-fips Trigger CI checks for FIPS auto-backport Automatically create backport pull requests when merged v9.1.1 v8.19.1 labels Jul 14, 2025
@mosche mosche marked this pull request as ready for review July 14, 2025 14:24
@mosche mosche requested a review from a team as a code owner July 14, 2025 14:24
@mosche mosche requested a review from a team July 14, 2025 14:24
@elasticsearchmachine elasticsearchmachine added the Team:Core/Infra Meta label for core/infra team label Jul 14, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@mosche
Copy link
Contributor Author

mosche commented Jul 15, 2025

TODO: Improve Javadocs on final version to better guide DEVs what to do

logger.debug("Unregistering node dirs: config [{}], dataDirs [{}], repoDirs [{}]", configDir, dataDirs, repoDirs);
baseDirPaths.compute(BaseDir.CONFIG, baseDirModifier(paths -> paths.remove(configDir)));
baseDirPaths.compute(BaseDir.DATA, baseDirModifier(paths -> paths.removeAll(dataDirs)));
baseDirPaths.compute(BaseDir.SHARED_REPO, baseDirModifier(paths -> paths.removeAll(repoDirs)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Huh, this baseDirModifier pattern is kind of neat. The code ends up quite readable.

@@ -50,7 +50,7 @@ configure(childProjects.values()) {
// Omit oddball libraries that aren't in server.
def nonServerLibs = ['plugin-scanner']
if (false == nonServerLibs.contains(project.name)) {
project.getTasks().withType(Test.class).matching(test -> ['test'].contains(test.name)).configureEach(test -> {
project.getTasks().withType(Test.class).matching(test -> ['test', 'internalClusterTest'].contains(test.name)).configureEach(test -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

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 :Core/Infra/Entitlements Entitlements infrastructure >refactoring Team:Core/Infra Meta label for core/infra team test-fips Trigger CI checks for FIPS test-windows Trigger CI checks on Windows v8.19.1 v9.1.1 v9.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants