Skip to content

Commit 2f855aa

Browse files
authored
TSDB: Make time boundaries settings required in tsdb indices (#81146)
Make `index.time_series.start_time` and `index.time_series.end_time` settings as required settings in tsdb indices. It will change many tests, among which a time_series index is created, and it will add the `index.time_series.start_time` and `index.time_series.end_time` settings
1 parent f9421e4 commit 2f855aa

File tree

25 files changed

+274
-153
lines changed

25 files changed

+274
-153
lines changed

qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.elasticsearch.cluster.metadata.MetadataIndexStateService;
2020
import org.elasticsearch.common.Strings;
2121
import org.elasticsearch.common.settings.Settings;
22+
import org.elasticsearch.common.time.DateUtils;
2223
import org.elasticsearch.common.xcontent.support.XContentMapValues;
2324
import org.elasticsearch.core.Booleans;
2425
import org.elasticsearch.core.CheckedFunction;
@@ -307,6 +308,8 @@ private int createTimeSeriesModeIndex(int replicas) throws IOException {
307308
mappingsAndSettings.field("number_of_replicas", replicas);
308309
mappingsAndSettings.field("mode", "time_series");
309310
mappingsAndSettings.field("routing_path", "dim");
311+
mappingsAndSettings.field("time_series.start_time", 1L);
312+
mappingsAndSettings.field("time_series.end_time", DateUtils.MAX_MILLIS_BEFORE_9999 - 1);
310313
mappingsAndSettings.endObject();
311314
}
312315
{

qa/multi-cluster-search/src/test/resources/rest-api-spec/test/multi_cluster/100_tsdb.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
setup:
33
# Create a local tsdb index with a tsid the doesn't overlap with the remote cluster.
44
- skip:
5-
version: " - 7.99.99"
6-
reason: introduced in 8.0.0
5+
version: " - 8.0.99"
6+
reason: introduced in 8.1.0
77

88
- do:
99
indices.create:
@@ -13,6 +13,9 @@ setup:
1313
index:
1414
mode: time_series
1515
routing_path: [metricset, k8s.pod.uid]
16+
time_series:
17+
start_time: 2021-04-28T00:00:00Z
18+
end_time: 2021-04-29T00:00:00Z
1619
number_of_replicas: 0
1720
number_of_shards: 2
1821
mappings:

qa/multi-cluster-search/src/test/resources/rest-api-spec/test/remote_cluster/10_basic.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@
156156
---
157157
tsdb:
158158
- skip:
159-
version: " - 7.99.99"
160-
reason: introduced in 8.0.0
159+
version: " - 8.0.99"
160+
reason: introduced in 8.1.0
161161

162162
- do:
163163
indices.create:
@@ -167,6 +167,9 @@ tsdb:
167167
index:
168168
mode: time_series
169169
routing_path: [metricset, k8s.pod.uid]
170+
time_series:
171+
start_time: 2021-04-28T00:00:00Z
172+
end_time: 2021-04-29T00:00:00Z
170173
number_of_replicas: 0
171174
number_of_shards: 2
172175
mappings:

qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/IndexingIT.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.client.Response;
1616
import org.elasticsearch.client.ResponseException;
1717
import org.elasticsearch.common.Strings;
18+
import org.elasticsearch.common.time.DateUtils;
1819
import org.elasticsearch.common.xcontent.support.XContentMapValues;
1920
import org.elasticsearch.core.Booleans;
2021
import org.elasticsearch.index.mapper.DateFieldMapper;
@@ -322,6 +323,8 @@ private void createTsdbIndex() throws IOException {
322323
indexSpec.startObject("settings").startObject("index");
323324
indexSpec.field("mode", "time_series");
324325
indexSpec.array("routing_path", new String[] { "dim" });
326+
indexSpec.field("time_series.start_time", 1L);
327+
indexSpec.field("time_series.end_time", DateUtils.MAX_MILLIS_BEFORE_9999 - 1);
325328
indexSpec.endObject().endObject();
326329
createIndex.setJsonEntity(Strings.toString(indexSpec.endObject()));
327330
client().performRequest(createIndex);

qa/smoke-test-multinode/src/test/resources/rest-api-spec/test/smoke_test_multinode/20_tsdb_consistency.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
setup:
55
- skip:
6-
version: " - 7.99.99"
7-
reason: introduced in 8.0.0
6+
version: " - 8.0.99"
7+
reason: introduced in 8.1.0
88

99
- do:
1010
indices.create:
@@ -14,6 +14,9 @@ setup:
1414
index:
1515
mode: time_series
1616
routing_path: [metricset, k8s.pod.uid]
17+
time_series:
18+
start_time: 2021-04-28T00:00:00Z
19+
end_time: 2021-04-29T00:00:00Z
1720
number_of_shards: 10
1821
number_of_replicas: 1
1922
mappings:

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/10_settings.yml

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
enable:
22
- skip:
3-
version: " - 7.99.99"
4-
reason: introduced in 8.0.0
3+
version: " - 8.0.99"
4+
reason: introduced in 8.1.0
55

66
- do:
77
indices.create:
@@ -11,6 +11,9 @@ enable:
1111
index:
1212
mode: time_series
1313
routing_path: [metricset, k8s.pod.uid]
14+
time_series:
15+
start_time: 2021-04-28T00:00:00Z
16+
end_time: 2021-04-29T00:00:00Z
1417
number_of_replicas: 0
1518
number_of_shards: 2
1619
mappings:
@@ -41,8 +44,8 @@ enable:
4144
---
4245
no sort field:
4346
- skip:
44-
version: " - 7.99.99"
45-
reason: introduced in 8.0.0
47+
version: " - 8.0.99"
48+
reason: introduced in 8.1.0
4649

4750
- do:
4851
catch: /\[index.mode=time_series\] is incompatible with \[index.sort.field\]/
@@ -52,13 +55,17 @@ no sort field:
5255
settings:
5356
index:
5457
mode: time_series
58+
routing_path: foo
59+
time_series:
60+
start_time: 2021-04-28T00:00:00Z
61+
end_time: 2021-04-29T00:00:00Z
5562
sort.field: ['a']
5663

5764
---
5865
no sort order:
5966
- skip:
60-
version: " - 7.99.99"
61-
reason: introduced in 8.0.0
67+
version: " - 8.0.99"
68+
reason: introduced in 8.1.0
6269

6370
- do:
6471
catch: /\[index.mode=time_series\] is incompatible with \[index.sort.order\]/
@@ -68,13 +75,17 @@ no sort order:
6875
settings:
6976
index:
7077
mode: time_series
78+
routing_path: foo
79+
time_series:
80+
start_time: 2021-04-28T00:00:00Z
81+
end_time: 2021-04-29T00:00:00Z
7182
sort.order: ['DESC']
7283

7384
---
7485
no sort mode:
7586
- skip:
76-
version: " - 7.99.99"
77-
reason: introduced in 8.0.0
87+
version: " - 8.0.99"
88+
reason: introduced in 8.1.0
7889

7990
- do:
8091
catch: /\[index.mode=time_series\] is incompatible with \[index.sort.mode\]/
@@ -84,13 +95,17 @@ no sort mode:
8495
settings:
8596
index:
8697
mode: time_series
98+
routing_path: foo
99+
time_series:
100+
start_time: 2021-04-28T00:00:00Z
101+
end_time: 2021-04-29T00:00:00Z
87102
sort.mode: ['MIN']
88103

89104
---
90105
no sort missing:
91106
- skip:
92-
version: " - 7.99.99"
93-
reason: introduced in 8.0.0
107+
version: " - 8.0.99"
108+
reason: introduced in 8.1.0
94109

95110
- do:
96111
catch: /\[index.mode=time_series\] is incompatible with \[index.sort.missing\]/
@@ -100,13 +115,17 @@ no sort missing:
100115
settings:
101116
index:
102117
mode: time_series
118+
routing_path: foo
119+
time_series:
120+
start_time: 2021-04-28T00:00:00Z
121+
end_time: 2021-04-29T00:00:00Z
103122
sort.missing: ['_last']
104123

105124
---
106125
no partitioning:
107126
- skip:
108-
version: " - 7.99.99"
109-
reason: introduced in 8.0.0
127+
version: " - 8.0.99"
128+
reason: introduced in 8.1.0
110129

111130
- do:
112131
catch: /\[index.mode=time_series\] is incompatible with \[index.routing_partition_size\]/
@@ -116,14 +135,18 @@ no partitioning:
116135
settings:
117136
index:
118137
mode: time_series
138+
routing_path: foo
139+
time_series:
140+
start_time: 2021-04-28T00:00:00Z
141+
end_time: 2021-04-29T00:00:00Z
119142
shards: 5
120143
routing_partition_size: 2
121144

122145
---
123146
routing_path required:
124147
- skip:
125-
version: " - 7.99.99"
126-
reason: introduced in 8.0.0 to be backported to 7.16.0
148+
version: " - 8.0.99"
149+
reason: introduced in 8.1.0
127150

128151
- do:
129152
catch: /\[index.mode=time_series\] requires \[index.routing_path\]/
@@ -133,13 +156,16 @@ routing_path required:
133156
settings:
134157
index:
135158
mode: time_series
136-
shards: 5
159+
time_series:
160+
start_time: 2021-04-28T00:00:00Z
161+
end_time: 2021-04-29T00:00:00Z
162+
number_of_shards: 5
137163

138164
---
139165
routing_path is not allowed in standard mode:
140166
- skip:
141-
version: " - 7.99.99"
142-
reason: introduced in 8.0.0 to be backported to 7.16.0
167+
version: " - 8.0.99"
168+
reason: introduced in 8.1.0
143169

144170
- do:
145171
catch: /\[index.routing_path\] requires \[index.mode=time_series\]/
@@ -153,8 +179,8 @@ routing_path is not allowed in standard mode:
153179
---
154180
routing required:
155181
- skip:
156-
version: " - 7.99.99"
157-
reason: introduced in 8.0.0 to be backported to 7.16.0
182+
version: " - 8.0.99"
183+
reason: introduced in 8.1.0
158184

159185
- do:
160186
catch: /routing is forbidden on CRUD operations that target indices in \[index.mode=time_series\]/
@@ -165,6 +191,9 @@ routing required:
165191
index:
166192
mode: time_series
167193
routing_path: foo
194+
time_series:
195+
start_time: 2021-04-28T00:00:00Z
196+
end_time: 2021-04-29T00:00:00Z
168197
mappings:
169198
_routing:
170199
required: true

0 commit comments

Comments
 (0)