|
@@ -9,14 +9,14 @@
|
|
|
|
|
|
package org.elasticsearch.gradle
|
|
|
|
|
|
-import org.elasticsearch.gradle.fixtures.AbstractGradleFuncTest
|
|
|
-import org.gradle.testkit.runner.GradleRunner
|
|
|
import spock.lang.IgnoreIf
|
|
|
import spock.lang.Unroll
|
|
|
+import spock.util.environment.RestoreSystemProperties
|
|
|
+
|
|
|
+import org.elasticsearch.gradle.fixtures.AbstractGradleFuncTest
|
|
|
+import org.gradle.testkit.runner.GradleRunner
|
|
|
|
|
|
-import static org.elasticsearch.gradle.fixtures.DistributionDownloadFixture.withChangedClasspathMockedDistributionDownload
|
|
|
-import static org.elasticsearch.gradle.fixtures.DistributionDownloadFixture.withChangedConfigMockedDistributionDownload
|
|
|
-import static org.elasticsearch.gradle.fixtures.DistributionDownloadFixture.withMockedDistributionDownload
|
|
|
+import static org.elasticsearch.gradle.fixtures.DistributionDownloadFixture.*
|
|
|
|
|
|
/**
|
|
|
* We do not have coverage for the test cluster startup on windows yet.
|
|
@@ -108,8 +108,8 @@ class TestClustersPluginFuncTest extends AbstractGradleFuncTest {
|
|
|
def runningClosure = { GradleRunner r -> r.build() }
|
|
|
withMockedDistributionDownload(runner, runningClosure)
|
|
|
def result = inputProperty == "distributionClasspath" ?
|
|
|
- withChangedClasspathMockedDistributionDownload(runner, runningClosure) :
|
|
|
- withChangedConfigMockedDistributionDownload(runner, runningClosure)
|
|
|
+ withChangedClasspathMockedDistributionDownload(runner, runningClosure) :
|
|
|
+ withChangedConfigMockedDistributionDownload(runner, runningClosure)
|
|
|
|
|
|
then:
|
|
|
result.output.contains("Task ':myTask' is not up-to-date because:\n Input property 'clusters.myCluster\$0.nodes.\$0.$inputProperty'")
|
|
@@ -166,18 +166,24 @@ class TestClustersPluginFuncTest extends AbstractGradleFuncTest {
|
|
|
}
|
|
|
|
|
|
then:
|
|
|
- result.output.contains("Task ':myTask' is not up-to-date because:\n" +
|
|
|
- " Input property 'clusters.myCluster\$0.$propertyName'")
|
|
|
+ result.output.contains(
|
|
|
+ "Task ':myTask' is not up-to-date because:\n" +
|
|
|
+ " Input property 'clusters.myCluster\$0.$propertyName'"
|
|
|
+ )
|
|
|
result.output.contains("elasticsearch-keystore script executed!")
|
|
|
assertEsOutputContains("myCluster", "Starting Elasticsearch process")
|
|
|
assertEsOutputContains("myCluster", "Stopping node")
|
|
|
|
|
|
where:
|
|
|
pluginType | propertyName | fileChange
|
|
|
- 'module' | "installedFiles" | { def testClazz -> testClazz.file("test-module/src/main/plugin-metadata/someAddedConfig.txt") << "new resource file" }
|
|
|
- 'plugin' | "installedFiles" | { def testClazz -> testClazz.file("test-plugin/src/main/plugin-metadata/someAddedConfig.txt") << "new resource file" }
|
|
|
- 'module' | "installedClasspath" | { def testClazz -> testClazz.file("test-module/src/main/java/SomeClass.java") << "class SomeClass {}" }
|
|
|
- 'plugin' | "installedClasspath" | { def testClazz -> testClazz.file("test-plugin/src/main/java/SomeClass.java") << "class SomeClass {}" }
|
|
|
+ 'module' | "installedFiles" |
|
|
|
+ { def testClazz -> testClazz.file("test-module/src/main/plugin-metadata/someAddedConfig.txt") << "new resource file" }
|
|
|
+ 'plugin' | "installedFiles" |
|
|
|
+ { def testClazz -> testClazz.file("test-plugin/src/main/plugin-metadata/someAddedConfig.txt") << "new resource file" }
|
|
|
+ 'module' | "installedClasspath" |
|
|
|
+ { def testClazz -> testClazz.file("test-module/src/main/java/SomeClass.java") << "class SomeClass {}" }
|
|
|
+ 'plugin' | "installedClasspath" |
|
|
|
+ { def testClazz -> testClazz.file("test-plugin/src/main/java/SomeClass.java") << "class SomeClass {}" }
|
|
|
}
|
|
|
|
|
|
def "can declare test cluster in lazy evaluated task configuration block"() {
|
|
@@ -232,9 +238,51 @@ class TestClustersPluginFuncTest extends AbstractGradleFuncTest {
|
|
|
assertCustomDistro('myCluster')
|
|
|
}
|
|
|
|
|
|
+ @RestoreSystemProperties
|
|
|
+ def "override jdk usage via ES_JAVA_HOME for known jdk os incompatibilities"() {
|
|
|
+ given:
|
|
|
+
|
|
|
+ settingsFile.text = """
|
|
|
+ plugins {
|
|
|
+ id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
|
|
|
+ }
|
|
|
+ """ + settingsFile.text
|
|
|
+
|
|
|
+ buildFile << """
|
|
|
+ testClusters {
|
|
|
+ myCluster {
|
|
|
+ testDistribution = 'default'
|
|
|
+ version = '8.10.4'
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Force linux platform to trigger jdk override
|
|
|
+ elasticsearch_distributions.forEach { d ->
|
|
|
+ d.platform = org.elasticsearch.gradle.ElasticsearchDistribution.Platform.LINUX
|
|
|
+ }
|
|
|
+
|
|
|
+ tasks.register('myTask', SomeClusterAwareTask) {
|
|
|
+ useCluster testClusters.myCluster
|
|
|
+ }
|
|
|
+ """
|
|
|
+ when:
|
|
|
+ def result = withMockedDistributionDownload(
|
|
|
+ "8.10.4",
|
|
|
+ ElasticsearchDistribution.Platform.LINUX,
|
|
|
+ gradleRunner("myTask", '-Dos.name=Linux', '-Dos.version=6.14.0-1015-gcp', '-i')
|
|
|
+ ) {
|
|
|
+ build()
|
|
|
+ }
|
|
|
+
|
|
|
+ then:
|
|
|
+ result.output.lines().anyMatch { line -> line.startsWith("Running") && line.split().find { it.startsWith("ES_JAVA_HOME=") }.contains("eclipse_adoptium-17") }
|
|
|
+ }
|
|
|
+
|
|
|
boolean assertEsOutputContains(String testCluster, String expectedOutput) {
|
|
|
- assert new File(testProjectDir.root,
|
|
|
- "build/testclusters/${testCluster}-0/logs/es.out").text.contains(expectedOutput)
|
|
|
+ assert new File(
|
|
|
+ testProjectDir.root,
|
|
|
+ "build/testclusters/${testCluster}-0/logs/es.out"
|
|
|
+ ).text.contains(expectedOutput)
|
|
|
true
|
|
|
}
|
|
|
|