Skip to content

Commit 5f5b4f8

Browse files
committed
Convert more x-pack modules to new test framework
1 parent 3ac0c13 commit 5f5b4f8

File tree

23 files changed

+186
-188
lines changed

23 files changed

+186
-188
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
@@ -38,8 +38,6 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
3838
map.put(LegacyRestTestBasePlugin.class, ":qa:rolling-upgrade-legacy");
3939
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ent-search");
4040
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:fleet");
41-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:logstash");
42-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:vector-tile");
4341
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:mixed-tier-cluster");
4442
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:repository-old-versions");
4543
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:rolling-upgrade");
@@ -94,8 +92,6 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
9492
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:security:qa:tls-basic");
9593
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:shutdown:qa:multi-node");
9694
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:shutdown:qa:rolling-upgrade");
97-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:slm:qa:multi-node");
98-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:slm:qa:rest");
9995
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:snapshot-based-recoveries:qa:fs");
10096
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:snapshot-based-recoveries:qa:license-enforcing");
10197
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:snapshot-repo-test-kit:qa:hdfs");
@@ -108,12 +104,10 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
108104
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:sql:qa:mixed-node");
109105
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:sql:qa:server:security:with-ssl");
110106
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:sql:qa:server:security:without-ssl");
111-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:stack:qa:rest");
112107
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:text-structure:qa:text-structure-with-security");
113108
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:transform:qa:multi-cluster-tests-with-security");
114109
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:transform:qa:multi-node-tests");
115110
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:transform:qa:single-node-tests");
116-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:vector-tile:qa:multi-cluster");
117111
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:watcher:qa:rest");
118112
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:watcher:qa:with-security");
119113
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
@@ -7,15 +7,18 @@
77

88
apply plugin: 'elasticsearch.internal-es-plugin'
99
apply plugin: 'elasticsearch.internal-cluster-test'
10+
apply plugin: 'elasticsearch.internal-yaml-rest-test'
11+
apply plugin: 'elasticsearch.internal-java-rest-test'
1012

1113
esplugin {
1214
name = 'x-pack-slm'
1315
description = 'Elasticsearch Expanded Pack Plugin - Snapshot Lifecycle Management'
14-
classname ='org.elasticsearch.xpack.slm.SnapshotLifecycle'
16+
classname = 'org.elasticsearch.xpack.slm.SnapshotLifecycle'
1517
extendedPlugins = ['x-pack-core']
16-
hasNativeController =false
17-
requiresKeystore =true
18+
hasNativeController = false
19+
requiresKeystore = true
1820
}
21+
1922
base {
2023
archivesName = 'x-pack-slm'
2124
}
@@ -26,6 +29,20 @@ dependencies {
2629
testImplementation project(xpackModule('ccr'))
2730
testImplementation project(xpackModule('ilm'))
2831
testImplementation project(':modules:data-streams')
32+
javaRestTestImplementation(testArtifact(project(xpackModule('core'))))
33+
javaRestTestImplementation project(xpackModule('slm'))
34+
yamlRestTestImplementation(testArtifact(project(xpackModule('core'))))
35+
clusterModules project(xpackModule("ilm"))
36+
clusterModules project(xpackModule("searchable-snapshots"))
37+
clusterModules project(":modules:data-streams")
38+
}
39+
40+
restResources {
41+
restApi {
42+
include '_common', 'cluster', 'indices', 'index', 'snapshot', 'slm', 'health_report'
43+
}
2944
}
3045

31-
addQaCheckDependencies(project)
46+
tasks.named("javaRestTest") {
47+
usesDefaultDistribution("uses _xpack/usage api")
48+
}

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

Whitespace-only changes.

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

Lines changed: 0 additions & 43 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.

x-pack/plugin/slm/qa/with-security/src/javaRestTest/java/org/elasticsearch/xpack/security/PermissionsIT.java renamed to x-pack/plugin/slm/src/javaRestTest/java/org/elasticsearch/xpack/security/PermissionsIT.java

File renamed without changes.

x-pack/plugin/slm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/slm/SnapshotLifecycleRestIT.java renamed to x-pack/plugin/slm/src/javaRestTest/java/org/elasticsearch/xpack/slm/SnapshotLifecycleRestIT.java

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import org.elasticsearch.common.settings.Settings;
2424
import org.elasticsearch.common.xcontent.XContentHelper;
2525
import org.elasticsearch.core.TimeValue;
26+
import org.elasticsearch.test.cluster.ElasticsearchCluster;
27+
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
2628
import org.elasticsearch.test.junit.annotations.TestIssueLogging;
2729
import org.elasticsearch.test.rest.ESRestTestCase;
2830
import org.elasticsearch.xcontent.ToXContent;
@@ -35,6 +37,9 @@
3537
import org.elasticsearch.xpack.core.slm.SnapshotLifecyclePolicy;
3638
import org.elasticsearch.xpack.core.slm.SnapshotLifecycleStats;
3739
import org.elasticsearch.xpack.core.slm.SnapshotRetentionConfiguration;
40+
import org.junit.ClassRule;
41+
import org.junit.rules.RuleChain;
42+
import org.junit.rules.TemporaryFolder;
3843

3944
import java.io.IOException;
4045
import java.io.InputStream;
@@ -65,13 +70,39 @@
6570
public class SnapshotLifecycleRestIT extends ESRestTestCase {
6671
private static final String NEVER_EXECUTE_CRON_SCHEDULE = "* * * 31 FEB ? *";
6772

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

101+
@Override
102+
protected String getTestRestCluster() {
103+
return cluster.getHttpAddresses();
104+
}
105+
75106
public void testMissingRepo() throws Exception {
76107
SnapshotLifecyclePolicy policy = new SnapshotLifecyclePolicy(
77108
"missing-repo-policy",
@@ -919,7 +950,7 @@ private void initializeRepo(String repoName, String maxBytesPerSecond) throws IO
919950
.field("type", "fs")
920951
.startObject("settings")
921952
.field("compress", randomBoolean())
922-
.field("location", System.getProperty("tests.path.repo"))
953+
.field("location", repoDir.getRoot().getAbsolutePath())
923954
.field("max_snapshot_bytes_per_sec", maxBytesPerSecond)
924955
.endObject()
925956
.endObject()

0 commit comments

Comments
 (0)