|
73 | 73 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; |
74 | 74 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; |
75 | 75 | import static org.hamcrest.Matchers.arrayWithSize; |
| 76 | +import static org.hamcrest.Matchers.containsString; |
76 | 77 | import static org.hamcrest.Matchers.equalTo; |
77 | 78 | import static org.hamcrest.Matchers.hasItemInArray; |
78 | 79 | import static org.hamcrest.Matchers.hasSize; |
@@ -221,6 +222,37 @@ public void testOtherWriteOps() throws Exception { |
221 | 222 | CreateDataStreamAction.Request createDataStreamRequest = new CreateDataStreamAction.Request(dataStreamName); |
222 | 223 | client().execute(CreateDataStreamAction.INSTANCE, createDataStreamRequest).get(); |
223 | 224 |
|
| 225 | + { |
| 226 | + BulkRequest bulkRequest = new BulkRequest().add( |
| 227 | + new IndexRequest(dataStreamName).source("{\"@timestamp1\": \"2020-12-12\"}", XContentType.JSON) |
| 228 | + ); |
| 229 | + BulkResponse bulkResponse = client().bulk(bulkRequest).actionGet(); |
| 230 | + assertThat(bulkResponse.getItems(), arrayWithSize(1)); |
| 231 | + assertThat( |
| 232 | + bulkResponse.getItems()[0].getFailure().getMessage(), |
| 233 | + containsString("only write ops with an op_type of create are allowed in data streams") |
| 234 | + ); |
| 235 | + } |
| 236 | + { |
| 237 | + BulkRequest bulkRequest = new BulkRequest().add(new DeleteRequest(dataStreamName, "_id")); |
| 238 | + BulkResponse bulkResponse = client().bulk(bulkRequest).actionGet(); |
| 239 | + assertThat(bulkResponse.getItems(), arrayWithSize(1)); |
| 240 | + assertThat( |
| 241 | + bulkResponse.getItems()[0].getFailure().getMessage(), |
| 242 | + containsString("only write ops with an op_type of create are allowed in data streams") |
| 243 | + ); |
| 244 | + } |
| 245 | + { |
| 246 | + BulkRequest bulkRequest = new BulkRequest().add( |
| 247 | + new UpdateRequest(dataStreamName, "_id").doc("{\"@timestamp1\": \"2020-12-12\"}", XContentType.JSON) |
| 248 | + ); |
| 249 | + BulkResponse bulkResponse = client().bulk(bulkRequest).actionGet(); |
| 250 | + assertThat(bulkResponse.getItems(), arrayWithSize(1)); |
| 251 | + assertThat( |
| 252 | + bulkResponse.getItems()[0].getFailure().getMessage(), |
| 253 | + containsString("only write ops with an op_type of create are allowed in data streams") |
| 254 | + ); |
| 255 | + } |
224 | 256 | { |
225 | 257 | IndexRequest indexRequest = new IndexRequest(dataStreamName).source("{\"@timestamp\": \"2020-12-12\"}", XContentType.JSON); |
226 | 258 | Exception e = expectThrows(IllegalArgumentException.class, () -> client().index(indexRequest).actionGet()); |
|
0 commit comments