From 51662c83eb1a2875cd4d7e992b4f2536e22a5a2d Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Mon, 3 Apr 2017 13:49:34 +0200 Subject: [PATCH] [TEST] If bulk item failed then log why. Original commit: elastic/x-pack-elasticsearch@e7cc96460df9b58609e26764bad1ebd79646771a --- .../xpack/ml/support/BaseMlIntegTestCase.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java index 02a267fcccb..5d33ddd41e5 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java @@ -7,6 +7,7 @@ package org.elasticsearch.xpack.ml.support; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse; +import org.elasticsearch.action.bulk.BulkItemResponse; import org.elasticsearch.action.bulk.BulkRequestBuilder; import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.index.IndexRequest; @@ -50,7 +51,6 @@ import java.util.Map; import java.util.concurrent.ExecutionException; import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; /** * A base class for testing datafeed and job lifecycle specifics. @@ -209,7 +209,16 @@ public abstract class BaseMlIntegTestCase extends ESIntegTestCase { BulkResponse bulkResponse = bulkRequestBuilder .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE) .get(); - assertThat(bulkResponse.hasFailures(), is(false)); + if (bulkResponse.hasFailures()) { + int failures = 0; + for (BulkItemResponse itemResponse : bulkResponse) { + if (itemResponse.isFailed()) { + failures++; + logger.error("Item response failure [{}]", itemResponse.getFailureMessage()); + } + } + fail("Bulk response contained " + failures + " failures"); + } logger.info("Indexed [{}] documents", numDocs); }