Skip to content

Commit a6ba4f0

Browse files
authored
[8.x] Convert more x-pack modules to new test framework (#125874) (#125991)
1 parent e625665 commit a6ba4f0

File tree

23 files changed

+187
-181
lines changed

23 files changed

+187
-181
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
3737
map.put(LegacyRestTestBasePlugin.class, ":qa:repository-multi-version");
3838
map.put(LegacyRestTestBasePlugin.class, ":qa:rolling-upgrade-legacy");
3939
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ent-search");
40-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:logstash");
41-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:vector-tile");
4240
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:mixed-tier-cluster");
4341
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:repository-old-versions");
4442
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:rolling-upgrade");
@@ -92,8 +90,6 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
9290
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:security:qa:tls-basic");
9391
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:shutdown:qa:multi-node");
9492
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:shutdown:qa:rolling-upgrade");
95-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:slm:qa:multi-node");
96-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:slm:qa:rest");
9793
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:snapshot-based-recoveries:qa:fs");
9894
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:snapshot-based-recoveries:qa:license-enforcing");
9995
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:snapshot-repo-test-kit:qa:hdfs");
@@ -106,12 +102,10 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
106102
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:sql:qa:mixed-node");
107103
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:sql:qa:server:security:with-ssl");
108104
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:sql:qa:server:security:without-ssl");
109-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:stack:qa:rest");
110105
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:text-structure:qa:text-structure-with-security");
111106
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:transform:qa:multi-cluster-tests-with-security");
112107
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:transform:qa:multi-node-tests");
113108
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:transform:qa:single-node-tests");
114-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:vector-tile:qa:multi-cluster");
115109
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:watcher:qa:rest");
116110
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:watcher:qa:with-security");
117111
return map;

x-pack/plugin/logstash/build.gradle

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apply plugin: 'elasticsearch.internal-es-plugin'
2-
apply plugin: 'elasticsearch.legacy-java-rest-test'
2+
apply plugin: 'elasticsearch.internal-java-rest-test'
33

44
esplugin {
55
name = 'x-pack-logstash'
@@ -17,10 +17,6 @@ dependencies {
1717
testImplementation(testArtifact(project(xpackModule('core'))))
1818
javaRestTestImplementation(project(path: xpackModule('core')))
1919
javaRestTestImplementation(testArtifact(project(xpackModule('core'))))
20-
}
2120

22-
testClusters.configureEach {
23-
testDistribution = 'DEFAULT'
24-
setting 'xpack.security.enabled', 'true'
25-
user username: 'x_pack_rest_user', password: 'x-pack-test-password'
21+
clusterModules project(':modules:analysis-common')
2622
}

x-pack/plugin/logstash/src/javaRestTest/java/org/elasticsearch/xpack/test/rest/LogstashSystemIndexIT.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
import org.elasticsearch.common.util.concurrent.ThreadContext;
1818
import org.elasticsearch.common.xcontent.XContentHelper;
1919
import org.elasticsearch.test.SecuritySettingsSourceField;
20+
import org.elasticsearch.test.cluster.ElasticsearchCluster;
2021
import org.elasticsearch.test.rest.ESRestTestCase;
2122
import org.elasticsearch.xcontent.XContentBuilder;
2223
import org.elasticsearch.xcontent.XContentType;
2324
import org.elasticsearch.xcontent.json.JsonXContent;
25+
import org.junit.ClassRule;
2426

2527
import java.io.IOException;
2628
import java.util.ArrayList;
@@ -31,6 +33,15 @@
3133
import static org.hamcrest.Matchers.is;
3234

3335
public class LogstashSystemIndexIT extends ESRestTestCase {
36+
37+
@ClassRule
38+
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
39+
.module("x-pack-logstash")
40+
.module("analysis-common")
41+
.setting("xpack.security.enabled", "true")
42+
.user("x_pack_rest_user", "x-pack-test-password")
43+
.build();
44+
3445
static final String BASIC_AUTH_VALUE = basicAuthHeaderValue(
3546
"x_pack_rest_user",
3647
SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING
@@ -41,6 +52,11 @@ protected Settings restClientSettings() {
4152
return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", BASIC_AUTH_VALUE).build();
4253
}
4354

55+
@Override
56+
protected String getTestRestCluster() {
57+
return cluster.getHttpAddresses();
58+
}
59+
4460
public void testPipelineCRUD() throws Exception {
4561
// put pipeline
4662
final String pipelineJson = getPipelineJson();

x-pack/plugin/slm/build.gradle

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ import org.elasticsearch.gradle.internal.info.BuildParams
22

33
apply plugin: 'elasticsearch.internal-es-plugin'
44
apply plugin: 'elasticsearch.internal-cluster-test'
5+
apply plugin: 'elasticsearch.internal-yaml-rest-test'
6+
apply plugin: 'elasticsearch.internal-java-rest-test'
57

68
esplugin {
79
name = 'x-pack-slm'
810
description = 'Elasticsearch Expanded Pack Plugin - Snapshot Lifecycle Management'
9-
classname ='org.elasticsearch.xpack.slm.SnapshotLifecycle'
11+
classname = 'org.elasticsearch.xpack.slm.SnapshotLifecycle'
1012
extendedPlugins = ['x-pack-core']
11-
hasNativeController =false
12-
requiresKeystore =true
13+
hasNativeController = false
14+
requiresKeystore = true
1315
}
16+
1417
base {
1518
archivesName = 'x-pack-slm'
1619
}
@@ -21,6 +24,20 @@ dependencies {
2124
testImplementation project(xpackModule('ccr'))
2225
testImplementation project(xpackModule('ilm'))
2326
testImplementation project(':modules:data-streams')
27+
javaRestTestImplementation(testArtifact(project(xpackModule('core'))))
28+
javaRestTestImplementation project(xpackModule('slm'))
29+
yamlRestTestImplementation(testArtifact(project(xpackModule('core'))))
30+
clusterModules project(xpackModule("ilm"))
31+
clusterModules project(xpackModule("searchable-snapshots"))
32+
clusterModules project(":modules:data-streams")
33+
}
34+
35+
restResources {
36+
restApi {
37+
include '_common', 'cluster', 'indices', 'index', 'snapshot', 'slm', 'health_report'
38+
}
2439
}
2540

26-
addQaCheckDependencies(project)
41+
tasks.named("javaRestTest") {
42+
usesDefaultDistribution("uses _xpack/usage api")
43+
}

x-pack/plugin/slm/qa/build.gradle

Whitespace-only changes.

x-pack/plugin/slm/qa/multi-node/build.gradle

Lines changed: 0 additions & 37 deletions
This file was deleted.

x-pack/plugin/slm/qa/rest/build.gradle

Lines changed: 0 additions & 20 deletions
This file was deleted.

x-pack/plugin/slm/qa/with-security/build.gradle

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
import org.elasticsearch.common.compress.CompressedXContent;
2323
import org.elasticsearch.common.settings.Settings;
2424
import org.elasticsearch.common.xcontent.XContentHelper;
25+
import org.elasticsearch.core.SuppressForbidden;
2526
import org.elasticsearch.core.TimeValue;
27+
import org.elasticsearch.test.cluster.ElasticsearchCluster;
28+
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
2629
import org.elasticsearch.test.junit.annotations.TestIssueLogging;
2730
import org.elasticsearch.test.rest.ESRestTestCase;
2831
import org.elasticsearch.xcontent.ToXContent;
@@ -35,6 +38,9 @@
3538
import org.elasticsearch.xpack.core.slm.SnapshotLifecyclePolicy;
3639
import org.elasticsearch.xpack.core.slm.SnapshotLifecycleStats;
3740
import org.elasticsearch.xpack.core.slm.SnapshotRetentionConfiguration;
41+
import org.junit.ClassRule;
42+
import org.junit.rules.RuleChain;
43+
import org.junit.rules.TemporaryFolder;
3844

3945
import java.io.IOException;
4046
import java.io.InputStream;
@@ -62,16 +68,43 @@
6268
import static org.hamcrest.Matchers.not;
6369
import static org.hamcrest.Matchers.startsWith;
6470

71+
@SuppressForbidden(reason = "TemporaryFolder uses java.io.File")
6572
public class SnapshotLifecycleRestIT extends ESRestTestCase {
6673
private static final String NEVER_EXECUTE_CRON_SCHEDULE = "* * * 31 FEB ? *";
6774

75+
public static TemporaryFolder repoDir = new TemporaryFolder();
76+
77+
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
78+
// TODO: Revert to integ-test distro once we sort out issues with usage and info xpack apis
79+
.distribution(DistributionType.DEFAULT)
80+
.nodes(2)
81+
.module("x-pack-slm")
82+
.module("x-pack-ilm")
83+
.module("searchable-snapshots")
84+
.module("data-streams")
85+
.setting("path.repo", () -> repoDir.getRoot().getAbsolutePath())
86+
.setting("xpack.security.enabled", "false")
87+
.setting("xpack.license.self_generated.type", "trial")
88+
.setting("xpack.searchable.snapshot.shared_cache.size", "16MB")
89+
.setting("xpack.searchable.snapshot.shared_cache.region_size", "256KB")
90+
.setting("indices.lifecycle.poll_interval", "1000ms")
91+
.build();
92+
93+
@ClassRule
94+
public static RuleChain rules = RuleChain.outerRule(repoDir).around(cluster);
95+
6896
// as we are testing the SLM history entries we'll preserve the "slm-history-ilm-policy" policy as it'll be associated with the
6997
// .slm-history-* indices and we won't be able to delete it when we wipe out the cluster
7098
@Override
7199
protected boolean preserveILMPoliciesUponCompletion() {
72100
return true;
73101
}
74102

103+
@Override
104+
protected String getTestRestCluster() {
105+
return cluster.getHttpAddresses();
106+
}
107+
75108
public void testMissingRepo() throws Exception {
76109
SnapshotLifecyclePolicy policy = new SnapshotLifecyclePolicy(
77110
"missing-repo-policy",
@@ -919,7 +952,7 @@ private void initializeRepo(String repoName, String maxBytesPerSecond) throws IO
919952
.field("type", "fs")
920953
.startObject("settings")
921954
.field("compress", randomBoolean())
922-
.field("location", System.getProperty("tests.path.repo"))
955+
.field("location", repoDir.getRoot().getAbsolutePath())
923956
.field("max_snapshot_bytes_per_sec", maxBytesPerSecond)
924957
.endObject()
925958
.endObject()

0 commit comments

Comments
 (0)