From 18f16ba555f0ba35213885c7203deeddeed552e5 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Fri, 2 Jun 2017 11:02:44 -0400 Subject: [PATCH] Test: improve error message on leftover tasks After every REST test we wait for the list of pending cluster tasks to empty before moving on to the next task. If the list doesn't empty in 10 second we fail the test. This improves the error message when we fail the test to include the list of running tasks. --- .../org/elasticsearch/test/rest/ESRestTestCase.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java index 9e4723f0fe6..a2d6f3bea5c 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java @@ -40,7 +40,6 @@ import org.junit.After; import org.junit.AfterClass; import org.junit.Before; -import javax.net.ssl.SSLContext; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; @@ -56,6 +55,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import javax.net.ssl.SSLContext; + import static java.util.Collections.singletonMap; import static java.util.Collections.sort; import static java.util.Collections.unmodifiableList; @@ -262,8 +263,14 @@ public abstract class ESRestTestCase extends ESTestCase { assertBusy(() -> { try { Response response = adminClient().performRequest("GET", "_cluster/pending_tasks"); - List tasks = (List) entityAsMap(response).get("tasks"); - assertTrue(tasks.isEmpty()); + List tasks = (List) entityAsMap(response).get("tasks"); + if (false == tasks.isEmpty()) { + StringBuilder message = new StringBuilder("there are still running tasks:"); + for (Object task: tasks) { + message.append('\n').append(task.toString()); + } + fail(message.toString()); + } } catch (IOException e) { fail("cannot get cluster's pending tasks: " + e.getMessage()); }