Skip to content

Commit

Permalink
Assert job is not null in FullClusterRestartIT
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.
Backport of elastic#38218
  • Loading branch information
polyfractal committed Feb 5, 2019
1 parent 6e0624a commit 44c3e8a
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,8 @@ private void assertRollUpJob(final String rollupJob) throws Exception {
final Request getRollupJobRequest = new Request("GET", "_xpack/rollup/job/" + rollupJob);
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 @@ -679,9 +678,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 44c3e8a

Please sign in to comment.