[TEST] If bulk item failed then log why.
Original commit: elastic/x-pack-elasticsearch@e7cc96460d
This commit is contained in:
parent
622c5ae166
commit
51662c83eb
|
@ -7,6 +7,7 @@ package org.elasticsearch.xpack.ml.support;
|
||||||
|
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse;
|
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.BulkRequestBuilder;
|
||||||
import org.elasticsearch.action.bulk.BulkResponse;
|
import org.elasticsearch.action.bulk.BulkResponse;
|
||||||
import org.elasticsearch.action.index.IndexRequest;
|
import org.elasticsearch.action.index.IndexRequest;
|
||||||
|
@ -50,7 +51,6 @@ import java.util.Map;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.is;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A base class for testing datafeed and job lifecycle specifics.
|
* A base class for testing datafeed and job lifecycle specifics.
|
||||||
|
@ -209,7 +209,16 @@ public abstract class BaseMlIntegTestCase extends ESIntegTestCase {
|
||||||
BulkResponse bulkResponse = bulkRequestBuilder
|
BulkResponse bulkResponse = bulkRequestBuilder
|
||||||
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
||||||
.get();
|
.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);
|
logger.info("Indexed [{}] documents", numDocs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue