From db8f2be8bce8524414ea1b2821e21e7975cddc82 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Wed, 18 Sep 2013 12:35:20 +0200 Subject: [PATCH] improve logging on before/after shared cluster tests --- .../AbstractSharedClusterTest.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/test/java/org/elasticsearch/AbstractSharedClusterTest.java b/src/test/java/org/elasticsearch/AbstractSharedClusterTest.java index ec26daaf69d..22b6981088f 100644 --- a/src/test/java/org/elasticsearch/AbstractSharedClusterTest.java +++ b/src/test/java/org/elasticsearch/AbstractSharedClusterTest.java @@ -103,11 +103,12 @@ public abstract class AbstractSharedClusterTest extends ElasticsearchTestCase { cluster.beforeTest(getRandom()); wipeIndices(); wipeTemplates(); + logger.info("[{}#{}]: before test", getTestClass().getSimpleName(), getTestName()); } @After public void after() throws IOException { - logger.info("Cleaning up after test."); + logger.info("[{}#{}]: cleaning up after test", getTestClass().getSimpleName(), getTestName()); MetaData metaData = client().admin().cluster().prepareState().execute().actionGet().getState().getMetaData(); assertThat("test leaves persistent cluster metadata behind: " + metaData.persistentSettings().getAsMap(), metaData .persistentSettings().getAsMap().size(), equalTo(0)); @@ -116,6 +117,7 @@ public abstract class AbstractSharedClusterTest extends ElasticsearchTestCase { wipeIndices(); // wipe after to make sure we fail in the test that didn't ack the delete wipeTemplates(); ensureAllFilesClosed(); + logger.info("[{}#{}]: cleaned up after test", getTestClass().getSimpleName(), getTestName()); } public static TestCluster cluster() { @@ -416,7 +418,7 @@ public abstract class AbstractSharedClusterTest extends ElasticsearchTestCase { } } } - + } else { logger.info("Index [{}] docs async: [{}]", list.size(), false); for (IndexRequestBuilder indexRequestBuilder : list) { @@ -440,17 +442,17 @@ public abstract class AbstractSharedClusterTest extends ElasticsearchTestCase { assertNoFailures(client().admin().indices().prepareRefresh(indices).setIgnoreIndices(IgnoreIndices.MISSING).execute().get()); } } - + private static final CountDownLatch newLatch(List latches) { CountDownLatch l = new CountDownLatch(1); latches.add(l); return l; } - + private static class LatchedActionListener implements ActionListener { private final CountDownLatch latch; private final CopyOnWriteArrayList errors; - + public LatchedActionListener(CountDownLatch latch, CopyOnWriteArrayList errors) { this.latch = latch; this.errors = errors; @@ -464,12 +466,12 @@ public abstract class AbstractSharedClusterTest extends ElasticsearchTestCase { @Override public void onFailure(Throwable e) { try { - errors.add(e); + errors.add(e); } finally { - latch.countDown(); + latch.countDown(); } } - + } public void clearScroll(String... scrollIds) {