Skip to content

Commit 92fcbd3

Browse files
authored
Migrate remaining ESIntegTestCases to internalClusterTest (#56479)
This commit migrates the ESIntegTestCase tests in x-pack to the internalClusterTest source set.
1 parent 410b079 commit 92fcbd3

File tree

61 files changed

+33
-131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+33
-131
lines changed

buildSrc/src/main/java/org/elasticsearch/gradle/precommit/TestingConventionsTasks.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,8 @@
4747
import java.nio.file.Path;
4848
import java.nio.file.StandardOpenOption;
4949
import java.nio.file.attribute.BasicFileAttributes;
50-
import java.util.Arrays;
5150
import java.util.Collections;
5251
import java.util.HashMap;
53-
import java.util.List;
5452
import java.util.Map;
5553
import java.util.Objects;
5654
import java.util.Set;
@@ -66,8 +64,6 @@ public class TestingConventionsTasks extends DefaultTask {
6664

6765
private final NamedDomainObjectContainer<TestingConventionRule> naming;
6866

69-
private List<String> tasks = null;
70-
7167
public TestingConventionsTasks() {
7268
setDescription("Tests various testing conventions");
7369
// Run only after everything is compiled
@@ -80,7 +76,6 @@ public Map<String, Set<File>> getClassFilesPerEnabledTask() {
8076
return getProject().getTasks()
8177
.withType(Test.class)
8278
.stream()
83-
.filter(t -> tasks == null || tasks.contains(t.getName()))
8479
.filter(Task::getEnabled)
8580
.collect(Collectors.toMap(Task::getPath, task -> task.getCandidateClassFiles().getFiles()));
8681
}
@@ -115,10 +110,6 @@ public void naming(Closure<TestingConventionRule> action) {
115110
naming.configure(action);
116111
}
117112

118-
public void setTasks(String... tasks) {
119-
this.tasks = Arrays.asList(tasks);
120-
}
121-
122113
@Input
123114
public Set<String> getMainClassNamedLikeTests() {
124115
SourceSetContainer javaSourceSets = GradleUtils.getJavaSourceSets(getProject());
@@ -168,8 +159,10 @@ public void doCheck() throws IOException {
168159

169160
final Map<String, Set<File>> classFilesPerTask = getClassFilesPerEnabledTask();
170161

162+
final Set<File> testSourceSetFiles = Util.getJavaTestSourceSet(getProject()).get().getRuntimeClasspath().getFiles();
171163
final Map<String, Set<Class<?>>> testClassesPerTask = classFilesPerTask.entrySet()
172164
.stream()
165+
.filter(entry -> testSourceSetFiles.containsAll(entry.getValue()))
173166
.collect(
174167
Collectors.toMap(
175168
Map.Entry::getKey,

server/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ testingConventions {
180180
baseClass "org.elasticsearch.test.ESSingleNodeTestCase"
181181
}
182182
}
183-
tasks = ['test']
184183
}
185184

186185
task generateModulesList {

x-pack/plugin/async-search/build.gradle

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
evaluationDependsOn(xpackModule('core'))
22

33
apply plugin: 'elasticsearch.esplugin'
4+
apply plugin: 'elasticsearch.internal-cluster-test'
45
esplugin {
56
name 'x-pack-async-search'
67
description 'A module which allows to track the progress of a search asynchronously.'
@@ -35,13 +36,3 @@ dependencyLicenses {
3536

3637
integTest.enabled = false
3738

38-
// Instead we create a separate task to run the
39-
// tests based on ESIntegTestCase
40-
task internalClusterTest(type: Test) {
41-
description = 'Java fantasy integration tests'
42-
mustRunAfter test
43-
44-
include '**/*IT.class'
45-
}
46-
47-
check.dependsOn internalClusterTest

x-pack/plugin/autoscaling/build.gradle

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import org.elasticsearch.gradle.info.BuildParams
33
evaluationDependsOn(xpackModule('core'))
44

55
apply plugin: 'elasticsearch.esplugin'
6+
apply plugin: 'elasticsearch.internal-cluster-test'
67

78
esplugin {
89
name 'x-pack-autoscaling'
@@ -16,19 +17,12 @@ archivesBaseName = 'x-pack-autoscaling'
1617

1718
integTest.enabled = false
1819

19-
task internalClusterTest(type: Test) {
20-
description = 'Java fantasy integration tests'
21-
mustRunAfter test
22-
23-
include '**/*IT.class'
24-
systemProperty 'es.set.netty.runtime.available.processors', 'false'
20+
tasks.named('internalClusterTest').configure {
2521
if (BuildParams.isSnapshotBuild() == false) {
2622
systemProperty 'es.autoscaling_feature_flag_registered', 'true'
2723
}
2824
}
2925

30-
check.dependsOn internalClusterTest
31-
3226
dependencies {
3327
compileOnly project(path: xpackModule('core'), configuration: 'default')
3428
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts')

x-pack/plugin/ccr/build.gradle

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
evaluationDependsOn(xpackModule('core'))
22

33
apply plugin: 'elasticsearch.esplugin'
4+
apply plugin: 'elasticsearch.internal-cluster-test'
45
esplugin {
56
name 'x-pack-ccr'
67
description 'Elasticsearch Expanded Pack Plugin - CCR'
@@ -16,28 +17,18 @@ integTest.enabled = false
1617
// Integration Test classes that cannot run with the security manager
1718
String[] noSecurityManagerITClasses = ["**/CloseFollowerIndexIT.class"]
1819

19-
task internalClusterTestNoSecurityManager(type: Test) {
20-
description = 'Java fantasy integration tests with no security manager'
21-
20+
tasks.register('internalClusterTestNoSecurityManager', Test) {
21+
testClassesDirs = sourceSets.internalClusterTest.output.classesDirs
22+
classpath = sourceSets.internalClusterTest.runtimeClasspath
2223
include noSecurityManagerITClasses
23-
systemProperty 'es.set.netty.runtime.available.processors', 'false'
2424
systemProperty 'tests.security.manager', 'false'
2525
}
26+
check.dependsOn 'internalClusterTestNoSecurityManager'
2627

27-
// Instead we create a separate task to run the
28-
// tests based on ESIntegTestCase
29-
task internalClusterTest(type: Test) {
30-
description = 'Java fantasy integration tests'
31-
dependsOn internalClusterTestNoSecurityManager
32-
mustRunAfter test
33-
34-
include '**/*IT.class'
28+
tasks.named('internalClusterTest').configure {
3529
exclude noSecurityManagerITClasses
36-
systemProperty 'es.set.netty.runtime.available.processors', 'false'
3730
}
3831

39-
check.dependsOn internalClusterTest
40-
4132
// add all sub-projects of the qa sub-project
4233
gradle.projectsEvaluated {
4334
project.subprojects

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowActionTests.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
import org.elasticsearch.common.settings.IndexScopedSettings;
1313
import org.elasticsearch.common.settings.Setting;
1414
import org.elasticsearch.common.settings.Settings;
15+
import org.elasticsearch.common.unit.TimeValue;
1516
import org.elasticsearch.index.IndexSettings;
1617
import org.elasticsearch.index.MapperTestUtils;
1718
import org.elasticsearch.index.mapper.MapperService;
1819
import org.elasticsearch.test.ESTestCase;
1920
import org.elasticsearch.xpack.ccr.Ccr;
2021
import org.elasticsearch.xpack.ccr.CcrSettings;
21-
import org.elasticsearch.xpack.ccr.IndexFollowingIT;
2222
import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction;
2323

2424
import java.io.IOException;
@@ -34,12 +34,20 @@
3434

3535
public class TransportResumeFollowActionTests extends ESTestCase {
3636

37+
public static ResumeFollowAction.Request resumeFollow(String followerIndex) {
38+
ResumeFollowAction.Request request = new ResumeFollowAction.Request();
39+
request.setFollowerIndex(followerIndex);
40+
request.getParameters().setMaxRetryDelay(TimeValue.timeValueMillis(10));
41+
request.getParameters().setReadPollTimeout(TimeValue.timeValueMillis(10));
42+
return request;
43+
}
44+
3745
public void testValidation() throws IOException {
3846
final Map<String, String> customMetadata = new HashMap<>();
3947
customMetadata.put(Ccr.CCR_CUSTOM_METADATA_LEADER_INDEX_SHARD_HISTORY_UUIDS, "uuid");
4048
customMetadata.put(Ccr.CCR_CUSTOM_METADATA_LEADER_INDEX_UUID_KEY, "_na_");
4149

42-
ResumeFollowAction.Request request = IndexFollowingIT.resumeFollow("index2");
50+
ResumeFollowAction.Request request = resumeFollow("index2");
4351
String[] UUIDs = new String[]{"uuid"};
4452
{
4553
IndexMetadata leaderIMD = createIMD("index1", 5, Settings.EMPTY, null);

x-pack/plugin/core/build.gradle

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import java.nio.file.Paths
66

77
apply plugin: 'elasticsearch.esplugin'
88
apply plugin: 'nebula.maven-base-publish'
9+
apply plugin: 'elasticsearch.internal-cluster-test'
910

1011
archivesBaseName = 'x-pack-core'
1112

@@ -148,8 +149,3 @@ thirdPartyAudit.ignoreMissingClasses(
148149
// so we disable integ tests
149150
integTest.enabled = false
150151

151-
// There are some integ tests that don't require a cluster, we still want to run those
152-
task internalClusterTest(type: Test) {
153-
include "**/*IT.class"
154-
}
155-
check.dependsOn internalClusterTest

x-pack/plugin/enrich/build.gradle

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
evaluationDependsOn(xpackModule('core'))
22

33
apply plugin: 'elasticsearch.esplugin'
4+
apply plugin: 'elasticsearch.internal-cluster-test'
45
esplugin {
56
name 'x-pack-enrich'
67
description 'Elasticsearch Expanded Pack Plugin - Enrich'
@@ -21,17 +22,6 @@ dependencies {
2122
// No real integ tests in the module:
2223
integTest.enabled = false
2324

24-
// Instead we create a separate task to run the tests based on ESIntegTestCase
25-
task internalClusterTest(type: Test) {
26-
description = '🌈🌈🌈🦄 Welcome to fantasy integration tests land! 🦄🌈🌈🌈'
27-
mustRunAfter test
28-
29-
include '**/*IT.class'
30-
systemProperty 'es.set.netty.runtime.available.processors', 'false'
31-
}
32-
33-
check.dependsOn internalClusterTest
34-
3525
// add all sub-projects of the qa sub-project
3626
gradle.projectsEvaluated {
3727
project.subprojects

x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@
3838
import java.util.Map;
3939
import java.util.Set;
4040

41-
import static org.elasticsearch.xpack.enrich.EnrichMultiNodeIT.DECORATE_FIELDS;
42-
import static org.elasticsearch.xpack.enrich.EnrichMultiNodeIT.MATCH_FIELD;
43-
import static org.elasticsearch.xpack.enrich.EnrichMultiNodeIT.SOURCE_INDEX_NAME;
4441
import static org.hamcrest.Matchers.equalTo;
4542
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
4643
import static org.hamcrest.Matchers.is;
@@ -50,6 +47,10 @@
5047

5148
public class BasicEnrichTests extends ESSingleNodeTestCase {
5249

50+
static final String SOURCE_INDEX_NAME = "users";
51+
static final String MATCH_FIELD = "email";
52+
static final String[] DECORATE_FIELDS = new String[] { "address", "city", "country" };
53+
5354
@Override
5455
protected Collection<Class<? extends Plugin>> getPlugins() {
5556
return Arrays.asList(LocalStateEnrich.class, ReindexPlugin.class, IngestCommonPlugin.class, MustachePlugin.class, GeoPlugin.class);

x-pack/plugin/eql/build.gradle

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import org.elasticsearch.gradle.info.BuildParams
33
evaluationDependsOn(xpackModule('core'))
44

55
apply plugin: 'elasticsearch.esplugin'
6+
apply plugin: 'elasticsearch.internal-cluster-test'
67
esplugin {
78
name 'x-pack-eql'
89
description 'The Elasticsearch plugin that powers EQL for Elasticsearch'
@@ -20,21 +21,12 @@ archivesBaseName = 'x-pack-eql'
2021
// All integration tests live in qa modules
2122
integTest.enabled = false
2223

23-
task internalClusterTest(type: Test) {
24-
mustRunAfter test
25-
include '**/*IT.class'
26-
/*
27-
* We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each
28-
* other if we allow them to set the number of available processors as it's set-once in Netty.
29-
*/
30-
systemProperty 'es.set.netty.runtime.available.processors', 'false'
24+
tasks.named('internalClusterTest').configure {
3125
if (BuildParams.isSnapshotBuild() == false) {
3226
systemProperty 'es.eql_feature_flag_registered', 'true'
3327
}
3428
}
3529

36-
check.dependsOn internalClusterTest
37-
3830
dependencies {
3931
compileOnly project(path: xpackModule('core'), configuration: 'default')
4032
compileOnly(project(':modules:lang-painless')) {

x-pack/plugin/ml/build.gradle

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
evaluationDependsOn(xpackModule('core'))
22

33
apply plugin: 'elasticsearch.esplugin'
4+
apply plugin: 'elasticsearch.internal-cluster-test'
45
esplugin {
56
name 'x-pack-ml'
67
description 'Elasticsearch Expanded Pack Plugin - Machine Learning'
@@ -99,17 +100,6 @@ project.afterEvaluate {
99100
// so we disable integ tests
100101
integTest.enabled = false
101102

102-
// Instead we create a separate task to run the
103-
// tests based on ESIntegTestCase
104-
task internalClusterTest(type: Test) {
105-
description = 'Multi-node tests'
106-
107-
include '**/*IT.class'
108-
systemProperty 'es.set.netty.runtime.available.processors', 'false'
109-
}
110-
check.dependsOn internalClusterTest
111-
internalClusterTest.mustRunAfter test
112-
113103
// add all sub-projects of the qa sub-project
114104
gradle.projectsEvaluated {
115105
project.subprojects
@@ -118,8 +108,3 @@ gradle.projectsEvaluated {
118108
.findAll { it.path.startsWith(project.path + ":qa") }
119109
.each { check.dependsOn it.check }
120110
}
121-
122-
// also add an "alias" task to make typing on the command line easier
123-
task icTest {
124-
dependsOn internalClusterTest
125-
}

x-pack/plugin/monitoring/build.gradle

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
evaluationDependsOn(xpackModule('core'))
22

33
apply plugin: 'elasticsearch.esplugin'
4+
apply plugin: 'elasticsearch.internal-cluster-test'
45
esplugin {
56
name 'x-pack-monitoring'
67
description 'Elasticsearch Expanded Pack Plugin - Monitoring'
@@ -45,20 +46,3 @@ dependencyLicenses {
4546
// installing them as individual plugins for integ tests doesn't make sense,
4647
// so we disable integ tests
4748
integTest.enabled = false
48-
49-
// Instead we create a separate task to run the
50-
// tests based on ESIntegTestCase
51-
task internalClusterTest(type: Test) {
52-
description = 'Multi-node tests'
53-
mustRunAfter test
54-
55-
include '**/*IT.class'
56-
systemProperty 'es.set.netty.runtime.available.processors', 'false'
57-
}
58-
59-
check.dependsOn internalClusterTest
60-
61-
// also add an "alias" task to make typing on the command line easier task icTest {
62-
task icTest {
63-
dependsOn internalClusterTest
64-
}
Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
evaluationDependsOn(xpackModule('core'))
22

33
apply plugin: 'elasticsearch.esplugin'
4+
apply plugin: 'elasticsearch.internal-cluster-test'
45

56
esplugin {
67
name 'search-business-rules'
@@ -13,17 +14,6 @@ archivesBaseName = 'x-pack-searchbusinessrules'
1314

1415
integTest.enabled = false
1516

16-
// Instead we create a separate task to run the
17-
// tests based on ESIntegTestCase
18-
task internalClusterTest(type: Test) {
19-
description = 'Java fantasy integration tests'
20-
mustRunAfter test
21-
22-
include '**/*IT.class'
23-
}
24-
25-
check.dependsOn internalClusterTest
26-
2717
dependencies {
2818
compileOnly project(path: xpackModule('core'), configuration: 'default')
2919
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts')
@@ -35,8 +25,3 @@ dependencyLicenses {
3525
ignoreSha 'x-pack-core'
3626
}
3727

38-
//testingConventions.naming {
39-
// IT {
40-
// baseClass "org.elasticsearch.xpack.searchbusinessrules.PinnedQueryBuilderIT"
41-
// }
42-
//}

0 commit comments

Comments
 (0)