Skip to content

Commit 0c50403

Browse files
authored
Migrate x-pack core module to new testing framework (#125740)
1 parent 4fa4106 commit 0c50403

File tree

6 files changed

+82
-14
lines changed

6 files changed

+82
-14
lines changed

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

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
3636
map.put(LegacyRestTestBasePlugin.class, ":qa:remote-clusters");
3737
map.put(LegacyRestTestBasePlugin.class, ":qa:repository-multi-version");
3838
map.put(LegacyRestTestBasePlugin.class, ":qa:rolling-upgrade-legacy");
39-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:core");
4039
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ent-search");
4140
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:fleet");
4241
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:logstash");

x-pack/plugin/core/build.gradle

+5-13
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import java.nio.file.Paths
1212
apply plugin: 'elasticsearch.internal-es-plugin'
1313
apply plugin: 'elasticsearch.publish'
1414
apply plugin: 'elasticsearch.internal-cluster-test'
15-
apply plugin: 'elasticsearch.legacy-yaml-rest-test'
16-
apply plugin: 'elasticsearch.legacy-java-rest-test'
17-
apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test'
15+
apply plugin: 'elasticsearch.internal-yaml-rest-test'
16+
apply plugin: 'elasticsearch.internal-java-rest-test'
17+
apply plugin: 'elasticsearch.yaml-rest-compat-test'
1818
apply plugin: 'elasticsearch.internal-test-artifact'
1919

2020
base {
@@ -149,16 +149,8 @@ restResources {
149149
}
150150
}
151151

152-
testClusters.configureEach {
153-
testDistribution = 'default'
154-
setting 'xpack.security.enabled', 'true'
155-
setting 'xpack.license.self_generated.type', 'trial'
156-
//disabling ILM history as it disturbs testDSXpackUsage test
157-
setting 'indices.lifecycle.history_index_enabled', 'false'
158-
keystore 'bootstrap.password', 'x-pack-test-password'
159-
user username: "x_pack_rest_user", password: "x-pack-test-password"
160-
requiresFeature 'es.failure_store_feature_flag_enabled', Version.fromString("8.15.0")
161-
systemProperty 'es.queryable_built_in_roles_enabled', 'false'
152+
tasks.named("javaRestTest") {
153+
usesDefaultDistribution("uses the _xpack api")
162154
}
163155

164156
if (buildParams.snapshotBuild == false) {

x-pack/plugin/core/src/javaRestTest/java/org/elasticsearch/xpack/core/DataStreamRestIT.java

+21
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313
import org.elasticsearch.common.settings.SecureString;
1414
import org.elasticsearch.common.settings.Settings;
1515
import org.elasticsearch.common.util.concurrent.ThreadContext;
16+
import org.elasticsearch.test.cluster.ElasticsearchCluster;
17+
import org.elasticsearch.test.cluster.FeatureFlag;
18+
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
1619
import org.elasticsearch.test.rest.ESRestTestCase;
1720
import org.elasticsearch.xcontent.XContentParser;
1821
import org.elasticsearch.xcontent.XContentParserConfiguration;
1922
import org.elasticsearch.xcontent.json.JsonXContent;
23+
import org.junit.ClassRule;
2024

2125
import java.util.List;
2226
import java.util.Map;
@@ -27,6 +31,18 @@
2731

2832
public class DataStreamRestIT extends ESRestTestCase {
2933

34+
@ClassRule
35+
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
36+
.distribution(DistributionType.DEFAULT)
37+
.setting("xpack.security.enabled", "true")
38+
.setting("xpack.license.self_generated.type", "trial")
39+
.setting("indices.lifecycle.history_index_enabled", "false")
40+
.feature(FeatureFlag.FAILURE_STORE_ENABLED)
41+
.keystore("bootstrap.password", "x-pack-test-password")
42+
.user("x_pack_rest_user", "x-pack-test-password")
43+
.systemProperty("es.queryable_built_in_roles_enabled", "false")
44+
.build();
45+
3046
private static final String BASIC_AUTH_VALUE = basicAuthHeaderValue("x_pack_rest_user", new SecureString("x-pack-test-password"));
3147

3248
@Override
@@ -143,4 +159,9 @@ private void putFailureStoreTemplate() {
143159
throw new RuntimeException(e);
144160
}
145161
}
162+
163+
@Override
164+
protected String getTestRestCluster() {
165+
return cluster.getHttpAddresses();
166+
}
146167
}

x-pack/plugin/core/src/javaRestTest/java/org/elasticsearch/xpack/core/LicenseInstallationIT.java

+18
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@
1818
import org.elasticsearch.license.License;
1919
import org.elasticsearch.license.LicenseSettings;
2020
import org.elasticsearch.license.TestUtils;
21+
import org.elasticsearch.test.cluster.ElasticsearchCluster;
22+
import org.elasticsearch.test.cluster.FeatureFlag;
2123
import org.elasticsearch.test.rest.ESRestTestCase;
2224
import org.elasticsearch.xcontent.ToXContent;
2325
import org.elasticsearch.xcontent.XContentBuilder;
2426
import org.elasticsearch.xcontent.json.JsonXContent;
2527
import org.junit.Before;
28+
import org.junit.ClassRule;
2629

2730
import java.io.IOException;
2831
import java.util.Locale;
@@ -39,6 +42,16 @@
3942
*/
4043
public class LicenseInstallationIT extends ESRestTestCase {
4144

45+
@ClassRule
46+
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
47+
.setting("xpack.security.enabled", "true")
48+
.setting("xpack.license.self_generated.type", "trial")
49+
.feature(FeatureFlag.FAILURE_STORE_ENABLED)
50+
.keystore("bootstrap.password", "x-pack-test-password")
51+
.user("x_pack_rest_user", "x-pack-test-password")
52+
.systemProperty("es.queryable_built_in_roles_enabled", "false")
53+
.build();
54+
4255
@Override
4356
protected Settings restClientSettings() {
4457
String token = basicAuthHeaderValue("x_pack_rest_user", new SecureString("x-pack-test-password".toCharArray()));
@@ -159,4 +172,9 @@ private void assertClusterUsingTrialLicense() throws Exception {
159172
assertThat("the cluster should be using a trial license", innerMap.get("type"), equalTo("trial"));
160173
});
161174
}
175+
176+
@Override
177+
protected String getTestRestCluster() {
178+
return cluster.getHttpAddresses();
179+
}
162180
}

x-pack/plugin/core/src/javaRestTest/java/org/elasticsearch/xpack/core/StackTemplatesRestIT.java

+20
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,27 @@
1212
import org.elasticsearch.common.settings.SecureString;
1313
import org.elasticsearch.common.settings.Settings;
1414
import org.elasticsearch.common.util.concurrent.ThreadContext;
15+
import org.elasticsearch.test.cluster.ElasticsearchCluster;
16+
import org.elasticsearch.test.cluster.FeatureFlag;
17+
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
1518
import org.elasticsearch.test.rest.ESRestTestCase;
19+
import org.junit.ClassRule;
1620

1721
import static org.hamcrest.Matchers.is;
1822

1923
public class StackTemplatesRestIT extends ESRestTestCase {
2024

25+
@ClassRule
26+
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
27+
.distribution(DistributionType.DEFAULT)
28+
.setting("xpack.security.enabled", "true")
29+
.setting("xpack.license.self_generated.type", "trial")
30+
.feature(FeatureFlag.FAILURE_STORE_ENABLED)
31+
.keystore("bootstrap.password", "x-pack-test-password")
32+
.user("x_pack_rest_user", "x-pack-test-password")
33+
.systemProperty("es.queryable_built_in_roles_enabled", "false")
34+
.build();
35+
2136
private static final String BASIC_AUTH_VALUE = basicAuthHeaderValue("x_pack_rest_user", new SecureString("x-pack-test-password"));
2237

2338
@Override
@@ -56,4 +71,9 @@ public void testTemplatesCanBeDisabled() throws Exception {
5671
ResponseException exception = expectThrows(ResponseException.class, () -> client.performRequest(deleteRequest));
5772
assertThat(exception.getResponse().getStatusLine().getStatusCode(), is(404));
5873
}
74+
75+
@Override
76+
protected String getTestRestCluster() {
77+
return cluster.getHttpAddresses();
78+
}
5979
}

x-pack/plugin/core/src/yamlRestTest/java/org/elasticsearch/license/XPackCoreClientYamlTestSuiteIT.java

+18
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,24 @@
1313
import org.elasticsearch.common.settings.SecureString;
1414
import org.elasticsearch.common.settings.Settings;
1515
import org.elasticsearch.common.util.concurrent.ThreadContext;
16+
import org.elasticsearch.test.cluster.ElasticsearchCluster;
17+
import org.elasticsearch.test.cluster.FeatureFlag;
1618
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
1719
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
20+
import org.junit.ClassRule;
1821

1922
public class XPackCoreClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
2023

24+
@ClassRule
25+
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
26+
.setting("xpack.security.enabled", "true")
27+
.setting("xpack.license.self_generated.type", "trial")
28+
.feature(FeatureFlag.FAILURE_STORE_ENABLED)
29+
.keystore("bootstrap.password", "x-pack-test-password")
30+
.user("x_pack_rest_user", "x-pack-test-password")
31+
.systemProperty("es.queryable_built_in_roles_enabled", "false")
32+
.build();
33+
2134
private static final String BASIC_AUTH_VALUE = basicAuthHeaderValue("x_pack_rest_user", new SecureString("x-pack-test-password"));
2235

2336
public XPackCoreClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
@@ -33,4 +46,9 @@ public static Iterable<Object[]> parameters() throws Exception {
3346
protected Settings restClientSettings() {
3447
return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", BASIC_AUTH_VALUE).build();
3548
}
49+
50+
@Override
51+
protected String getTestRestCluster() {
52+
return cluster.getHttpAddresses();
53+
}
3654
}

0 commit comments

Comments
 (0)