[TEST] If bulk item failed then log why.
Original commit: elastic/x-pack-elasticsearch@e7cc96460df9b58609e26764bad1ebd79646771a
@@ -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);
}
