Assert job is not null in FullClusterRestartIT (#38218)

`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.
This commit is contained in:
Zachary Tong 2019-02-05 17:06:28 -05:00 committed by GitHub
parent 2b6b85815b
commit f939c3c5ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 6 deletions

View File

@ -659,9 +659,8 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
}
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");
@ -712,9 +711,8 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
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);
}