Skip to content

Commit fb1fc72

Browse files
authored
Added missing data streams tests (#60878)
This tests exist in 7.x branch, but not in master branch.
1 parent e4014de commit fb1fc72

File tree

1 file changed

+32
-0
lines changed
  • x-pack/plugin/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams

1 file changed

+32
-0
lines changed

x-pack/plugin/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
7474
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
7575
import static org.hamcrest.Matchers.arrayWithSize;
76+
import static org.hamcrest.Matchers.containsString;
7677
import static org.hamcrest.Matchers.equalTo;
7778
import static org.hamcrest.Matchers.hasItemInArray;
7879
import static org.hamcrest.Matchers.hasSize;
@@ -221,6 +222,37 @@ public void testOtherWriteOps() throws Exception {
221222
CreateDataStreamAction.Request createDataStreamRequest = new CreateDataStreamAction.Request(dataStreamName);
222223
client().execute(CreateDataStreamAction.INSTANCE, createDataStreamRequest).get();
223224

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+
}
224256
{
225257
IndexRequest indexRequest = new IndexRequest(dataStreamName).source("{\"@timestamp\": \"2020-12-12\"}", XContentType.JSON);
226258
Exception e = expectThrows(IllegalArgumentException.class, () -> client().index(indexRequest).actionGet());

0 commit comments

Comments
 (0)