Skip to content

Commit 2c60fe4

Browse files
committed
Wait for watcher to be started prior to rolling upgrade tests.
In the rolling upgrade tests, watcher is manually executed, in rare scenarios this happens before watcher is started, resulting in the manual execution to fail. Relates to elastic#33185
1 parent b402ea2 commit 2c60fe4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/UpgradeClusterClientYamlTestSuiteIT.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
99
import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
1010
import org.apache.lucene.util.TimeUnits;
11+
import org.elasticsearch.client.Request;
12+
import org.elasticsearch.client.Response;
1113
import org.elasticsearch.common.settings.Settings;
1214
import org.elasticsearch.common.util.concurrent.ThreadContext;
1315
import org.elasticsearch.test.rest.ESRestTestCase;
@@ -19,6 +21,9 @@
1921

2022
import java.nio.charset.StandardCharsets;
2123
import java.util.Base64;
24+
import java.util.Map;
25+
26+
import static org.hamcrest.Matchers.equalTo;
2227

2328

2429
@TimeoutSuite(millis = 5 * TimeUnits.MINUTE) // to account for slow as hell VMs
@@ -32,6 +37,17 @@ public void waitForTemplates() throws Exception {
3237
XPackRestTestHelper.waitForTemplates(client(), XPackRestTestConstants.ML_POST_V660_TEMPLATES);
3338
}
3439

40+
@Before
41+
public void waitForWatcher() throws Exception {
42+
// Wait for watcher to be in started state in order to avoid errors due
43+
// to manually executing watches prior for watcher to be ready:
44+
assertBusy(() -> {
45+
Response response = client().performRequest(new Request("GET", "_watcher/stats"));
46+
Map<String, Object> responseBody = entityAsMap(response);
47+
assertThat(responseBody.get("watcher_state"), equalTo("started"));
48+
});
49+
}
50+
3551
@Override
3652
protected boolean preserveIndicesUponCompletion() {
3753
return true;

0 commit comments

Comments
 (0)