Skip to content

Commit 7be13e5

Browse files
committed
QA: Fixup rolling restart tests
Fix the skip message in the token tests to explain why the test can only be run once in the mixed version cluster. Reenable the watcher tests by writing a condition that will hold true.
1 parent 3114553 commit 7be13e5

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public void testTokenWorksInMixedOrUpgradedCluster() throws Exception {
7272
public void testMixedCluster() throws Exception {
7373
assumeTrue("this test should only run against the mixed cluster", CLUSTER_TYPE == ClusterType.MIXED);
7474
assumeTrue("the master must be on the latest version before we can write", isMasterOnLatestVersion());
75-
assumeFalse("Can't be run twice in mixed clusters for unknown reasons so we skip the first attempt",
76-
false == Booleans.parseBoolean(System.getProperty("tests.first_round")));
75+
assumeFalse("can't be run twice because it invalidates a token so we skip the first attempt",
76+
Booleans.parseBoolean(System.getProperty("tests.first_round")));
7777

7878
Response getResponse = client().performRequest("GET", "token_backwards_compatibility_it/doc/old_cluster_token2");
7979
assertOK(getResponse);

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

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.util.HashMap;
3535
import java.util.List;
3636
import java.util.Map;
37+
import java.util.function.Function;
3738
import java.util.stream.Collectors;
3839

3940
import static org.elasticsearch.xpack.watcher.actions.ActionBuilders.loggingAction;
@@ -177,14 +178,14 @@ public void testWatcherStats() throws Exception {
177178
}
178179

179180
public void testWatcherRestart() throws Exception {
180-
assumeFalse("Seems to be broken in mixed clusters. Skipping while I debug.", CLUSTER_TYPE == ClusterType.MIXED);
181181
executeUpgradeIfNeeded();
182182

183183
executeAgainstRandomNode(client -> assertOK(client.performRequest("POST", "/_xpack/watcher/_stop")));
184184
ensureWatcherStopped();
185185

186186
executeAgainstRandomNode(client -> assertOK(client.performRequest("POST", "/_xpack/watcher/_start")));
187-
ensureWatcherStarted();
187+
// Watcher should be started on at least the nodes with the new version.
188+
ensureWatcherStartedOnModernNodes();
188189
}
189190

190191
public void testWatchCrudApis() throws Exception {
@@ -314,6 +315,30 @@ private void ensureWatcherStarted() throws Exception {
314315
}));
315316
}
316317

318+
private void ensureWatcherStartedOnModernNodes() throws Exception {
319+
if (nodes.getMaster().getVersion().before(Version.V_6_0_0)) {
320+
/*
321+
* Versions before 6.0 ran watcher on the master node and the
322+
* logic in ensureWatcherStarted is fine.
323+
*/
324+
ensureWatcherStarted();
325+
return;
326+
}
327+
executeAgainstMasterNode(client -> assertBusy(() -> {
328+
Map<?, ?> responseBody = entityAsMap(client.performRequest("GET", "_xpack/watcher/stats"));
329+
logger.info("ensureWatcherStartedOnModernNodes(), stats response [{}]", responseBody);
330+
Map<?, ?> stats = ((List<?>) responseBody.get("stats")).stream()
331+
.map(o -> (Map<?, ?>) o)
332+
.collect(Collectors.toMap(m -> m.get("node_id"), Function.identity()));
333+
assertNotNull("no stats yet", stats);
334+
for (Node node : nodes.getNewNodes()) {
335+
Map<?, ?> nodeStats = (Map<?, ?>) stats.get(node.getId());
336+
assertEquals("modern node [" + node.getId() + "] is not started",
337+
nodeStats.get("watcher_state"), "started");
338+
}
339+
}));
340+
}
341+
317342
private Nodes buildNodeAndVersions() throws IOException {
318343
Response response = client().performRequest("GET", "_nodes");
319344
ObjectPath objectPath = ObjectPath.createFromResponse(response);

0 commit comments

Comments
 (0)