Skip to content

Commit c9aaff2

Browse files
committed
Ensure a unique WatchId for test in SmokeTestWatcherWithSecurityIT
This commit un-mutes SmokeTestWatcherWithSecurityIT by ensuring that between test invocations a new WatchId is used. It is believed that since the same WatchId is used between tests, and that Watch is never deleted, the test failures may be due to a race condition between the current Watch execution, the new Watch (with the same ID), and the busy wait for the Watcher history document. This race condtion can be avoided by simply using a new WatchId and removing the Watch between test invocations. This commit also adds a minor change (XPackRestTestConstants.TEMPLATE_NAMES_NO_ILM) that is needed since the test was muted. Fixes elastic#35361
1 parent b8b5811 commit c9aaff2

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

x-pack/qa/smoke-test-watcher-with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityIT.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@
3232
import static org.hamcrest.Matchers.hasEntry;
3333
import static org.hamcrest.Matchers.is;
3434

35-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/35361")
3635
public class SmokeTestWatcherWithSecurityIT extends ESRestTestCase {
3736

3837
private static final String TEST_ADMIN_USERNAME = "test_admin";
3938
private static final String TEST_ADMIN_PASSWORD = "x-pack-test-password";
4039

41-
private String watchId = randomAlphaOfLength(20);
40+
private String watchId = null;
4241

4342
@Before
4443
public void startWatcher() throws Exception {
44+
watchId = randomAlphaOfLength(20);
4545
Request createAllowedDoc = new Request("PUT", "/my_test_index/_doc/1");
4646
createAllowedDoc.setJsonEntity("{ \"value\" : \"15\" }");
4747
createAllowedDoc.addParameter("refresh", "true");
@@ -83,7 +83,7 @@ public void startWatcher() throws Exception {
8383
});
8484

8585
assertBusy(() -> {
86-
for (String template : XPackRestTestConstants.TEMPLATE_NAMES) {
86+
for (String template : XPackRestTestConstants.TEMPLATE_NAMES_NO_ILM) {
8787
assertOK(adminClient().performRequest(new Request("HEAD", "_template/" + template)));
8888
}
8989
});
@@ -92,6 +92,10 @@ public void startWatcher() throws Exception {
9292
@After
9393
public void stopWatcher() throws Exception {
9494
adminClient().performRequest(new Request("DELETE", "/my_test_index"));
95+
Response response = adminClient().performRequest(new Request("GET", "_watcher/watch/" + watchId));
96+
if (response.getStatusLine().getStatusCode() == 200) {
97+
adminClient().performRequest(new Request("DELETE", "_watcher/watch/" + watchId));
98+
}
9599

96100
assertBusy(() -> {
97101
try {

x-pack/qa/src/main/java/org/elasticsearch/xpack/test/rest/XPackRestTestConstants.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@ public final class XPackRestTestConstants {
1111

1212
// Watcher constants:
1313
public static final String INDEX_TEMPLATE_VERSION = "9";
14-
public static final String HISTORY_TEMPLATE_NAME = ".watch-history-" + INDEX_TEMPLATE_VERSION;
1514
public static final String HISTORY_TEMPLATE_NAME_NO_ILM = ".watch-history-no-ilm-" + INDEX_TEMPLATE_VERSION;
1615
public static final String TRIGGERED_TEMPLATE_NAME = ".triggered_watches";
1716
public static final String WATCHES_TEMPLATE_NAME = ".watches";
18-
public static final String[] TEMPLATE_NAMES = new String[] {
19-
HISTORY_TEMPLATE_NAME, TRIGGERED_TEMPLATE_NAME, WATCHES_TEMPLATE_NAME
20-
};
2117
public static final String[] TEMPLATE_NAMES_NO_ILM = new String[] {
2218
HISTORY_TEMPLATE_NAME_NO_ILM, TRIGGERED_TEMPLATE_NAME, WATCHES_TEMPLATE_NAME
2319
};

0 commit comments

Comments
 (0)