Skip to content

Commit

Permalink
Wait for watcher to be started prior to rolling upgrade tests. (#52186)
Browse files Browse the repository at this point in the history
Backport: #52139

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 #33185
  • Loading branch information
martijnvg authored Feb 11, 2020
1 parent cbebc26 commit c14e466
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
import org.apache.lucene.util.TimeUnits;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.test.rest.ESRestTestCase;
Expand All @@ -19,6 +21,10 @@

import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.List;
import java.util.Map;

import static org.hamcrest.Matchers.equalTo;


@TimeoutSuite(millis = 5 * TimeUnits.MINUTE) // to account for slow as hell VMs
Expand All @@ -32,6 +38,21 @@ public void waitForTemplates() throws Exception {
XPackRestTestHelper.waitForTemplates(client(), XPackRestTestConstants.ML_POST_V660_TEMPLATES);
}

@Before
public void waitForWatcher() throws Exception {
// Wait for watcher to be in started state in order to avoid errors due
// to manually executing watches prior for watcher to be ready:
assertBusy(() -> {
Response response = client().performRequest(new Request("GET", "_watcher/stats"));
Map<String, Object> responseBody = entityAsMap(response);
List<?> stats = (List<?>) responseBody.get("stats");
for (Object stat : stats) {
Map<?, ?> statAsMap = (Map<?, ?>) stat;
assertThat(statAsMap.get("watcher_state"), equalTo("started"));
}
});
}

@Override
protected boolean preserveIndicesUponCompletion() {
return true;
Expand Down

0 comments on commit c14e466

Please sign in to comment.