Skip to content

Commit 7158b16

Browse files
committed
Convert enterprise search module to new testing framework (#125807)
1 parent a3314ad commit 7158b16

File tree

61 files changed

+73
-56
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

+73
-56
lines changed

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

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
apply plugin: 'elasticsearch.internal-es-plugin'
22
apply plugin: 'elasticsearch.internal-cluster-test'
3-
apply plugin: 'elasticsearch.legacy-java-rest-test'
3+
apply plugin: 'elasticsearch.internal-java-rest-test'
4+
apply plugin: 'elasticsearch.internal-yaml-rest-test'
5+
apply plugin: 'elasticsearch.yaml-rest-compat-test'
46

57
esplugin {
68
name = 'x-pack-ent-search'
@@ -35,25 +37,50 @@ dependencies {
3537
javaRestTestImplementation(project(path: xpackModule('core')))
3638
javaRestTestImplementation(testArtifact(project(xpackModule('core'))))
3739
javaRestTestImplementation(project(':modules:lang-mustache'))
40+
41+
yamlRestTestImplementation(testArtifact(project(xpackModule('core'))))
3842
}
3943

40-
testClusters.configureEach {
41-
testDistribution = 'DEFAULT'
42-
setting 'xpack.security.enabled', 'true'
43-
setting 'xpack.security.autoconfiguration.enabled', 'false'
44-
user username: 'x_pack_rest_user', password: 'x-pack-test-password'
44+
restResources {
45+
restApi {
46+
include '_common',
47+
'bulk',
48+
'cluster',
49+
'connector',
50+
'nodes',
51+
'indices',
52+
'index',
53+
'query_rules',
54+
'search_application',
55+
'xpack',
56+
'security',
57+
'search',
58+
'ml'
59+
}
4560
}
4661

47-
tasks.named("dependencyLicenses").configure {
62+
tasks.named("dependencyLicenses") {
4863
mapping from: /jackson.*/, to: 'jackson'
4964
}
5065

51-
tasks.named("thirdPartyAudit").configure {
66+
tasks.named("thirdPartyAudit") {
5267
ignoreMissingClasses(
5368
// [missing classes] SLF4j includes an optional class that depends on an extension class (!)
5469
'org.slf4j.ext.EventData'
5570
)
5671
}
5772

73+
tasks.named("yamlRestTest") {
74+
usesDefaultDistribution("uses the xpack/usage api")
75+
}
76+
77+
tasks.named("yamlRestCompatTestTransform") { task ->
78+
// Behavioral Analytics is deprecated with 9.0.0.
79+
task.addAllowedWarning("Behavioral Analytics is deprecated and will be removed in a future release.")
80+
}
81+
5882
addQaCheckDependencies(project)
5983

84+
artifacts {
85+
restXpackTests(new File(projectDir, "src/yamlRestTest/resources/rest-api-spec/test"))
86+
}

x-pack/plugin/ent-search/qa/rest/build.gradle

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

x-pack/plugin/ent-search/src/javaRestTest/java/org/elasticsearch/xpack/entsearch/ConnectorSecretsSystemIndexIT.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
import org.elasticsearch.common.util.concurrent.ThreadContext;
1717
import org.elasticsearch.common.xcontent.XContentHelper;
1818
import org.elasticsearch.test.SecuritySettingsSourceField;
19+
import org.elasticsearch.test.cluster.ElasticsearchCluster;
1920
import org.elasticsearch.test.rest.ESRestTestCase;
2021
import org.elasticsearch.xcontent.XContentBuilder;
2122
import org.elasticsearch.xcontent.XContentType;
2223
import org.elasticsearch.xcontent.json.JsonXContent;
24+
import org.junit.ClassRule;
2325

2426
import java.io.IOException;
2527
import java.util.Map;
@@ -28,6 +30,14 @@
2830

2931
public class ConnectorSecretsSystemIndexIT extends ESRestTestCase {
3032

33+
@ClassRule
34+
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
35+
.module("x-pack-ent-search")
36+
.setting("xpack.security.enabled", "true")
37+
.setting("xpack.security.autoconfiguration.enabled", "false")
38+
.user("x_pack_rest_user", "x-pack-test-password")
39+
.build();
40+
3141
static final String BASIC_AUTH_VALUE = basicAuthHeaderValue(
3242
"x_pack_rest_user",
3343
SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING
@@ -91,4 +101,9 @@ private String getPostSecretJson() throws IOException {
91101
private Map<String, Object> getResponseMap(Response response) throws IOException {
92102
return XContentHelper.convertToMap(XContentType.JSON.xContent(), EntityUtils.toString(response.getEntity()), false);
93103
}
104+
105+
@Override
106+
protected String getTestRestCluster() {
107+
return cluster.getHttpAddresses();
108+
}
94109
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,28 @@
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.local.distribution.DistributionType;
17+
import org.elasticsearch.test.cluster.util.resource.Resource;
1518
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
1619
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
20+
import org.junit.ClassRule;
1721

1822
public class EnterpriseSearchRestIT extends ESClientYamlSuiteTestCase {
1923

24+
@ClassRule
25+
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
26+
.distribution(DistributionType.DEFAULT)
27+
.setting("xpack.security.enabled", "true")
28+
.setting("xpack.security.autoconfiguration.enabled", "false")
29+
.setting("xpack.license.self_generated.type", "trial")
30+
.rolesFile(Resource.fromClasspath("roles.yml"))
31+
.user("entsearch-superuser", "entsearch-superuser-password", "superuser", false)
32+
.user("entsearch-admin", "entsearch-admin-password", "admin", false)
33+
.user("entsearch-user", "entsearch-user-password", "user", false)
34+
.user("entsearch-unprivileged", "entsearch-unprivileged-password", "unprivileged", false)
35+
.build();
36+
2037
public EnterpriseSearchRestIT(final ClientYamlTestCandidate testCandidate) {
2138
super(testCandidate);
2239
}
@@ -37,4 +54,9 @@ protected Settings restClientSettings() {
3754
final String value = basicAuthHeaderValue("entsearch-admin", new SecureString("entsearch-admin-password".toCharArray()));
3855
return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", value).build();
3956
}
57+
58+
@Override
59+
protected String getTestRestCluster() {
60+
return cluster.getHttpAddresses();
61+
}
4062
}

0 commit comments

Comments
 (0)