REST test for rolling data streams

This commit is contained in:
Dan Hermann 2020-04-29 17:34:52 -05:00 committed by GitHub
parent 462c0337a1
commit 9bf254fe36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,44 @@
---
"Roll over a data stream":
- skip:
version: " - 7.99.99"
reason: "enable in 7.8+ after backporting"
- do:
indices.create_data_stream:
name: data-stream-for-rollover
body:
timestamp_field: "@timestamp"
- is_true: acknowledged
# rollover data stream to create new backing index
- do:
indices.rollover:
alias: "data-stream-for-rollover"
- match: { old_index: data-stream-for-rollover-000001 }
- match: { new_index: data-stream-for-rollover-000002 }
- match: { rolled_over: true }
- match: { dry_run: false }
# ensure new index is created
- do:
indices.exists:
index: data-stream-for-rollover-000002
- is_true: ''
- do:
indices.get_data_streams:
name: "*"
- match: { 0.name: data-stream-for-rollover }
- match: { 0.timestamp_field: '@timestamp' }
- match: { 0.generation: 2 }
- length: { 0.indices: 2 }
- match: { 0.indices.0.index_name: 'data-stream-for-rollover-000001' }
- match: { 0.indices.1.index_name: 'data-stream-for-rollover-000002' }
- do:
indices.delete_data_stream:
name: data-stream-for-rollover
- is_true: acknowledged

View File

@ -96,6 +96,7 @@ public final class DataStream extends AbstractDiffable<DataStream> implements To
public DataStream removeBackingIndex(Index index) {
List<Index> backingIndices = new ArrayList<>(indices);
backingIndices.remove(index);
assert backingIndices.size() == indices.size() - 1;
return new DataStream(name, timeStampField, backingIndices, generation);
}