From 71145462445dfc6de35a5ab2a0ff04b1f38f17cf Mon Sep 17 00:00:00 2001 From: Rene Groeschke Date: Sun, 2 Jun 2024 17:59:53 +0200 Subject: [PATCH] Fix running cluster lookup - after loaded from configuration cache - in multiproject running parallel scenario --- .../gradle/internal/AntFixtureStop.groovy | 16 ++++----- .../gradle/internal/AntTask.groovy | 10 +++--- .../gradle/internal/test/AntFixture.groovy | 35 ++++++++++++------- .../gradle/internal/docker/DockerUtils.java | 20 ----------- .../gradle/internal/test/Fixture.java | 21 ----------- .../gradle/testclusters/TestClusterInfo.java | 11 ++++-- .../testclusters/TestClusterValueSource.java | 5 ++- .../testclusters/TestClustersRegistry.java | 24 ++++++++++--- .../discovery-ec2/qa/amazon-ec2/build.gradle | 15 ++++---- .../downgrade-to-basic-license/build.gradle | 5 +++ .../plugin/ccr/qa/multi-cluster/build.gradle | 7 ++++ .../ccr/qa/non-compliant-license/build.gradle | 4 +++ x-pack/plugin/ccr/qa/restart/build.gradle | 8 ++++- x-pack/plugin/ccr/qa/security/build.gradle | 4 +++ .../plugin/sql/qa/jdbc/security/build.gradle | 16 +++++++++ 15 files changed, 116 insertions(+), 85 deletions(-) delete mode 100644 build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/docker/DockerUtils.java delete mode 100644 build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/Fixture.java diff --git a/build-tools-internal/src/main/groovy/org/elasticsearch/gradle/internal/AntFixtureStop.groovy b/build-tools-internal/src/main/groovy/org/elasticsearch/gradle/internal/AntFixtureStop.groovy index ad37fa9f02c8c..840f8ab3a5441 100644 --- a/build-tools-internal/src/main/groovy/org/elasticsearch/gradle/internal/AntFixtureStop.groovy +++ b/build-tools-internal/src/main/groovy/org/elasticsearch/gradle/internal/AntFixtureStop.groovy @@ -15,16 +15,12 @@ import org.elasticsearch.gradle.internal.test.AntFixture import org.gradle.api.file.FileSystemOperations import org.gradle.api.file.ProjectLayout import org.gradle.api.provider.ProviderFactory -import org.gradle.api.tasks.Internal import org.gradle.process.ExecOperations import javax.inject.Inject abstract class AntFixtureStop extends LoggedExec implements FixtureStop { - @Internal - AntFixture fixture - @Inject AntFixtureStop(ProjectLayout projectLayout, ExecOperations execOperations, @@ -35,11 +31,12 @@ abstract class AntFixtureStop extends LoggedExec implements FixtureStop { void setFixture(AntFixture fixture) { assert this.fixture == null - this.fixture = fixture; - final Object pid = "${-> this.fixture.pid}" - onlyIf("pidFile exists") { fixture.pidFile.exists() } + def pidFile = fixture.pidFile + def fixtureName = fixture.name + final Object pid = "${-> Integer.parseInt(pidFile.getText('UTF-8').trim())}" + onlyIf("pidFile exists") { pidFile.exists() } doFirst { - logger.info("Shutting down ${fixture.name} with pid ${pid}") + logger.info("Shutting down ${fixtureName} with pid ${pid}") } if (OS.current() == OS.WINDOWS) { @@ -51,9 +48,8 @@ abstract class AntFixtureStop extends LoggedExec implements FixtureStop { } doLast { fileSystemOperations.delete { - it.delete(fixture.pidFile) + it.delete(pidFile) } } - this.fixture = fixture } } diff --git a/build-tools-internal/src/main/groovy/org/elasticsearch/gradle/internal/AntTask.groovy b/build-tools-internal/src/main/groovy/org/elasticsearch/gradle/internal/AntTask.groovy index 81f21f8c62d86..01a3bdaee2337 100644 --- a/build-tools-internal/src/main/groovy/org/elasticsearch/gradle/internal/AntTask.groovy +++ b/build-tools-internal/src/main/groovy/org/elasticsearch/gradle/internal/AntTask.groovy @@ -29,11 +29,6 @@ import java.nio.charset.Charset */ public abstract class AntTask extends DefaultTask { - /** - * A buffer that will contain the output of the ant code run, - * if the output was not already written directly to stdout. - */ - public final ByteArrayOutputStream outputBuffer = new ByteArrayOutputStream() @Inject protected FileSystemOperations getFileSystemOperations() { @@ -57,6 +52,11 @@ public abstract class AntTask extends DefaultTask { // otherwise groovy replaces System.out, and you have no chance to debug // ant.saveStreams = false + /** + * A buffer that will contain the output of the ant code run, + * if the output was not already written directly to stdout. + */ + ByteArrayOutputStream outputBuffer = new ByteArrayOutputStream() final int outputLevel = logger.isDebugEnabled() ? Project.MSG_DEBUG : Project.MSG_INFO final PrintStream stream = useStdout() ? System.out : new PrintStream(outputBuffer, true, Charset.defaultCharset().name()) diff --git a/build-tools-internal/src/main/groovy/org/elasticsearch/gradle/internal/test/AntFixture.groovy b/build-tools-internal/src/main/groovy/org/elasticsearch/gradle/internal/test/AntFixture.groovy index f2837ff40fb79..8fc30c2b7bc0a 100644 --- a/build-tools-internal/src/main/groovy/org/elasticsearch/gradle/internal/test/AntFixture.groovy +++ b/build-tools-internal/src/main/groovy/org/elasticsearch/gradle/internal/test/AntFixture.groovy @@ -10,22 +10,30 @@ package org.elasticsearch.gradle.internal.test import org.elasticsearch.gradle.OS + import org.elasticsearch.gradle.internal.AntFixtureStop import org.elasticsearch.gradle.internal.AntTask import org.gradle.api.GradleException +import org.gradle.api.file.ProjectLayout +import org.gradle.api.provider.Provider +import org.gradle.api.provider.ProviderFactory import org.gradle.api.tasks.Internal import org.gradle.api.tasks.TaskProvider +import javax.inject.Inject + /** * A fixture for integration tests which runs in a separate process launched by Ant. */ -class AntFixture extends AntTask implements Fixture { +class AntFixture extends AntTask { /** The path to the executable that starts the fixture. */ @Internal String executable private final List arguments = new ArrayList<>() + private ProjectLayout projectLayout + private final ProviderFactory providerFactory void args(Object... args) { arguments.addAll(args) @@ -69,19 +77,14 @@ class AntFixture extends AntTask implements Fixture { return tmpFile.exists() } - private final TaskProvider stopTask - - AntFixture() { - stopTask = createStopTask() + @Inject + AntFixture(ProjectLayout projectLayout, ProviderFactory providerFactory) { + this.providerFactory = providerFactory + this.projectLayout = projectLayout; + TaskProvider stopTask = createStopTask() finalizedBy(stopTask) } - @Override - @Internal - TaskProvider getStopTask() { - return stopTask - } - @Override protected void runAnt(AntBuilder ant) { // reset everything @@ -231,7 +234,7 @@ class AntFixture extends AntTask implements Fixture { */ @Internal protected File getBaseDir() { - return new File(project.buildDir, "fixtures/${name}") + return new File(projectLayout.getBuildDirectory().getAsFile().get(), "fixtures/${name}") } /** Returns the working directory for the process. Defaults to "cwd" inside baseDir. */ @@ -242,7 +245,7 @@ class AntFixture extends AntTask implements Fixture { /** Returns the file the process writes its pid to. Defaults to "pid" inside baseDir. */ @Internal - protected File getPidFile() { + File getPidFile() { return new File(baseDir, 'pid') } @@ -264,6 +267,12 @@ class AntFixture extends AntTask implements Fixture { return portsFile.readLines("UTF-8").get(0) } + @Internal + Provider getAddressAndPortProvider() { + File thePortFile = portsFile + return providerFactory.provider(() -> thePortFile.readLines("UTF-8").get(0)) + } + /** Returns a file that wraps around the actual command when {@code spawn == true}. */ @Internal protected File getWrapperScript() { diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/docker/DockerUtils.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/docker/DockerUtils.java deleted file mode 100644 index 76501ae729790..0000000000000 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/docker/DockerUtils.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -package org.elasticsearch.gradle.internal.docker; - -import org.elasticsearch.gradle.Architecture; - -public class DockerUtils { - - public static boolean isArchitectureSupported(Architecture architecture, DockerSupportService service) { - return service.getDockerAvailability().supportedArchitectures().contains(architecture); - } - -} diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/Fixture.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/Fixture.java deleted file mode 100644 index f7ee88c715dfa..0000000000000 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/Fixture.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -package org.elasticsearch.gradle.internal.test; - -/** - * Any object that can produce an accompanying stop task, meant to tear down - * a previously instantiated service. - */ -public interface Fixture { - - /** A task which will stop this fixture. This should be used as a finalizedBy for any tasks that use the fixture. */ - Object getStopTask(); - -} diff --git a/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/TestClusterInfo.java b/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/TestClusterInfo.java index b35e5b505775d..07663de7a9df9 100644 --- a/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/TestClusterInfo.java +++ b/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/TestClusterInfo.java @@ -6,19 +6,20 @@ * your election, the "Elastic License 2.0", the "GNU Affero General Public * License v3.0 only", or the "Server Side Public License, v 1". */ - package org.elasticsearch.gradle.testclusters; +import java.io.File; import java.util.List; public class TestClusterInfo { private final List allHttpSocketURI; private final List allTransportPortURI; + private final List auditLogs; - public TestClusterInfo(List allHttpSocketURI, List allTransportPortURI) { - + public TestClusterInfo(List allHttpSocketURI, List allTransportPortURI, List auditLogs) { this.allHttpSocketURI = allHttpSocketURI; this.allTransportPortURI = allTransportPortURI; + this.auditLogs = auditLogs; } public List getAllHttpSocketURI() { @@ -28,4 +29,8 @@ public List getAllHttpSocketURI() { public List getAllTransportPortURI() { return allTransportPortURI; } + + public List getAuditLogs() { + return auditLogs; + } } diff --git a/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/TestClusterValueSource.java b/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/TestClusterValueSource.java index 34f86c8c51608..8ecadcdc6d2b1 100644 --- a/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/TestClusterValueSource.java +++ b/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/TestClusterValueSource.java @@ -20,12 +20,15 @@ public abstract class TestClusterValueSource implements ValueSource getClusterName(); + Property getPath(); + Property getService(); } } diff --git a/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersRegistry.java b/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersRegistry.java index d0cf0484623d6..f965d89eebebd 100644 --- a/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersRegistry.java +++ b/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersRegistry.java @@ -19,6 +19,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; import javax.inject.Inject; @@ -85,19 +86,32 @@ public void stopCluster(ElasticsearchCluster cluster, boolean taskFailed) { claimsInventory.put(cluster, currentClaims); cluster.setClaims(currentClaims); if (currentClaims <= 0 && runningClusters.contains(cluster)) { + System.out.println("TestClustersRegistry.stopCluster " + cluster.getName() + " stopping..."); cluster.stop(false); runningClusters.remove(cluster); } } } - public TestClusterInfo getClusterDetails(String clusterName) { - ElasticsearchCluster cluster = runningClusters.stream().filter(c -> c.getName().equals(clusterName)).findFirst().orElseThrow(); - return new TestClusterInfo(cluster.getAllHttpSocketURI(), cluster.getAllTransportPortURI()); + public TestClusterInfo getClusterDetails(String path, String clusterName) { + ElasticsearchCluster cluster = runningClusters.stream() + .filter(c -> c.getPath().equals(path)) + .filter(c -> c.getName().equals(clusterName)) + .findFirst() + .orElseThrow(); + return new TestClusterInfo( + cluster.getAllHttpSocketURI(), + cluster.getAllTransportPortURI(), + cluster.getNodes().stream().map(n -> n.getAuditLog()).collect(Collectors.toList()) + ); } - public void restart(String clusterName) { - ElasticsearchCluster cluster = runningClusters.stream().filter(c -> c.getName().equals(clusterName)).findFirst().orElseThrow(); + public void restart(String path, String clusterName) { + ElasticsearchCluster cluster = runningClusters.stream() + .filter(c -> c.getPath().equals(path)) + .filter(c -> c.getName().equals(clusterName)) + .findFirst() + .orElseThrow(); cluster.restart(); } diff --git a/plugins/discovery-ec2/qa/amazon-ec2/build.gradle b/plugins/discovery-ec2/qa/amazon-ec2/build.gradle index aad59be376262..dfa62be05eb42 100644 --- a/plugins/discovery-ec2/qa/amazon-ec2/build.gradle +++ b/plugins/discovery-ec2/qa/amazon-ec2/build.gradle @@ -8,7 +8,6 @@ */ import org.apache.tools.ant.filters.ReplaceTokens -import org.elasticsearch.gradle.internal.info.BuildParams import org.elasticsearch.gradle.internal.test.AntFixture import org.elasticsearch.gradle.internal.test.RestIntegTestTask import org.elasticsearch.gradle.internal.test.rest.LegacyYamlRestTestPlugin @@ -55,8 +54,9 @@ tasks.named("yamlRestTest").configure { enabled = false } ['KeyStore', 'EnvVariables', 'SystemProperties', 'ContainerCredentials', 'InstanceProfile'].forEach { action -> TaskProvider fixture = tasks.register("ec2Fixture${action}", AntFixture) { dependsOn project.sourceSets.yamlRestTest.runtimeClasspath - env 'CLASSPATH', "${-> project.sourceSets.yamlRestTest.runtimeClasspath.asPath}" - executable = "${buildParams.runtimeJavaHome.get()}/bin/java" + FileCollection cp = project.sourceSets.yamlRestTest.runtimeClasspath + env 'CLASSPATH', "${-> cp.asPath}" + executable = "${buildParams.runtimeJavaHome}/bin/java" args 'org.elasticsearch.discovery.ec2.AmazonEC2Fixture', baseDir, "${buildDir}/testclusters/yamlRestTest${action}-1/config/unicast_hosts.txt" } @@ -72,15 +72,17 @@ tasks.named("yamlRestTest").configure { enabled = false } dependsOn(yamlRestTestTask) } + Provider addressAndPort = fixture.get().addressAndPortProvider + testClusters.matching { it.name == yamlRestTestTask.name}.configureEach { numberOfNodes = ec2NumberOfNodes plugin ':plugins:discovery-ec2' setting 'discovery.seed_providers', 'ec2' setting 'network.host', '_ec2_' - setting 'discovery.ec2.endpoint', { "http://${-> fixture.get().addressAndPort}" }, IGNORE_VALUE + setting 'discovery.ec2.endpoint', { "http://${-> addressAndPort.get()}" }, IGNORE_VALUE - systemProperty "com.amazonaws.sdk.ec2MetadataServiceEndpointOverride", { "http://${-> fixture.get().addressAndPort}" }, IGNORE_VALUE + systemProperty "com.amazonaws.sdk.ec2MetadataServiceEndpointOverride", { "http://${-> addressAndPort.get() }" }, IGNORE_VALUE } } @@ -107,9 +109,10 @@ tasks.named("ec2FixtureContainerCredentials").configure { env 'ACTIVATE_CONTAINER_CREDENTIALS', true } +def someProvider = tasks.findByName("ec2FixtureContainerCredentials").addressAndPortProvider testClusters.matching { it.name == "yamlRestTestContainerCredentials" }.configureEach { environment 'AWS_CONTAINER_CREDENTIALS_FULL_URI', - { "http://${-> tasks.findByName("ec2FixtureContainerCredentials").addressAndPort}/ecs_credentials_endpoint" }, IGNORE_VALUE + { "http://${-> someProvider.get()}/ecs_credentials_endpoint" }, IGNORE_VALUE } // Extra config for InstanceProfile diff --git a/x-pack/plugin/ccr/qa/downgrade-to-basic-license/build.gradle b/x-pack/plugin/ccr/qa/downgrade-to-basic-license/build.gradle index f03bd611f3c59..ac8ce1b0fd331 100644 --- a/x-pack/plugin/ccr/qa/downgrade-to-basic-license/build.gradle +++ b/x-pack/plugin/ccr/qa/downgrade-to-basic-license/build.gradle @@ -15,6 +15,8 @@ dependencies { testImplementation project(':x-pack:plugin:ccr:qa') } +def clusterPath = getPath() + def leaderCluster = testClusters.register("leader-cluster") { testDistribution = 'DEFAULT' setting 'xpack.license.self_generated.type', 'trial' @@ -33,6 +35,7 @@ def followCluster = testClusters.register("follow-cluster") { TestClustersPlugin.REGISTRY_SERVICE_NAME ) def leaderInfo = project.getProviders().of(TestClusterValueSource.class) { + it.parameters.path.set(clusterPath) it.parameters.clusterName.set("leader-cluster") it.parameters.service = serviceProvider } @@ -73,10 +76,12 @@ tasks.register("follow-cluster", RestIntegTestTask) { TestClustersPlugin.REGISTRY_SERVICE_NAME ) def leaderInfo = project.getProviders().of(TestClusterValueSource.class) { + it.parameters.path.set(clusterPath) it.parameters.clusterName.set("leader-cluster") it.parameters.service = serviceProvider } def followInfo = project.getProviders().of(TestClusterValueSource.class) { + it.parameters.path.set(clusterPath) it.parameters.clusterName.set("follow-cluster") it.parameters.service = serviceProvider } diff --git a/x-pack/plugin/ccr/qa/multi-cluster/build.gradle b/x-pack/plugin/ccr/qa/multi-cluster/build.gradle index 5397d3152397a..86abbbbeedf6b 100644 --- a/x-pack/plugin/ccr/qa/multi-cluster/build.gradle +++ b/x-pack/plugin/ccr/qa/multi-cluster/build.gradle @@ -16,6 +16,7 @@ dependencies { testImplementation project(':x-pack:plugin:ccr:qa') } +def clusterPath = getPath() def leaderCluster = testClusters.register('leader-cluster') { testDistribution = 'DEFAULT' setting 'xpack.license.self_generated.type', 'trial' @@ -35,6 +36,7 @@ def middleCluster = testClusters.register('middle-cluster') { TestClustersPlugin.REGISTRY_SERVICE_NAME ) def leaderInfo = project.getProviders().of(TestClusterValueSource.class) { + it.parameters.path.set(clusterPath) it.parameters.clusterName.set("leader-cluster") it.parameters.service = serviceProvider } @@ -61,6 +63,7 @@ tasks.register("middle-cluster", RestIntegTestTask) { ) def leaderUri = project.getProviders().of(TestClusterValueSource.class) { + it.parameters.path.set(clusterPath) it.parameters.clusterName.set("leader-cluster") it.parameters.service = serviceProvider }.map { it.allHttpSocketURI.get(0) } @@ -80,11 +83,13 @@ tasks.register('follow-cluster', RestIntegTestTask) { ) def leaderUri = project.getProviders().of(TestClusterValueSource.class) { + it.parameters.path.set(clusterPath) it.parameters.clusterName.set("leader-cluster") it.parameters.service = serviceProvider }.map { it.allHttpSocketURI.get(0) } def middleUri = project.getProviders().of(TestClusterValueSource.class) { + it.parameters.path.set(clusterPath) it.parameters.clusterName.set("middle-cluster") it.parameters.service = serviceProvider }.map { it.allHttpSocketURI.get(0) } @@ -104,11 +109,13 @@ testClusters.matching { it.name == "follow-cluster" }.configureEach { TestClustersPlugin.REGISTRY_SERVICE_NAME ) def leaderUris = project.getProviders().of(TestClusterValueSource.class) { + it.parameters.path.set(clusterPath) it.parameters.clusterName.set("leader-cluster") it.parameters.service = serviceProvider }.map { it.getAllTransportPortURI() } def middleUris = project.getProviders().of(TestClusterValueSource.class) { + it.parameters.path.set(clusterPath) it.parameters.clusterName.set("middle-cluster") it.parameters.service = serviceProvider }.map { it.getAllTransportPortURI() } diff --git a/x-pack/plugin/ccr/qa/non-compliant-license/build.gradle b/x-pack/plugin/ccr/qa/non-compliant-license/build.gradle index 22cb8f52a660e..ff342accef277 100644 --- a/x-pack/plugin/ccr/qa/non-compliant-license/build.gradle +++ b/x-pack/plugin/ccr/qa/non-compliant-license/build.gradle @@ -14,6 +14,8 @@ dependencies { testImplementation project(':x-pack:plugin:ccr:qa:') } +def clusterPath = getPath() + def leaderCluster = testClusters.register('leader-cluster') { testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'true' @@ -31,6 +33,7 @@ def followerCluster = testClusters.register('follow-cluster') { TestClustersPlugin.REGISTRY_SERVICE_NAME ) def leaderInfo = project.getProviders().of(TestClusterValueSource.class) { + it.parameters.path.set(clusterPath) it.parameters.clusterName.set("leader-cluster") it.parameters.service = serviceProvider } @@ -55,6 +58,7 @@ tasks.register('follow-cluster', RestIntegTestTask) { TestClustersPlugin.REGISTRY_SERVICE_NAME ) def followInfo = project.getProviders().of(TestClusterValueSource.class) { + it.parameters.path.set(clusterPath) it.parameters.clusterName.set("follow-cluster") it.parameters.service = serviceProvider } diff --git a/x-pack/plugin/ccr/qa/restart/build.gradle b/x-pack/plugin/ccr/qa/restart/build.gradle index 17dd416cd931a..848beb1da10ae 100644 --- a/x-pack/plugin/ccr/qa/restart/build.gradle +++ b/x-pack/plugin/ccr/qa/restart/build.gradle @@ -13,6 +13,8 @@ dependencies { testImplementation project(':x-pack:plugin:ccr:qa') } +def clusterPath = getPath() + def leaderCluster = testClusters.register('leader-cluster') { testDistribution = 'DEFAULT' setting 'xpack.license.self_generated.type', 'trial' @@ -32,6 +34,7 @@ def followCluster = testClusters.register('follow-cluster') { TestClustersPlugin.REGISTRY_SERVICE_NAME ) def leaderInfo = project.getProviders().of(TestClusterValueSource.class) { + it.parameters.path.set(clusterPath) it.parameters.clusterName.set("leader-cluster") it.parameters.service = serviceProvider } @@ -57,6 +60,7 @@ tasks.register('follow-cluster', RestIntegTestTask) { TestClustersPlugin.REGISTRY_SERVICE_NAME ) def leaderUri = project.getProviders().of(TestClusterValueSource.class) { + it.parameters.path.set(clusterPath) it.parameters.clusterName.set("leader-cluster") it.parameters.service = serviceProvider }.map { it.allHttpSocketURI.get(0) } @@ -77,11 +81,13 @@ tasks.register("followClusterRestartTest", StandaloneRestIntegTestTask) { TestClustersPlugin.REGISTRY_SERVICE_NAME ) def leaderUri = project.getProviders().of(TestClusterValueSource.class) { + it.parameters.path.set(clusterPath) it.parameters.clusterName.set("leader-cluster") it.parameters.service = serviceProvider }.map { it.allHttpSocketURI.get(0) } def followUris = project.getProviders().of(TestClusterValueSource.class) { + it.parameters.path.set(clusterPath) it.parameters.clusterName.set("follow-cluster") it.parameters.service = serviceProvider }.map { it.allHttpSocketURI.join(",") } @@ -90,7 +96,7 @@ tasks.register("followClusterRestartTest", StandaloneRestIntegTestTask) { nonInputProperties.systemProperty 'tests.rest.cluster', followUris doFirst { - serviceProvider.get().restart("follow-cluster") + serviceProvider.get().restart(clusterPath, "follow-cluster") } } diff --git a/x-pack/plugin/ccr/qa/security/build.gradle b/x-pack/plugin/ccr/qa/security/build.gradle index bcb45d3f02e71..454a9ae721736 100644 --- a/x-pack/plugin/ccr/qa/security/build.gradle +++ b/x-pack/plugin/ccr/qa/security/build.gradle @@ -15,6 +15,8 @@ dependencies { testImplementation project(':x-pack:plugin:ccr:qa') } +def clusterPath = getPath() + def leadCluster = testClusters.register('leader-cluster') { testDistribution = 'DEFAULT' setting 'xpack.license.self_generated.type', 'trial' @@ -31,6 +33,7 @@ testClusters.register('follow-cluster') { TestClustersPlugin.REGISTRY_SERVICE_NAME ) def leaderUris = project.getProviders().of(TestClusterValueSource.class) { + it.parameters.path.set(clusterPath) it.parameters.clusterName.set("leader-cluster") it.parameters.service = serviceProvider }.map { it.AllTransportPortURI } @@ -60,6 +63,7 @@ def followerClusterTestTask = tasks.register('follow-cluster', RestIntegTestTask TestClustersPlugin.REGISTRY_SERVICE_NAME ) def leaderUri = project.getProviders().of(TestClusterValueSource.class) { + it.parameters.path.set(clusterPath) it.parameters.clusterName.set("leader-cluster") it.parameters.service = serviceProvider }.map { it.allHttpSocketURI.get(0) } diff --git a/x-pack/plugin/sql/qa/jdbc/security/build.gradle b/x-pack/plugin/sql/qa/jdbc/security/build.gradle index c446755e91929..89e55db3a08ad 100644 --- a/x-pack/plugin/sql/qa/jdbc/security/build.gradle +++ b/x-pack/plugin/sql/qa/jdbc/security/build.gradle @@ -1,4 +1,6 @@ import org.elasticsearch.gradle.internal.test.RestIntegTestTask +import org.elasticsearch.gradle.testclusters.TestClustersRegistry +import org.elasticsearch.gradle.testclusters.TestClusterValueSource apply plugin: 'elasticsearch.internal-test-artifact' @@ -11,7 +13,10 @@ dependencies { Project mainProject = project + subprojects { + def clusterPath = getPath() + // Use tests from the root security qa project in subprojects configurations.create('testArtifacts').transitive(false) @@ -46,6 +51,17 @@ subprojects { dependsOn copyTestClasses classpath += configurations.testArtifacts testClassesDirs = project.files(testArtifactsDir) + + Provider serviceProvider = GradleUtils.getBuildService( + project.gradle.sharedServices, + TestClustersPlugin.REGISTRY_SERVICE_NAME + ) + def clusterInfo = project.getProviders().of(TestClusterValueSource.class) { + it.parameters.path.set(clusterPath) + it.parameters.clusterName.set("javaRestTest") + it.parameters.service = serviceProvider + } + nonInputProperties.systemProperty 'tests.audit.logfile', "${-> testClusters.javaRestTest.singleNode().getAuditLog()}" nonInputProperties.systemProperty 'tests.audit.yesterday.logfile',