|
9 | 9 | import com.carrotsearch.randomizedtesting.annotations.Name; |
10 | 10 | import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; |
11 | 11 |
|
| 12 | +import org.elasticsearch.test.cluster.ElasticsearchCluster; |
12 | 13 | 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; |
25 | 15 |
|
26 | 16 | /** 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 | + } |
28 | 35 |
|
29 | 36 | public WatcherJiraYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) { |
30 | 37 | super(testCandidate); |
31 | 38 | } |
32 | 39 |
|
33 | 40 | @ParametersFactory |
34 | 41 | 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(); |
76 | 43 | } |
77 | 44 | } |
0 commit comments