Skip to content

Commit 482ae34

Browse files
committed
[TEST] Force a stop to save rollup state before continuing (#32787)
We only upgrade the ID when the state is saved in one of four scenarios: - when we reach a checkpoint (every 50 pages) - when we run out of data - when explicitly stopped - on failure The test was relying on the pre-upgrade to finish, save state and then the post-upgrade to start, hit the end of data and upgrade ID. THEN get the new doc and apply the new ID. But I think this is vulnerable to timing issues. If the pre-upgrade portion shutdown before it saved the state, when restarting we would run through all the data from the beginning with the old ID, meaning both docs would still have the old scheme. This change makes the pre-upgrade wait for the job to go back to STARTED so that we know it persisted the end point. Post-upgrade, it stops and restarts the job to ensure the state was persisted and the ID upgraded. That _should_ rule out the above timing issue. Closes #32773
1 parent acd0a07 commit 482ae34

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,29 @@ public void testRollupIDSchemeAfterRestart() throws Exception {
402402
}
403403
});
404404

405+
// After we've confirmed the doc, wait until we move back to STARTED so that we know the
406+
// state was saved at the end
407+
waitForRollUpJob("rollup-id-test", equalTo("started"));
408+
405409
} else {
406410

407411
final Request indexRequest = new Request("POST", "/id-test-rollup/_doc/2");
408412
indexRequest.setJsonEntity("{\"timestamp\":\"2018-01-02T00:00:01\",\"value\":345}");
409413
client().performRequest(indexRequest);
410414

411-
assertRollUpJob("rollup-id-test");
415+
// stop the rollup job to force a state save, which will upgrade the ID
416+
final Request stopRollupJobRequest = new Request("POST", "_xpack/rollup/job/rollup-id-test/_stop");
417+
Map<String, Object> stopRollupJobResponse = entityAsMap(client().performRequest(stopRollupJobRequest));
418+
assertThat(stopRollupJobResponse.get("stopped"), equalTo(Boolean.TRUE));
419+
420+
waitForRollUpJob("rollup-id-test", equalTo("stopped"));
421+
422+
// start the rollup job again
423+
final Request startRollupJobRequest = new Request("POST", "_xpack/rollup/job/rollup-id-test/_start");
424+
Map<String, Object> startRollupJobResponse = entityAsMap(client().performRequest(startRollupJobRequest));
425+
assertThat(startRollupJobResponse.get("started"), equalTo(Boolean.TRUE));
426+
427+
waitForRollUpJob("rollup-id-test", anyOf(equalTo("indexing"), equalTo("started")));
412428

413429
assertBusy(() -> {
414430
client().performRequest(new Request("POST", "id-test-results-rollup/_refresh"));

0 commit comments

Comments
 (0)