Skip to content

Commit

Permalink
Assert job is not null in FullClusterRestartIT (#38218)
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
polyfractal committed Feb 5, 2019
1 parent 2b6b858 commit f939c3c
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -659,9 +659,8 @@ private void assertRollUpJob(final String rollupJob) throws Exception {
}
Map<String, Object> getRollupJobResponse = entityAsMap(client().performRequest(getRollupJobRequest));
Map<String, Object> job = getJob(getRollupJobResponse, rollupJob);
if (job != null) {
assertThat(ObjectPath.eval("status.job_state", job), expectedStates);
}
assertNotNull(job);
assertThat(ObjectPath.eval("status.job_state", job), expectedStates);

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

Map<String, Object> job = getJob(getRollupJobResponse, rollupJob);
if (job != null) {
assertThat(ObjectPath.eval("status.job_state", job), expectedStates);
}
assertNotNull(job);
assertThat(ObjectPath.eval("status.job_state", job), expectedStates);
}, 30L, TimeUnit.SECONDS);
}

Expand Down

0 comments on commit f939c3c

Please sign in to comment.