Skip to content

Commit

Permalink
[TEST] Add Elasticsearch 5.0 bulk error test
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaiera committed Jul 11, 2016
1 parent 3724768 commit c3fc0d2
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,30 @@ public void testParseBulkErrorsInES090x() throws Exception {
assertTrue(string.contains("E"));
}

@Test
public void testParseBulkErrorsInES5x() throws Exception {
String inputEntry = IOUtils.asString(getClass().getResourceAsStream("bulk-retry-input-template.json"));

TrackingBytesArray inputData = new TrackingBytesArray(new BytesArray(128));

inputData.copyFrom(new BytesArray(inputEntry.replace("w", "A")));
inputData.copyFrom(new BytesArray(inputEntry.replace("w", "B")));
inputData.copyFrom(new BytesArray(inputEntry.replace("w", "C")));
inputData.copyFrom(new BytesArray(inputEntry.replace("w", "D")));
inputData.copyFrom(new BytesArray(inputEntry.replace("w", "E")));

assertEquals(5, inputData.entries());
assertEquals("{0, 1, 2, 3, 4}", inputData.leftoversPosition().toString());

Response response = new SimpleResponse(HttpStatus.OK, getClass().getResourceAsStream("bulk-retry-output-es5x.json"), "");
assertTrue(rc.retryFailedEntries(response, inputData));
assertEquals(3, inputData.entries());
assertEquals("{1, 3, 4}", inputData.leftoversPosition().toString());
String string = inputData.toString();
assertTrue(string.contains("B"));
assertTrue(string.contains("D"));
assertTrue(string.contains("E"));

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"took": 56,
"errors": false,
"items": [
{
"index": {
"_index": "foo",
"_type": "bar",
"_id": "AVXMJmn4D7mgXuu4xXuX",
"_version": 1,
"forced_refresh": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"created": true,
"status": 201
}
},
{
"index": {
"_index": "foo",
"_type": "bar",
"_id": "AVXMJm7cD7mgXuu4xX14",
"status": 429,
"error": {
"type": "es_rejected_execution_exception",
"reason": "rejected execution of org.elasticsearch.transport.TransportService$5@2c37e0bc on EsThreadPoolExecutor[bulk, queue capacity = 0, org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor@7e1fa465[Running, pool size = 1, active threads = 0, queued tasks = 0, completed tasks = 1]]"
}
}
},
{
"index": {
"_index": "foo",
"_type": "bar",
"_id": "AVXMJmn4D7mgXuu4xXuZ",
"_version": 1,
"forced_refresh": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"created": true,
"status": 201
}
},
{
"index": {
"_index": "foo",
"_type": "bar",
"_id": "AVXMJm7cD7mgXuu4xX16",
"status": 429,
"error": {
"type": "es_rejected_execution_exception",
"reason": "rejected execution of org.elasticsearch.transport.TransportService$5@2c37e0bc on EsThreadPoolExecutor[bulk, queue capacity = 0, org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor@7e1fa465[Running, pool size = 1, active threads = 0, queued tasks = 0, completed tasks = 1]]"
}
}
},
{
"index": {
"_index": "foo",
"_type": "bar",
"_id": "AVXMJm7cD7mgXuu4xX17",
"status": 429,
"error": {
"type": "es_rejected_execution_exception",
"reason": "rejected execution of org.elasticsearch.transport.TransportService$5@2c37e0bc on EsThreadPoolExecutor[bulk, queue capacity = 0, org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor@7e1fa465[Running, pool size = 1, active threads = 0, queued tasks = 0, completed tasks = 1]]"
}
}
}
]
}

0 comments on commit c3fc0d2

Please sign in to comment.