Skip to content

Commit b006aca

Browse files
committed
Adds indices.rollover test
1 parent 6e1449b commit b006aca

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

tests/indices/rollover.yml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
teardown:
3+
- do:
4+
indices.delete: { index: logs-1 }
5+
- do:
6+
indices.delete: { index: logs-000002 }
7+
---
8+
"Rollover index via API":
9+
# create index with alias
10+
- do:
11+
indices.create:
12+
index: logs-1
13+
wait_for_active_shards: 1
14+
body:
15+
aliases:
16+
logs_index: {}
17+
logs_search: {}
18+
# index document
19+
- do:
20+
index:
21+
index: logs-1
22+
id: "1"
23+
body: { "foo": "hello world" }
24+
# make this doc visible in index stats
25+
refresh: true
26+
- do:
27+
get:
28+
index: logs_search
29+
id: "1"
30+
- match: { _index: logs-1 }
31+
- match: { _id: "1" }
32+
- match: { _source: { foo: "hello world" } }
33+
34+
# perform alias rollover
35+
- do:
36+
indices.rollover:
37+
alias: "logs_search"
38+
wait_for_active_shards: 1
39+
body:
40+
conditions:
41+
max_docs: 1
42+
- match: { old_index: logs-1 }
43+
- match: { new_index: logs-000002 }
44+
- match: { rolled_over: true }
45+
- match: { dry_run: false }
46+
- match: { conditions: { "[max_docs: 1]": true } }
47+
48+
# ensure new index is created
49+
- do:
50+
indices.exists:
51+
index: logs-000002
52+
- is_true: ''
53+
54+
# index into new index
55+
- do:
56+
index:
57+
index: logs-000002
58+
id: "2"
59+
body: { "foo": "hello world" }
60+
- do:
61+
indices.refresh: {}
62+
63+
# check alias points to the new index
64+
- do:
65+
search:
66+
rest_total_hits_as_int: true
67+
index: logs_search
68+
- match: { hits.total: 1 }
69+
- match: { hits.hits.0._index: "logs-000002"}

0 commit comments

Comments
 (0)