Skip to content

Commit 537763e

Browse files
committed
Fix failing integration tests.
1 parent 3993aa9 commit 537763e

File tree

10 files changed

+95
-96
lines changed

10 files changed

+95
-96
lines changed

client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorIT.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public void testBulkProcessorConcurrentRequests() throws Exception {
163163
for (BulkItemResponse bulkItemResponse : listener.bulkItems) {
164164
assertThat(bulkItemResponse.getFailureMessage(), bulkItemResponse.isFailed(), equalTo(false));
165165
assertThat(bulkItemResponse.getIndex(), equalTo("test"));
166-
assertThat(bulkItemResponse.getType(), equalTo("test"));
166+
assertThat(bulkItemResponse.getType(), equalTo("_doc"));
167167
//with concurrent requests > 1 we can't rely on the order of the bulk requests
168168
assertThat(Integer.valueOf(bulkItemResponse.getId()), both(greaterThan(0)).and(lessThanOrEqualTo(numDocs)));
169169
//we do want to check that we don't get duplicate ids back
@@ -240,12 +240,12 @@ public void testBulkProcessorConcurrentRequestsReadOnlyIndex() throws Exception
240240
for (int i = 1; i <= numDocs; i++) {
241241
if (randomBoolean()) {
242242
testDocs++;
243-
processor.add(new IndexRequest("test", "test", Integer.toString(testDocs))
243+
processor.add(new IndexRequest("test", "_doc", Integer.toString(testDocs))
244244
.source(XContentType.JSON, "field", "value"));
245-
multiGetRequest.add("test", "test", Integer.toString(testDocs));
245+
multiGetRequest.add("test", Integer.toString(testDocs));
246246
} else {
247247
testReadOnlyDocs++;
248-
processor.add(new IndexRequest("test-ro", "test", Integer.toString(testReadOnlyDocs))
248+
processor.add(new IndexRequest("test-ro", "_doc", Integer.toString(testReadOnlyDocs))
249249
.source(XContentType.JSON, "field", "value"));
250250
}
251251
}
@@ -262,7 +262,7 @@ public void testBulkProcessorConcurrentRequestsReadOnlyIndex() throws Exception
262262
Set<String> readOnlyIds = new HashSet<>();
263263
for (BulkItemResponse bulkItemResponse : listener.bulkItems) {
264264
assertThat(bulkItemResponse.getIndex(), either(equalTo("test")).or(equalTo("test-ro")));
265-
assertThat(bulkItemResponse.getType(), equalTo("test"));
265+
assertThat(bulkItemResponse.getType(), equalTo("_doc"));
266266
if (bulkItemResponse.getIndex().equals("test")) {
267267
assertThat(bulkItemResponse.isFailed(), equalTo(false));
268268
//with concurrent requests > 1 we can't rely on the order of the bulk requests
@@ -330,12 +330,12 @@ public void testGlobalParametersAndBulkProcessor() throws Exception {
330330
.setConcurrentRequests(randomIntBetween(0, 1)).setBulkActions(numDocs)
331331
.setFlushInterval(TimeValue.timeValueHours(24)).setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB))
332332
.setGlobalIndex("test")
333-
.setGlobalType("test")
333+
.setGlobalType("_doc")
334334
.setGlobalRouting("routing")
335335
.setGlobalPipeline("pipeline_id")
336336
.build()) {
337337

338-
indexDocs(processor, numDocs, null, null, "test", "test", "pipeline_id");
338+
indexDocs(processor, numDocs, null, null, "test", "pipeline_id");
339339
latch.await();
340340

341341
assertThat(listener.beforeCounts.get(), equalTo(1));
@@ -346,7 +346,7 @@ public void testGlobalParametersAndBulkProcessor() throws Exception {
346346
Iterable<SearchHit> hits = searchAll(new SearchRequest("test").routing("routing"));
347347

348348
assertThat(hits, everyItem(hasProperty(fieldFromSource("fieldNameXYZ"), equalTo("valueXYZ"))));
349-
assertThat(hits, everyItem(Matchers.allOf(hasIndex("test"), hasType("test"))));
349+
assertThat(hits, everyItem(Matchers.allOf(hasIndex("test"), hasType("_doc"))));
350350
assertThat(hits, containsInAnyOrder(expectedIds(numDocs)));
351351
}
352352
}
@@ -359,18 +359,18 @@ private Matcher<SearchHit>[] expectedIds(int numDocs) {
359359
.<Matcher<SearchHit>>toArray(Matcher[]::new);
360360
}
361361

362-
private static MultiGetRequest indexDocs(BulkProcessor processor, int numDocs, String localIndex, String localType,
362+
private static MultiGetRequest indexDocs(BulkProcessor processor, int numDocs, String localIndex,
363363
String globalIndex, String globalType, String globalPipeline) throws Exception {
364364
MultiGetRequest multiGetRequest = new MultiGetRequest();
365365
for (int i = 1; i <= numDocs; i++) {
366366
if (randomBoolean()) {
367-
processor.add(new IndexRequest(localIndex, localType, Integer.toString(i))
367+
processor.add(new IndexRequest(localIndex, "_doc", Integer.toString(i))
368368
.source(XContentType.JSON, "field", randomRealisticUnicodeOfLengthBetween(1, 30)));
369369
} else {
370-
BytesArray data = bytesBulkRequest(localIndex, localType, i);
370+
BytesArray data = bytesBulkRequest(localIndex, "_doc", i);
371371
processor.add(data, globalIndex, globalType, globalPipeline, null, XContentType.JSON);
372372
}
373-
multiGetRequest.add(localIndex, localType, Integer.toString(i));
373+
multiGetRequest.add(localIndex, Integer.toString(i));
374374
}
375375
return multiGetRequest;
376376
}
@@ -396,15 +396,15 @@ private static BytesArray bytesBulkRequest(String localIndex, String localType,
396396
}
397397

398398
private static MultiGetRequest indexDocs(BulkProcessor processor, int numDocs) throws Exception {
399-
return indexDocs(processor, numDocs, "test", "test", null, null, null);
399+
return indexDocs(processor, numDocs, "test", null, null, null);
400400
}
401401

402402
private static void assertResponseItems(List<BulkItemResponse> bulkItemResponses, int numDocs) {
403403
assertThat(bulkItemResponses.size(), is(numDocs));
404404
int i = 1;
405405
for (BulkItemResponse bulkItemResponse : bulkItemResponses) {
406406
assertThat(bulkItemResponse.getIndex(), equalTo("test"));
407-
assertThat(bulkItemResponse.getType(), equalTo("test"));
407+
assertThat(bulkItemResponse.getType(), equalTo("_doc"));
408408
assertThat(bulkItemResponse.getId(), equalTo(Integer.toString(i++)));
409409
assertThat("item " + i + " failed with cause: " + bulkItemResponse.getFailureMessage(),
410410
bulkItemResponse.isFailed(), equalTo(false));
@@ -416,7 +416,7 @@ private static void assertMultiGetResponse(MultiGetResponse multiGetResponse, in
416416
int i = 1;
417417
for (MultiGetItemResponse multiGetItemResponse : multiGetResponse) {
418418
assertThat(multiGetItemResponse.getIndex(), equalTo("test"));
419-
assertThat(multiGetItemResponse.getType(), equalTo("test"));
419+
assertThat(multiGetItemResponse.getType(), equalTo("_doc"));
420420
assertThat(multiGetItemResponse.getId(), equalTo(Integer.toString(i++)));
421421
}
422422
}

client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorRetryIT.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
public class BulkProcessorRetryIT extends ESRestHighLevelClientTestCase {
4646

4747
private static final String INDEX_NAME = "index";
48-
private static final String TYPE_NAME = "type";
4948

5049
private static BulkProcessor.Builder initBulkProcessorBuilder(BulkProcessor.Listener listener) {
5150
return BulkProcessor.builder(
@@ -144,9 +143,9 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure)
144143
private static MultiGetRequest indexDocs(BulkProcessor processor, int numDocs) {
145144
MultiGetRequest multiGetRequest = new MultiGetRequest();
146145
for (int i = 1; i <= numDocs; i++) {
147-
processor.add(new IndexRequest(INDEX_NAME, TYPE_NAME, Integer.toString(i))
146+
processor.add(new IndexRequest(INDEX_NAME, "_doc", Integer.toString(i))
148147
.source(XContentType.JSON, "field", randomRealisticUnicodeOfCodepointLengthBetween(1, 30)));
149-
multiGetRequest.add(INDEX_NAME, TYPE_NAME, Integer.toString(i));
148+
multiGetRequest.add(INDEX_NAME, Integer.toString(i));
150149
}
151150
return multiGetRequest;
152151
}

client/rest-high-level/src/test/java/org/elasticsearch/client/MachineLearningIT.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ public void testStartDatafeed() throws Exception {
527527

528528
// Set up the index and docs
529529
CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName);
530-
createIndexRequest.mapping("doc", "timestamp", "type=date", "total", "type=long");
530+
createIndexRequest.mapping("_doc", "timestamp", "type=date", "total", "type=long");
531531
highLevelClient().indices().create(createIndexRequest, RequestOptions.DEFAULT);
532532
BulkRequest bulk = new BulkRequest();
533533
bulk.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
@@ -538,7 +538,7 @@ public void testStartDatafeed() throws Exception {
538538
while(pastCopy < now) {
539539
IndexRequest doc = new IndexRequest();
540540
doc.index(indexName);
541-
doc.type("doc");
541+
doc.type("_doc");
542542
doc.id("id" + i);
543543
doc.source("{\"total\":" +randomInt(1000) + ",\"timestamp\":"+ pastCopy +"}", XContentType.JSON);
544544
bulk.add(doc);
@@ -558,7 +558,7 @@ public void testStartDatafeed() throws Exception {
558558
DatafeedConfig datafeed = DatafeedConfig.builder(datafeedId, jobId)
559559
.setIndices(indexName)
560560
.setQueryDelay(TimeValue.timeValueSeconds(1))
561-
.setTypes(Arrays.asList("doc"))
561+
.setTypes(Arrays.asList("_doc"))
562562
.setFrequency(TimeValue.timeValueSeconds(1)).build();
563563
machineLearningClient.putDatafeed(new PutDatafeedRequest(datafeed), RequestOptions.DEFAULT);
564564

@@ -603,7 +603,7 @@ public void testStopDatafeed() throws Exception {
603603

604604
// Set up the index
605605
CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName);
606-
createIndexRequest.mapping("doc", "timestamp", "type=date", "total", "type=long");
606+
createIndexRequest.mapping("_doc", "timestamp", "type=date", "total", "type=long");
607607
highLevelClient().indices().create(createIndexRequest, RequestOptions.DEFAULT);
608608

609609
// create the job and the datafeed
@@ -667,7 +667,7 @@ public void testGetDatafeedStats() throws Exception {
667667

668668
// Set up the index
669669
CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName);
670-
createIndexRequest.mapping("doc", "timestamp", "type=date", "total", "type=long");
670+
createIndexRequest.mapping("_doc", "timestamp", "type=date", "total", "type=long");
671671
highLevelClient().indices().create(createIndexRequest, RequestOptions.DEFAULT);
672672

673673
// create the job and the datafeed
@@ -736,7 +736,7 @@ public void testPreviewDatafeed() throws Exception {
736736

737737
// Set up the index and docs
738738
CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName);
739-
createIndexRequest.mapping("doc", "timestamp", "type=date", "total", "type=long");
739+
createIndexRequest.mapping("_doc", "timestamp", "type=date", "total", "type=long");
740740
highLevelClient().indices().create(createIndexRequest, RequestOptions.DEFAULT);
741741
BulkRequest bulk = new BulkRequest();
742742
bulk.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
@@ -748,7 +748,7 @@ public void testPreviewDatafeed() throws Exception {
748748
Integer total = randomInt(1000);
749749
IndexRequest doc = new IndexRequest();
750750
doc.index(indexName);
751-
doc.type("doc");
751+
doc.type("_doc");
752752
doc.id("id" + i);
753753
doc.source("{\"total\":" + total + ",\"timestamp\":"+ thePast +"}", XContentType.JSON);
754754
bulk.add(doc);
@@ -768,7 +768,7 @@ public void testPreviewDatafeed() throws Exception {
768768
DatafeedConfig datafeed = DatafeedConfig.builder(datafeedId, jobId)
769769
.setIndices(indexName)
770770
.setQueryDelay(TimeValue.timeValueSeconds(1))
771-
.setTypes(Collections.singletonList("doc"))
771+
.setTypes(Collections.singletonList("_doc"))
772772
.setFrequency(TimeValue.timeValueSeconds(1)).build();
773773
machineLearningClient.putDatafeed(new PutDatafeedRequest(datafeed), RequestOptions.DEFAULT);
774774

@@ -795,7 +795,7 @@ private String createExpiredData(String jobId) throws Exception {
795795
String indexId = jobId + "-data";
796796
// Set up the index and docs
797797
CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexId);
798-
createIndexRequest.mapping("doc", "timestamp", "type=date,format=epoch_millis", "total", "type=long");
798+
createIndexRequest.mapping("_doc", "timestamp", "type=date,format=epoch_millis", "total", "type=long");
799799
highLevelClient().indices().create(createIndexRequest, RequestOptions.DEFAULT);
800800
BulkRequest bulk = new BulkRequest();
801801
bulk.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
@@ -809,7 +809,7 @@ private String createExpiredData(String jobId) throws Exception {
809809
long timestamp = nowMillis - TimeValue.timeValueHours(totalBuckets - bucket).getMillis();
810810
int bucketRate = bucket == anomalousBucket ? anomalousRate : normalRate;
811811
for (int point = 0; point < bucketRate; point++) {
812-
IndexRequest indexRequest = new IndexRequest(indexId, "doc");
812+
IndexRequest indexRequest = new IndexRequest(indexId, "_doc");
813813
indexRequest.source(XContentType.JSON, "timestamp", timestamp, "total", randomInt(1000));
814814
bulk.add(indexRequest);
815815
}
@@ -819,7 +819,7 @@ private String createExpiredData(String jobId) throws Exception {
819819
{
820820
// Index a randomly named unused state document
821821
String docId = "non_existing_job_" + randomFrom("model_state_1234567#1", "quantiles", "categorizer_state#1");
822-
IndexRequest indexRequest = new IndexRequest(".ml-state", "doc", docId);
822+
IndexRequest indexRequest = new IndexRequest(".ml-state", "_doc", docId);
823823
indexRequest.source(Collections.emptyMap(), XContentType.JSON);
824824
indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
825825
highLevelClient().index(indexRequest, RequestOptions.DEFAULT);
@@ -1388,7 +1388,7 @@ private void updateModelSnapshotTimestamp(String jobId, String timestamp) throws
13881388
String documentId = jobId + "_model_snapshot_" + snapshotId;
13891389

13901390
String snapshotUpdate = "{ \"timestamp\": " + timestamp + "}";
1391-
UpdateRequest updateSnapshotRequest = new UpdateRequest(".ml-anomalies-" + jobId, "doc", documentId);
1391+
UpdateRequest updateSnapshotRequest = new UpdateRequest(".ml-anomalies-" + jobId, "_doc", documentId);
13921392
updateSnapshotRequest.doc(snapshotUpdate.getBytes(StandardCharsets.UTF_8), XContentType.JSON);
13931393
highLevelClient().update(updateSnapshotRequest, RequestOptions.DEFAULT);
13941394

@@ -1403,7 +1403,7 @@ private String createAndPutDatafeed(String jobId, String indexName) throws IOExc
14031403
DatafeedConfig datafeed = DatafeedConfig.builder(datafeedId, jobId)
14041404
.setIndices(indexName)
14051405
.setQueryDelay(TimeValue.timeValueSeconds(1))
1406-
.setTypes(Arrays.asList("doc"))
1406+
.setTypes(Arrays.asList("_doc"))
14071407
.setFrequency(TimeValue.timeValueSeconds(1)).build();
14081408
highLevelClient().machineLearning().putDatafeed(new PutDatafeedRequest(datafeed), RequestOptions.DEFAULT);
14091409
return datafeedId;
@@ -1414,7 +1414,7 @@ public void createModelSnapshot(String jobId, String snapshotId) throws IOExcept
14141414
Job job = MachineLearningIT.buildJob(jobId);
14151415
highLevelClient().machineLearning().putJob(new PutJobRequest(job), RequestOptions.DEFAULT);
14161416

1417-
IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared", "doc", documentId);
1417+
IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared", "_doc", documentId);
14181418
indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
14191419
indexRequest.source("{\"job_id\":\"" + jobId + "\", \"timestamp\":1541587919000, " +
14201420
"\"description\":\"State persisted due to job close at 2018-11-07T10:51:59+0000\", " +
@@ -1434,7 +1434,7 @@ public void createModelSnapshots(String jobId, List<String> snapshotIds) throws
14341434

14351435
for(String snapshotId : snapshotIds) {
14361436
String documentId = jobId + "_model_snapshot_" + snapshotId;
1437-
IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared", "doc", documentId);
1437+
IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared", "_doc", documentId);
14381438
indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
14391439
indexRequest.source("{\"job_id\":\"" + jobId + "\", \"timestamp\":1541587919000, " +
14401440
"\"description\":\"State persisted due to job close at 2018-11-07T10:51:59+0000\", " +

0 commit comments

Comments
 (0)