Skip to content

Commit 08b8d11

Browse files
authored
Add support for switching distribution for all integration tests (#30874)
* remove left-over comment * make sure of the property for plugins * skip installing modules if these exist in the distribution * Log the distrbution being ran * Don't allow running with integ-tests-zip passed externally * top level x-pack/qa can't run with oss distro * Add support for matching objects in lists Makes it possible to have a key that points to a list and assert that a certain object is present in the list. All keys have to be present and values have to match. The objects in the source list may have additional fields. example: ``` match: { 'nodes.$master.plugins': { name: ingest-attachment } } ``` * Update plugin and module tests to work with other distributions Some of the tests expected that the integration tests will always be ran with the `integ-test-zip` distribution so that there will be no other plugins loaded. With this change, we check for the presence of the plugin without assuming exclusivity. * Allow modules to run on other distros as well To match the behavior of tets.distributions * Add and use a new `contains` assertion Replaces the previus changes that caused `match` to do a partial match. * Implement PR review comments
1 parent 544e473 commit 08b8d11

File tree

33 files changed

+174
-65
lines changed

33 files changed

+174
-65
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ public class PluginBuildPlugin extends BuildPlugin {
7171
if (isModule) {
7272
project.integTestCluster.module(project)
7373
project.tasks.run.clusterConfig.module(project)
74-
project.tasks.run.clusterConfig.distribution = 'integ-test-zip'
74+
project.tasks.run.clusterConfig.distribution = System.getProperty(
75+
'run.distribution', 'integ-test-zip'
76+
)
7577
} else {
7678
project.integTestCluster.plugin(project.path)
7779
project.tasks.run.clusterConfig.plugin(project.path)
@@ -111,7 +113,7 @@ public class PluginBuildPlugin extends BuildPlugin {
111113
private static void createIntegTestTask(Project project) {
112114
RestIntegTestTask integTest = project.tasks.create('integTest', RestIntegTestTask.class)
113115
integTest.mustRunAfter(project.precommit, project.test)
114-
project.integTestCluster.distribution = 'integ-test-zip'
116+
project.integTestCluster.distribution = System.getProperty('tests.distribution', 'integ-test-zip')
115117
project.check.dependsOn(integTest)
116118
}
117119

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ class ClusterFormationTasks {
8888
Configuration currentDistro = project.configurations.create("${prefix}_elasticsearchDistro")
8989
Configuration bwcDistro = project.configurations.create("${prefix}_elasticsearchBwcDistro")
9090
Configuration bwcPlugins = project.configurations.create("${prefix}_elasticsearchBwcPlugins")
91+
if (System.getProperty('tests.distribution', 'oss-zip') == 'integ-test-zip') {
92+
throw new Exception("tests.distribution=integ-test-zip is not supported")
93+
}
9194
configureDistributionDependency(project, config.distribution, currentDistro, VersionProperties.elasticsearch)
9295
if (config.numBwcNodes > 0) {
9396
if (config.bwcVersion == null) {
@@ -533,7 +536,8 @@ class ClusterFormationTasks {
533536

534537
static Task configureInstallModuleTask(String name, Project project, Task setup, NodeInfo node, Project module) {
535538
if (node.config.distribution != 'integ-test-zip') {
536-
throw new GradleException("Module ${module.path} not allowed be installed distributions other than integ-test-zip because they should already have all modules bundled!")
539+
project.logger.lifecycle("Not installing modules for $name, ${node.config.distribution} already has them")
540+
return setup
537541
}
538542
if (module.plugins.hasPlugin(PluginBuildPlugin) == false) {
539543
throw new GradleException("Task ${name} cannot include module ${module.path} which is not an esplugin")
@@ -643,6 +647,9 @@ class ClusterFormationTasks {
643647
BuildPlugin.requireJavaHome(start, node.javaVersion)
644648
}
645649
start.doLast(elasticsearchRunner)
650+
start.doFirst {
651+
project.logger.info("Starting node in ${node.clusterName} distribution: ${node.config.distribution}")
652+
}
646653
return start
647654
}
648655

modules/aggs-matrix-stats/src/test/resources/rest-api-spec/test/stats/10_basic.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
- do:
1111
nodes.info: {}
1212

13-
- match: { nodes.$master.modules.0.name: aggs-matrix-stats }
13+
- contains: { nodes.$master.modules: { name: aggs-matrix-stats } }

modules/analysis-common/src/test/resources/rest-api-spec/test/analysis-common/10_basic.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
- do:
99
nodes.info: {}
1010

11-
- match: { nodes.$master.modules.0.name: analysis-common }
11+
- contains: { nodes.$master.modules: { name: analysis-common } }

modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/10_basic.yml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@
88
- do:
99
nodes.info: {}
1010

11-
- match: { nodes.$master.modules.0.name: ingest-common }
12-
- match: { nodes.$master.ingest.processors.0.type: append }
13-
- match: { nodes.$master.ingest.processors.1.type: convert }
14-
- match: { nodes.$master.ingest.processors.2.type: date }
15-
- match: { nodes.$master.ingest.processors.3.type: date_index_name }
16-
- match: { nodes.$master.ingest.processors.4.type: dot_expander }
17-
- match: { nodes.$master.ingest.processors.5.type: fail }
18-
- match: { nodes.$master.ingest.processors.6.type: foreach }
19-
- match: { nodes.$master.ingest.processors.7.type: grok }
20-
- match: { nodes.$master.ingest.processors.8.type: gsub }
21-
- match: { nodes.$master.ingest.processors.9.type: join }
22-
- match: { nodes.$master.ingest.processors.10.type: json }
23-
- match: { nodes.$master.ingest.processors.11.type: kv }
24-
- match: { nodes.$master.ingest.processors.12.type: lowercase }
25-
- match: { nodes.$master.ingest.processors.13.type: remove }
26-
- match: { nodes.$master.ingest.processors.14.type: rename }
27-
- match: { nodes.$master.ingest.processors.15.type: script }
28-
- match: { nodes.$master.ingest.processors.16.type: set }
29-
- match: { nodes.$master.ingest.processors.17.type: sort }
30-
- match: { nodes.$master.ingest.processors.18.type: split }
31-
- match: { nodes.$master.ingest.processors.19.type: trim }
32-
- match: { nodes.$master.ingest.processors.20.type: uppercase }
11+
- contains: { nodes.$master.modules: { name: ingest-common } }
12+
- contains: { nodes.$master.ingest.processors: { type: append } }
13+
- contains: { nodes.$master.ingest.processors: { type: convert } }
14+
- contains: { nodes.$master.ingest.processors: { type: date } }
15+
- contains: { nodes.$master.ingest.processors: { type: date_index_name } }
16+
- contains: { nodes.$master.ingest.processors: { type: dot_expander } }
17+
- contains: { nodes.$master.ingest.processors: { type: fail } }
18+
- contains: { nodes.$master.ingest.processors: { type: foreach } }
19+
- contains: { nodes.$master.ingest.processors: { type: grok } }
20+
- contains: { nodes.$master.ingest.processors: { type: gsub } }
21+
- contains: { nodes.$master.ingest.processors: { type: join } }
22+
- contains: { nodes.$master.ingest.processors: { type: json } }
23+
- contains: { nodes.$master.ingest.processors: { type: kv } }
24+
- contains: { nodes.$master.ingest.processors: { type: lowercase } }
25+
- contains: { nodes.$master.ingest.processors: { type: remove } }
26+
- contains: { nodes.$master.ingest.processors: { type: rename } }
27+
- contains: { nodes.$master.ingest.processors: { type: script } }
28+
- contains: { nodes.$master.ingest.processors: { type: set } }
29+
- contains: { nodes.$master.ingest.processors: { type: sort } }
30+
- contains: { nodes.$master.ingest.processors: { type: split } }
31+
- contains: { nodes.$master.ingest.processors: { type: trim } }
32+
- contains: { nodes.$master.ingest.processors: { type: uppercase } }

modules/lang-expression/src/test/resources/rest-api-spec/test/lang_expression/10_basic.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
- do:
1111
nodes.info: {}
1212

13-
- match: { nodes.$master.modules.0.name: lang-expression }
13+
- contains: { nodes.$master.modules: { name: lang-expression } }

modules/lang-mustache/src/test/resources/rest-api-spec/test/lang_mustache/10_basic.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
- do:
1111
nodes.info: {}
1212

13-
- match: { nodes.$master.modules.0.name: lang-mustache }
13+
- contains: { nodes.$master.modules: { name: lang-mustache } }

modules/lang-painless/src/test/resources/rest-api-spec/test/painless/10_basic.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
- do:
1111
nodes.info: {}
1212

13-
- match: { nodes.$master.modules.0.name: lang-painless }
13+
- contains: { nodes.$master.modules: { name: lang-painless } }

modules/repository-url/src/test/resources/rest-api-spec/test/repository_url/10_basic.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ teardown:
112112
- do:
113113
nodes.info: {}
114114

115-
- match: { nodes.$master.modules.0.name: repository-url }
115+
- contains: { nodes.$master.modules: { name: repository-url } }
116116

117117
---
118118
"Restore with repository-url using http://":

modules/transport-netty4/src/test/resources/rest-api-spec/test/10_basic.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- do:
1111
nodes.info: {}
1212

13-
- match: { nodes.$master.modules.0.name: transport-netty4 }
13+
- contains: { nodes.$master.modules: { name: transport-netty4 } }
1414

1515
- do:
1616
cluster.stats: {}

0 commit comments

Comments
 (0)