Skip to content

Commit 44c3e8a

Browse files
committed
Assert job is not null in FullClusterRestartIT
`waitForRollUpJob` is an assertBusy that waits for the rollup job to appear in the tasks list, and waits for it to be a certain state. However, there was a null check around the state assertion, which meant if the job _was_ null, the assertion would be skipped, and the assertBusy would pass withouot an exception. This could then lead to downstream assertions to fail because the job was not actually ready, or in the wrong state. This changes the test to assert the job is not null, so the assertBusy operates as intended. Backport of elastic#38218
1 parent 6e0624a commit 44c3e8a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -631,9 +631,8 @@ private void assertRollUpJob(final String rollupJob) throws Exception {
631631
final Request getRollupJobRequest = new Request("GET", "_xpack/rollup/job/" + rollupJob);
632632
Map<String, Object> getRollupJobResponse = entityAsMap(client().performRequest(getRollupJobRequest));
633633
Map<String, Object> job = getJob(getRollupJobResponse, rollupJob);
634-
if (job != null) {
635-
assertThat(ObjectPath.eval("status.job_state", job), expectedStates);
636-
}
634+
assertNotNull(job);
635+
assertThat(ObjectPath.eval("status.job_state", job), expectedStates);
637636

638637
// check that the rollup job is started using the Tasks API
639638
final Request taskRequest = new Request("GET", "_tasks");
@@ -679,9 +678,8 @@ private void waitForRollUpJob(final String rollupJob, final Matcher<?> expectedS
679678
assertThat(getRollupJobResponse.getStatusLine().getStatusCode(), equalTo(RestStatus.OK.getStatus()));
680679

681680
Map<String, Object> job = getJob(getRollupJobResponse, rollupJob);
682-
if (job != null) {
683-
assertThat(ObjectPath.eval("status.job_state", job), expectedStates);
684-
}
681+
assertNotNull(job);
682+
assertThat(ObjectPath.eval("status.job_state", job), expectedStates);
685683
}, 30L, TimeUnit.SECONDS);
686684
}
687685

0 commit comments

Comments
 (0)