Skip to content

Commit ca2fa59

Browse files
authored
Convert remaining module projects to new test clusters framework (elastic#125613) (elastic#125676)
1 parent 69115b5 commit ca2fa59

File tree

14 files changed

+179
-43
lines changed

14 files changed

+179
-43
lines changed

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,7 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
2929
ListMultimap<Class<?>, String> map = ArrayListMultimap.create(1, 200);
3030
map.put(LegacyRestTestBasePlugin.class, ":docs");
3131
map.put(LegacyRestTestBasePlugin.class, ":distribution:docker");
32-
map.put(LegacyRestTestBasePlugin.class, ":modules:lang-expression");
33-
map.put(LegacyRestTestBasePlugin.class, ":modules:lang-mustache");
34-
map.put(LegacyRestTestBasePlugin.class, ":modules:mapper-extras");
35-
map.put(LegacyRestTestBasePlugin.class, ":modules:parent-join");
36-
map.put(LegacyRestTestBasePlugin.class, ":modules:percolator");
37-
map.put(LegacyRestTestBasePlugin.class, ":modules:rank-eval");
3832
map.put(LegacyRestTestBasePlugin.class, ":modules:reindex");
39-
map.put(LegacyRestTestBasePlugin.class, ":modules:repository-url");
40-
map.put(LegacyRestTestBasePlugin.class, ":modules:transport-netty4");
4133
map.put(LegacyRestTestBasePlugin.class, ":plugins:analysis-icu");
4234
map.put(LegacyRestTestBasePlugin.class, ":plugins:analysis-kuromoji");
4335
map.put(LegacyRestTestBasePlugin.class, ":plugins:analysis-nori");

modules/lang-expression/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* your election, the "Elastic License 2.0", the "GNU Affero General Public
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
9-
apply plugin: 'elasticsearch.legacy-yaml-rest-test'
10-
apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test'
9+
apply plugin: 'elasticsearch.internal-yaml-rest-test'
10+
apply plugin: 'elasticsearch.yaml-rest-compat-test'
1111
apply plugin: 'elasticsearch.internal-cluster-test'
1212

1313
esplugin {

modules/lang-expression/src/yamlRestTest/java/org/elasticsearch/script/expression/LangExpressionClientYamlTestSuiteIT.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@
1212
import com.carrotsearch.randomizedtesting.annotations.Name;
1313
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
1414

15+
import org.elasticsearch.test.cluster.ElasticsearchCluster;
1516
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
1617
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
18+
import org.junit.ClassRule;
1719

1820
public class LangExpressionClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
1921

22+
@ClassRule
23+
public static ElasticsearchCluster cluster = ElasticsearchCluster.local().module("lang-expression").build();
24+
2025
public LangExpressionClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
2126
super(testCandidate);
2227
}
@@ -25,4 +30,9 @@ public LangExpressionClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate
2530
public static Iterable<Object[]> parameters() throws Exception {
2631
return ESClientYamlSuiteTestCase.createParameters();
2732
}
33+
34+
@Override
35+
protected String getTestRestCluster() {
36+
return cluster.getHttpAddresses();
37+
}
2838
}

modules/lang-mustache/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
* your election, the "Elastic License 2.0", the "GNU Affero General Public
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
9-
apply plugin: 'elasticsearch.legacy-yaml-rest-test'
10-
apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test'
11-
apply plugin: 'elasticsearch.legacy-java-rest-test'
9+
apply plugin: 'elasticsearch.internal-yaml-rest-test'
10+
apply plugin: 'elasticsearch.internal-java-rest-test'
11+
apply plugin: 'elasticsearch.yaml-rest-compat-test'
1212
apply plugin: 'elasticsearch.internal-cluster-test'
1313

1414
esplugin {

modules/lang-mustache/src/javaRestTest/java/org/elasticsearch/script/mustache/SearchTemplateWithoutContentIT.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@
1111

1212
import org.elasticsearch.client.Request;
1313
import org.elasticsearch.client.ResponseException;
14+
import org.elasticsearch.test.cluster.ElasticsearchCluster;
1415
import org.elasticsearch.test.rest.ESRestTestCase;
16+
import org.junit.ClassRule;
1517

1618
import java.io.IOException;
1719

1820
import static org.hamcrest.CoreMatchers.containsString;
1921

2022
public class SearchTemplateWithoutContentIT extends ESRestTestCase {
2123

24+
@ClassRule
25+
public static ElasticsearchCluster cluster = ElasticsearchCluster.local().module("lang-mustache").build();
26+
2227
public void testSearchTemplateMissingBody() throws IOException {
2328
ResponseException responseException = expectThrows(
2429
ResponseException.class,
@@ -36,4 +41,9 @@ public void testMultiSearchTemplateMissingBody() throws IOException {
3641
assertEquals(400, responseException.getResponse().getStatusLine().getStatusCode());
3742
assertThat(responseException.getMessage(), containsString("request body or source parameter is required"));
3843
}
44+
45+
@Override
46+
protected String getTestRestCluster() {
47+
return cluster.getHttpAddresses();
48+
}
3949
}

modules/lang-mustache/src/yamlRestTest/java/org/elasticsearch/script/mustache/LangMustacheClientYamlTestSuiteIT.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@
1212
import com.carrotsearch.randomizedtesting.annotations.Name;
1313
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
1414

15+
import org.elasticsearch.test.cluster.ElasticsearchCluster;
1516
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
1617
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
18+
import org.junit.ClassRule;
1719

1820
public class LangMustacheClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
1921

22+
@ClassRule
23+
public static ElasticsearchCluster cluster = ElasticsearchCluster.local().module("lang-mustache").build();
24+
2025
public LangMustacheClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
2126
super(testCandidate);
2227
}
@@ -25,4 +30,9 @@ public LangMustacheClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate t
2530
public static Iterable<Object[]> parameters() throws Exception {
2631
return ESClientYamlSuiteTestCase.createParameters();
2732
}
33+
34+
@Override
35+
protected String getTestRestCluster() {
36+
return cluster.getHttpAddresses();
37+
}
2838
}

modules/rank-eval/build.gradle

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* your election, the "Elastic License 2.0", the "GNU Affero General Public
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
9-
apply plugin: 'elasticsearch.legacy-yaml-rest-test'
10-
apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test'
9+
apply plugin: 'elasticsearch.internal-yaml-rest-test'
10+
apply plugin: 'elasticsearch.yaml-rest-compat-test'
1111
apply plugin: 'elasticsearch.internal-cluster-test'
1212

1313
esplugin {
@@ -21,9 +21,8 @@ restResources {
2121
}
2222
}
2323

24-
testClusters.configureEach {
25-
// Modules who's integration is explicitly tested in integration tests
26-
module ':modules:lang-mustache'
24+
dependencies {
25+
clusterModules project(':modules:lang-mustache')
2726
}
2827

2928
tasks.named("yamlRestTestV7CompatTransform").configure({ task ->

modules/rank-eval/src/yamlRestTest/java/org/elasticsearch/index/rankeval/RankEvalYamlIT.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@
1212
import com.carrotsearch.randomizedtesting.annotations.Name;
1313
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
1414

15+
import org.elasticsearch.test.cluster.ElasticsearchCluster;
1516
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
1617
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
18+
import org.junit.ClassRule;
1719

1820
public class RankEvalYamlIT extends ESClientYamlSuiteTestCase {
21+
22+
@ClassRule
23+
public static ElasticsearchCluster cluster = ElasticsearchCluster.local().module("lang-mustache").module("rank-eval").build();
24+
1925
public RankEvalYamlIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
2026
super(testCandidate);
2127
}
@@ -24,4 +30,9 @@ public RankEvalYamlIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
2430
public static Iterable<Object[]> parameters() throws Exception {
2531
return ESClientYamlSuiteTestCase.createParameters();
2632
}
33+
34+
@Override
35+
protected String getTestRestCluster() {
36+
return cluster.getHttpAddresses();
37+
}
2738
}

modules/transport-netty4/build.gradle

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10+
11+
import org.elasticsearch.gradle.internal.test.InternalClusterTestPlugin
1012
import org.elasticsearch.gradle.internal.test.RestIntegTestTask
1113
import org.elasticsearch.gradle.internal.test.rest.LegacyJavaRestTestPlugin
12-
import org.elasticsearch.gradle.internal.test.InternalClusterTestPlugin
1314

14-
apply plugin: 'elasticsearch.legacy-yaml-rest-test'
15-
apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test'
16-
apply plugin: 'elasticsearch.legacy-java-rest-test'
15+
apply plugin: 'elasticsearch.internal-yaml-rest-test'
16+
apply plugin: 'elasticsearch.yaml-rest-compat-test'
17+
apply plugin: 'elasticsearch.internal-java-rest-test'
1718
apply plugin: 'elasticsearch.internal-cluster-test'
1819
apply plugin: 'elasticsearch.publish'
1920

@@ -48,6 +49,8 @@ dependencies {
4849
api "io.netty:netty-transport-native-unix-common:${versions.netty}"
4950

5051
testImplementation project(':modules:rest-root')
52+
53+
clusterModules project(':modules:rest-root')
5154
}
5255

5356
restResources {
@@ -77,28 +80,12 @@ TaskProvider<Test> pooledInternalClusterTest = tasks.register("pooledInternalClu
7780
setClasspath(internalTestSourceSet.getRuntimeClasspath())
7881
}
7982

80-
TaskProvider<RestIntegTestTask> pooledJavaRestTest = tasks.register("pooledJavaRestTest", RestIntegTestTask) {
81-
SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
82-
SourceSet javaRestTestSourceSet = sourceSets.getByName(LegacyJavaRestTestPlugin.SOURCE_SET_NAME)
83-
setTestClassesDirs(javaRestTestSourceSet.getOutput().getClassesDirs())
84-
setClasspath(javaRestTestSourceSet.getRuntimeClasspath())
85-
86-
87-
testClusters.pooledJavaRestTest {
88-
systemProperty 'es.use_unpooled_allocator', 'false'
89-
}
90-
}
91-
9283
tasks.named("internalClusterTest").configure {
9384
systemProperty 'es.insecure_network_trace_enabled', 'true'
9485
}
9586

96-
testClusters.configureEach {
97-
module ':modules:rest-root'
98-
}
99-
10087
tasks.named("check").configure {
101-
dependsOn(pooledTest, pooledJavaRestTest, pooledInternalClusterTest)
88+
dependsOn(pooledTest, pooledInternalClusterTest)
10289
}
10390

10491
tasks.named("thirdPartyAudit").configure {
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.rest;
11+
12+
import com.carrotsearch.randomizedtesting.annotations.Name;
13+
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
14+
15+
import org.elasticsearch.test.cluster.ElasticsearchCluster;
16+
import org.elasticsearch.test.cluster.MutableSystemPropertyProvider;
17+
import org.elasticsearch.test.rest.ESRestTestCase;
18+
import org.junit.Before;
19+
import org.junit.ClassRule;
20+
21+
import java.io.IOException;
22+
import java.util.List;
23+
24+
public abstract class AbstractNetty4IT extends ESRestTestCase {
25+
private static final MutableSystemPropertyProvider clusterSettings = new MutableSystemPropertyProvider();
26+
private final boolean usePooledAllocator;
27+
28+
@ClassRule
29+
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
30+
.module("transport-netty4")
31+
.module("rest-root")
32+
.systemProperties(clusterSettings)
33+
.build();
34+
35+
public AbstractNetty4IT(@Name("pooled") boolean pooledAllocator) {
36+
this.usePooledAllocator = pooledAllocator;
37+
}
38+
39+
@ParametersFactory
40+
public static Iterable<Object[]> parameters() throws Exception {
41+
return List.of(new Object[] { true }, new Object[] { false });
42+
}
43+
44+
@Before
45+
public void maybeRestart() throws IOException {
46+
// Restart the cluster to pick up the new setting if necessary
47+
String current = clusterSettings.get(null).get("es.use_unpooled_allocator");
48+
if (current == null || current.equals(Boolean.toString(usePooledAllocator))) {
49+
clusterSettings.get(null).put("es.use_unpooled_allocator", Boolean.toString(usePooledAllocator == false));
50+
cluster.restart(false);
51+
closeClients();
52+
initClient();
53+
}
54+
}
55+
56+
@Override
57+
protected String getTestRestCluster() {
58+
return cluster.getHttpAddresses();
59+
}
60+
}

0 commit comments

Comments
 (0)