Skip to content

Commit fadcce8

Browse files
authored
Watcher: Fold two smoke test projects into smoke-test-watcher (#30137)
In order to have less qa/ projects, this commit removes the watcher-smoke-test-mustache and the watcher-smoke-test-painless projects and moves the tests of both into the watcher-smoke-test projects. This results in less projects to parse when calling gradle and a shorter test time due to being able to run everything within one elasticsearch instance.
1 parent 32dfb65 commit fadcce8

File tree

19 files changed

+98
-177
lines changed

19 files changed

+98
-177
lines changed

x-pack/qa/smoke-test-watcher-with-mustache/build.gradle

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

x-pack/qa/smoke-test-watcher-with-mustache/src/test/java/org/elasticsearch/smoketest/WatcherWithMustacheIT.java

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

x-pack/qa/smoke-test-watcher-with-painless/build.gradle

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

x-pack/qa/smoke-test-watcher-with-painless/src/test/java/org/elasticsearch/smoketest/WatcherWithPainlessIT.java

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

x-pack/qa/smoke-test-watcher/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ apply plugin: 'elasticsearch.rest-test'
99
dependencies {
1010
testCompile project(path: xpackModule('core'), configuration: 'runtime')
1111
testCompile project(path: xpackModule('watcher'), configuration: 'runtime')
12+
testCompile project(path: ':modules:lang-mustache', configuration: 'runtime')
13+
testCompile project(path: ':modules:lang-painless', configuration: 'runtime')
1214
}
1315

1416
integTestCluster {
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
package org.elasticsearch.smoketest;
7+
8+
import com.carrotsearch.randomizedtesting.annotations.Name;
9+
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
10+
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
11+
import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse;
12+
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
13+
import org.elasticsearch.xpack.core.watcher.support.WatcherIndexTemplateRegistryField;
14+
import org.junit.After;
15+
import org.junit.Before;
16+
17+
import static java.util.Collections.emptyList;
18+
import static java.util.Collections.emptyMap;
19+
import static java.util.Collections.singletonMap;
20+
import static org.hamcrest.Matchers.is;
21+
22+
/** Runs rest tests against external cluster */
23+
public class WatcherRestIT extends ESClientYamlSuiteTestCase {
24+
25+
public WatcherRestIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
26+
super(testCandidate);
27+
}
28+
29+
@ParametersFactory
30+
public static Iterable<Object[]> parameters() throws Exception {
31+
return ESClientYamlSuiteTestCase.createParameters();
32+
}
33+
34+
@Before
35+
public void startWatcher() throws Exception {
36+
assertBusy(() -> {
37+
ClientYamlTestResponse response =
38+
getAdminExecutionContext().callApi("xpack.watcher.stats", emptyMap(), emptyList(), emptyMap());
39+
String state = (String) response.evaluate("stats.0.watcher_state");
40+
41+
switch (state) {
42+
case "stopped":
43+
ClientYamlTestResponse startResponse =
44+
getAdminExecutionContext().callApi("xpack.watcher.start", emptyMap(), emptyList(), emptyMap());
45+
boolean isAcknowledged = (boolean) startResponse.evaluate("acknowledged");
46+
assertThat(isAcknowledged, is(true));
47+
break;
48+
case "stopping":
49+
throw new AssertionError("waiting until stopping state reached stopped state to start again");
50+
case "starting":
51+
throw new AssertionError("waiting until starting state reached started state");
52+
case "started":
53+
// all good here, we are done
54+
break;
55+
default:
56+
throw new AssertionError("unknown state[" + state + "]");
57+
}
58+
});
59+
60+
assertBusy(() -> {
61+
for (String template : WatcherIndexTemplateRegistryField.TEMPLATE_NAMES) {
62+
ClientYamlTestResponse templateExistsResponse = getAdminExecutionContext().callApi("indices.exists_template",
63+
singletonMap("name", template), emptyList(), emptyMap());
64+
assertThat(templateExistsResponse.getStatusCode(), is(200));
65+
}
66+
});
67+
}
68+
69+
@After
70+
public void stopWatcher() throws Exception {
71+
assertBusy(() -> {
72+
ClientYamlTestResponse response =
73+
getAdminExecutionContext().callApi("xpack.watcher.stats", emptyMap(), emptyList(), emptyMap());
74+
String state = (String) response.evaluate("stats.0.watcher_state");
75+
76+
switch (state) {
77+
case "stopped":
78+
// all good here, we are done
79+
break;
80+
case "stopping":
81+
throw new AssertionError("waiting until stopping state reached stopped state");
82+
case "starting":
83+
throw new AssertionError("waiting until starting state reached started state to stop");
84+
case "started":
85+
ClientYamlTestResponse stopResponse =
86+
getAdminExecutionContext().callApi("xpack.watcher.stop", emptyMap(), emptyList(), emptyMap());
87+
boolean isAcknowledged = (boolean) stopResponse.evaluate("acknowledged");
88+
assertThat(isAcknowledged, is(true));
89+
break;
90+
default:
91+
throw new AssertionError("unknown state[" + state + "]");
92+
}
93+
});
94+
}
95+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import static org.hamcrest.Matchers.equalTo;
3131
import static org.hamcrest.Matchers.notNullValue;
3232

33-
public class WatcherTemplateTests extends ESTestCase {
33+
public class WatcherTemplateIT extends ESTestCase {
3434

3535
private TextTemplateEngine textTemplateEngine;
3636

0 commit comments

Comments
 (0)