From 8cf12faa311a5567914df65f7600073e3c4d98be Mon Sep 17 00:00:00 2001 From: Zachary Tong Date: Fri, 8 Feb 2019 12:09:26 -0500 Subject: [PATCH] Assert job is not null in FullClusterRestartIT (#38468) `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 #38218 --- .../xpack/restart/FullClusterRestartIT.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java b/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java index 276cdaaacebf9..381683781b753 100644 --- a/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java +++ b/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java @@ -631,9 +631,8 @@ private void assertRollUpJob(final String rollupJob) throws Exception { final Request getRollupJobRequest = new Request("GET", "_xpack/rollup/job/" + rollupJob); Map getRollupJobResponse = entityAsMap(client().performRequest(getRollupJobRequest)); Map 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"); @@ -679,9 +678,8 @@ private void waitForRollUpJob(final String rollupJob, final Matcher expectedS assertThat(getRollupJobResponse.getStatusLine().getStatusCode(), equalTo(RestStatus.OK.getStatus())); Map 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); }