Skip to content

Commit e5f9637

Browse files
authored
Migrate third party module tests using legacy test clusters framework (#140991)
1 parent c51be0a commit e5f9637

9 files changed

Lines changed: 166 additions & 209 deletions

File tree

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
5050
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:smoke-test-plugins-ssl");
5151
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:smoke-test-security-with-mustache");
5252
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:xpack-prefix-rest-compat");
53-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:third-party:jira");
54-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:third-party:pagerduty");
55-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:third-party:slack");
5653
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ent-search:qa:rest");
5754
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:eql:qa:ccs-rolling-upgrade");
5855
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:eql:qa:correctness");

x-pack/qa/third-party/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apply plugin: 'elasticsearch.java'
2+
3+
dependencies {
4+
api project(':test:framework')
5+
api project(':test:yaml-rest-runner')
6+
api project(':test:test-clusters')
7+
api project(xpackModule('core'))
8+
}

x-pack/qa/third-party/jira/build.gradle

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ import groovy.json.JsonSlurper
1010
import javax.net.ssl.HttpsURLConnection
1111
import java.nio.charset.StandardCharsets
1212

13-
apply plugin: 'elasticsearch.legacy-yaml-rest-test'
13+
apply plugin: 'elasticsearch.internal-yaml-rest-test'
1414

1515
dependencies {
16-
yamlRestTestImplementation project(':x-pack:plugin:core')
17-
yamlRestTestImplementation project(path: xpackModule('watcher'))
16+
yamlRestTestImplementation project(':x-pack:qa:third-party')
17+
18+
clusterModules project(xpackModule('watcher'))
19+
clusterModules project(xpackModule('ilm'))
1820
}
1921

2022
restResources {
2123
restApi {
22-
include 'watcher'
24+
include '_common', 'cluster', 'indices', 'search', 'watcher'
2325
}
2426
}
2527

@@ -44,20 +46,7 @@ tasks.register("cleanJira", DefaultTask) {
4446
if (!jiraUrl && !jiraUser && !jiraPassword && !jiraProject) {
4547
tasks.named("yamlRestTest").configure { enabled = false }
4648
} else {
47-
testClusters.matching { it.name == "yamlRestTest" }.configureEach {
48-
testDistribution = 'DEFAULT'
49-
setting 'xpack.security.enabled', 'false'
50-
setting 'xpack.ml.enabled', 'false'
51-
setting 'xpack.license.self_generated.type', 'trial'
52-
setting 'logger.org.elasticsearch.xpack.watcher', 'DEBUG'
53-
setting 'xpack.notification.jira.account.test.issue_defaults.issuetype.name', 'Bug'
54-
setting 'xpack.notification.jira.account.test.issue_defaults.labels.0', 'integration-tests'
55-
setting 'xpack.notification.jira.account.test.issue_defaults.project.key', jiraProject
56-
keystore 'xpack.notification.jira.account.test.secure_url', jiraUrl
57-
keystore 'xpack.notification.jira.account.test.secure_user', jiraUser
58-
keystore 'xpack.notification.jira.account.test.secure_password', jiraPassword
59-
}
60-
tasks.named("yamlRestTest")configure { finalizedBy "cleanJira" }
49+
tasks.named("yamlRestTest").configure { finalizedBy "cleanJira" }
6150
}
6251

6352
if (buildParams.inFipsJvm){

x-pack/qa/third-party/jira/src/yamlRestTest/java/org/elasticsearch/smoketest/WatcherJiraYamlTestSuiteIT.java

Lines changed: 21 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -9,69 +9,36 @@
99
import com.carrotsearch.randomizedtesting.annotations.Name;
1010
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
1111

12+
import org.elasticsearch.test.cluster.ElasticsearchCluster;
1213
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
13-
import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse;
14-
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
15-
import org.elasticsearch.xpack.core.watcher.support.WatcherIndexTemplateRegistryField;
16-
import org.junit.After;
17-
import org.junit.Before;
18-
19-
import java.io.IOException;
20-
import java.util.List;
21-
import java.util.Map;
22-
import java.util.concurrent.TimeUnit;
23-
24-
import static org.hamcrest.Matchers.is;
14+
import org.junit.ClassRule;
2515

2616
/** Runs rest tests against external cluster */
27-
public class WatcherJiraYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
17+
public class WatcherJiraYamlTestSuiteIT extends AbstractWatcherThirdPartyYamlTestSuiteIT {
18+
19+
@ClassRule
20+
public static ElasticsearchCluster cluster = baseClusterBuilder().setting(
21+
"xpack.notification.jira.account.test.issue_defaults.issuetype.name",
22+
"Bug"
23+
)
24+
.setting("xpack.notification.jira.account.test.issue_defaults.labels.0", "integration-tests")
25+
.setting("xpack.notification.jira.account.test.issue_defaults.project.key", System.getenv("jira_project"))
26+
.keystore("xpack.notification.jira.account.test.secure_url", System.getenv("jira_url"))
27+
.keystore("xpack.notification.jira.account.test.secure_user", System.getenv("jira_user"))
28+
.keystore("xpack.notification.jira.account.test.secure_password", System.getenv("jira_password"))
29+
.build();
30+
31+
@Override
32+
protected ElasticsearchCluster getCluster() {
33+
return cluster;
34+
}
2835

2936
public WatcherJiraYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
3037
super(testCandidate);
3138
}
3239

3340
@ParametersFactory
3441
public static Iterable<Object[]> parameters() throws Exception {
35-
return ESClientYamlSuiteTestCase.createParameters();
36-
}
37-
38-
@Before
39-
public void startWatcher() throws Exception {
40-
final List<String> watcherTemplates = List.of(WatcherIndexTemplateRegistryField.TEMPLATE_NAMES_NO_ILM);
41-
assertBusy(() -> {
42-
try {
43-
getAdminExecutionContext().callApi("watcher.start", Map.of(), List.of(), Map.of());
44-
45-
for (String template : watcherTemplates) {
46-
ClientYamlTestResponse templateExistsResponse = getAdminExecutionContext().callApi(
47-
"indices.exists_template",
48-
Map.of("name", template),
49-
List.of(),
50-
Map.of()
51-
);
52-
assertThat(templateExistsResponse.getStatusCode(), is(200));
53-
}
54-
55-
ClientYamlTestResponse response = getAdminExecutionContext().callApi("watcher.stats", Map.of(), List.of(), Map.of());
56-
String state = response.evaluate("stats.0.watcher_state");
57-
assertThat(state, is("started"));
58-
} catch (IOException e) {
59-
throw new AssertionError(e);
60-
}
61-
});
62-
}
63-
64-
@After
65-
public void stopWatcher() throws Exception {
66-
assertBusy(() -> {
67-
try {
68-
getAdminExecutionContext().callApi("watcher.stop", Map.of(), List.of(), Map.of());
69-
ClientYamlTestResponse response = getAdminExecutionContext().callApi("watcher.stats", Map.of(), List.of(), Map.of());
70-
String state = response.evaluate("stats.0.watcher_state");
71-
assertThat(state, is("stopped"));
72-
} catch (IOException e) {
73-
throw new AssertionError(e);
74-
}
75-
}, 60, TimeUnit.SECONDS);
42+
return createParameters();
7643
}
7744
}

x-pack/qa/third-party/pagerduty/build.gradle

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,25 @@
55
* 2.0.
66
*/
77

8-
apply plugin: 'elasticsearch.legacy-yaml-rest-test'
8+
apply plugin: 'elasticsearch.internal-yaml-rest-test'
99

1010
dependencies {
11-
yamlRestTestImplementation project(':x-pack:plugin:core')
12-
yamlRestTestImplementation project(path: xpackModule('watcher'))
13-
}
11+
yamlRestTestImplementation project(':x-pack:qa:third-party')
1412

15-
String pagerDutyServiceKey = System.getenv('pagerduty_service_api_key')
13+
clusterModules project(xpackModule('watcher'))
14+
clusterModules project(xpackModule('ilm'))
15+
}
1616

1717
restResources {
1818
restApi {
19-
include 'watcher'
19+
include '_common', 'watcher', 'indices', 'cluster', 'search'
2020
}
2121
}
2222

23+
String pagerDutyServiceKey = System.getenv('pagerduty_service_api_key')
24+
2325
if (!pagerDutyServiceKey) {
2426
tasks.named("yamlRestTest").configure { enabled = false }
25-
} else {
26-
testClusters.matching { it.name == "yamlRestTest" }.configureEach {
27-
testDistribution = 'DEFAULT'
28-
setting 'xpack.security.enabled', 'false'
29-
setting 'xpack.ml.enabled', 'false'
30-
setting 'xpack.license.self_generated.type', 'trial'
31-
setting 'logger.org.elasticsearch.xpack.watcher', 'DEBUG'
32-
keystore 'xpack.notification.pagerduty.account.test_account.secure_service_api_key', pagerDutyServiceKey
33-
}
3427
}
3528

3629
if (buildParams.inFipsJvm){

x-pack/qa/third-party/pagerduty/src/yamlRestTest/java/org/elasticsearch/smoketest/WatcherPagerDutyYamlTestSuiteIT.java

Lines changed: 13 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -9,69 +9,29 @@
99
import com.carrotsearch.randomizedtesting.annotations.Name;
1010
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
1111

12+
import org.elasticsearch.test.cluster.ElasticsearchCluster;
1213
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
13-
import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse;
14-
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
15-
import org.elasticsearch.xpack.core.watcher.support.WatcherIndexTemplateRegistryField;
16-
import org.junit.After;
17-
import org.junit.Before;
14+
import org.junit.ClassRule;
1815

19-
import java.io.IOException;
20-
import java.util.List;
21-
import java.util.Map;
22-
import java.util.concurrent.TimeUnit;
16+
public class WatcherPagerDutyYamlTestSuiteIT extends AbstractWatcherThirdPartyYamlTestSuiteIT {
2317

24-
import static org.hamcrest.Matchers.is;
18+
@ClassRule
19+
public static ElasticsearchCluster cluster = baseClusterBuilder().keystore(
20+
"xpack.notification.pagerduty.account.test_account.secure_service_api_key",
21+
System.getenv("pagerduty_service_api_key")
22+
).build();
2523

26-
/** Runs rest tests against external cluster */
27-
public class WatcherPagerDutyYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
24+
@Override
25+
protected ElasticsearchCluster getCluster() {
26+
return cluster;
27+
}
2828

2929
public WatcherPagerDutyYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
3030
super(testCandidate);
3131
}
3232

3333
@ParametersFactory
3434
public static Iterable<Object[]> parameters() throws Exception {
35-
return ESClientYamlSuiteTestCase.createParameters();
36-
}
37-
38-
@Before
39-
public void startWatcher() throws Exception {
40-
final List<String> watcherTemplates = List.of(WatcherIndexTemplateRegistryField.TEMPLATE_NAMES_NO_ILM);
41-
assertBusy(() -> {
42-
try {
43-
getAdminExecutionContext().callApi("watcher.start", Map.of(), List.of(), Map.of());
44-
45-
for (String template : watcherTemplates) {
46-
ClientYamlTestResponse templateExistsResponse = getAdminExecutionContext().callApi(
47-
"indices.exists_template",
48-
Map.of("name", template),
49-
List.of(),
50-
Map.of()
51-
);
52-
assertThat(templateExistsResponse.getStatusCode(), is(200));
53-
}
54-
55-
ClientYamlTestResponse response = getAdminExecutionContext().callApi("watcher.stats", Map.of(), List.of(), Map.of());
56-
String state = response.evaluate("stats.0.watcher_state");
57-
assertThat(state, is("started"));
58-
} catch (IOException e) {
59-
throw new AssertionError(e);
60-
}
61-
});
62-
}
63-
64-
@After
65-
public void stopWatcher() throws Exception {
66-
assertBusy(() -> {
67-
try {
68-
getAdminExecutionContext().callApi("watcher.stop", Map.of(), List.of(), Map.of());
69-
ClientYamlTestResponse response = getAdminExecutionContext().callApi("watcher.stats", Map.of(), List.of(), Map.of());
70-
String state = response.evaluate("stats.0.watcher_state");
71-
assertThat(state, is("stopped"));
72-
} catch (IOException e) {
73-
throw new AssertionError(e);
74-
}
75-
}, 60, TimeUnit.SECONDS);
35+
return createParameters();
7636
}
7737
}

x-pack/qa/third-party/slack/build.gradle

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,25 @@
55
* 2.0.
66
*/
77

8-
apply plugin: 'elasticsearch.legacy-yaml-rest-test'
8+
apply plugin: 'elasticsearch.internal-yaml-rest-test'
99

1010
dependencies {
11-
yamlRestTestImplementation project(':x-pack:plugin:core')
12-
yamlRestTestImplementation project(path: xpackModule('watcher'))
11+
yamlRestTestImplementation project(':x-pack:qa:third-party')
12+
13+
clusterModules project(xpackModule('watcher'))
14+
clusterModules project(xpackModule('ilm'))
1315
}
1416

1517
restResources {
1618
restApi {
17-
include 'watcher'
19+
include '_common', 'cluster', 'indices', 'search', 'watcher'
1820
}
1921
}
2022

2123
String slackUrl = System.getenv('slack_url')
2224

2325
if (!slackUrl) {
2426
tasks.named("yamlRestTest").configure { enabled = false }
25-
} else {
26-
testClusters.matching { it.name == "yamlRestTest" }.configureEach {
27-
testDistribution = 'DEFAULT'
28-
setting 'xpack.security.enabled', 'false'
29-
setting 'xpack.ml.enabled', 'false'
30-
setting 'xpack.license.self_generated.type', 'trial'
31-
setting 'logger.org.elasticsearch.xpack.watcher', 'DEBUG'
32-
keystore 'xpack.notification.slack.account.test_account.secure_url', slackUrl
33-
}
3427
}
3528

3629
if (buildParams.inFipsJvm){

0 commit comments

Comments
 (0)