|
33 | 33 | import org.elasticsearch.index.IndexSettings; |
34 | 34 | import org.elasticsearch.rest.RestStatus; |
35 | 35 | import org.elasticsearch.rest.action.document.RestIndexAction; |
| 36 | +import org.elasticsearch.rest.action.document.RestUpdateAction; |
36 | 37 | import org.elasticsearch.test.rest.yaml.ObjectPath; |
37 | 38 | import org.hamcrest.Matcher; |
38 | 39 |
|
@@ -572,4 +573,23 @@ private void ensureGlobalCheckpointSynced(String index) throws Exception { |
572 | 573 | }); |
573 | 574 | }, 60, TimeUnit.SECONDS); |
574 | 575 | } |
| 576 | + |
| 577 | + /** Ensure that we can always execute update requests regardless of the version of cluster */ |
| 578 | + public void testUpdateDoc() throws Exception { |
| 579 | + final String index = "test_update_doc"; |
| 580 | + if (CLUSTER_TYPE == ClusterType.OLD) { |
| 581 | + Settings.Builder settings = Settings.builder() |
| 582 | + .put(IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) |
| 583 | + .put(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 2); |
| 584 | + createIndex(index, settings.build()); |
| 585 | + } |
| 586 | + ensureGreen(index); |
| 587 | + indexDocs(index, 0, 10); |
| 588 | + for (int i = 0; i < 10; i++) { |
| 589 | + Request update = new Request("POST", index + "/test/" + i + "/_update/"); |
| 590 | + update.setOptions(expectWarnings(RestUpdateAction.TYPES_DEPRECATION_MESSAGE)); |
| 591 | + update.setJsonEntity("{\"doc\": {\"f\": " + randomNonNegativeLong() + "}}"); |
| 592 | + client().performRequest(update); |
| 593 | + } |
| 594 | + } |
575 | 595 | } |
0 commit comments