Skip to content

Commit

Permalink
TSDB: move TimeSeriesModeIT to yaml tests (#80933)
Browse files Browse the repository at this point in the history
I move TimeSeriesModeIT to yaml tests.
I move the below lists to 15_timestamp_mapping.yml:
```
testTimestampMillis -> date
testTimestampNanos -> date_nanos
testAddsTimestamp -> automatically add with date
testBadTimestamp  -> reject @timestamp with wrong type
testDisabledTimeStampMapper -> reject timestamp meta field with wrong type
```

And add some tests in 15_timestamp_mapping.yml:
```
testBadTimeStampMapper  -> reject bad timestamp meta field
testWithoutTimestamp -> write without timestamp
testAddTimeStampMeta -> add timestamp meta
testEnabledTimeStampMapper -> enable timestamp meta field
```

AND move the below lists to 10_settings.yml:
```
testEnableTimestampRange ->  set start_time and end_time
```

And add some tests in 10_settings.yml:
```
testBadStartTime\testBadEndTime ->  set bad start_time and end_time
```
  • Loading branch information
weizijun authored Nov 23, 2021
1 parent 95c2c73 commit a6d5899
Show file tree
Hide file tree
Showing 3 changed files with 198 additions and 601 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ set start_time and end_time:
time_series:
start_time: 1632625782000
end_time: 1632625792000
mappings:
properties:
metricset:
type: keyword
time_series_dimension: true

- do:
indices.put_settings:
Expand All @@ -202,6 +207,23 @@ set start_time and end_time:
time_series:
end_time: 1632625792000

- do:
index:
refresh: true
index: test_index
body: {
"@timestamp": 1632625792000,
"metricset": "pod"
}

- do:
search:
index: test_index
body:
docvalue_fields: [ '@timestamp' ]
- match: { hits.total.value: 1 }
- match: { "hits.hits.0.fields.@timestamp": [ "2021-09-26T03:09:52.000Z" ] }

- do:
indices.delete:
index: test_index
Expand Down Expand Up @@ -231,6 +253,46 @@ set start_time and end_time without timeseries mode:
time_series:
end_time: 1632625782000

---
set bad start_time and end_time:
- skip:
version: " - 8.0.99"
reason: introduced in 8.1.0
- do:
indices.create:
index: test_index
body:
settings:
index:
mode: time_series
routing_path: [ metricset ]
time_series:
start_time: 1632625782000
end_time: 1632625792000
mappings:
properties:
metricset:
type: keyword
time_series_dimension: true

- do:
catch: /time series index @timestamp value \[2021-09-26T03:09:41Z\] must be larger than 2021-09-26T03:09:42Z/
index:
index: test_index
body: {
"@timestamp": 1632625781000,
"metricset": "pod"
}

- do:
catch: /time series index @timestamp value \[2021-09-26T03:09:53Z\] must be smaller than 2021-09-26T03:09:52Z/
index:
index: test_index
body: {
"@timestamp": 1632625793000,
"metricset": "pod"
}

---
check start_time and end_time with data_nano:
- skip:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ reject @timestamp with wrong type:
reject timestamp meta field with wrong type:
- skip:
version: " - 8.0.99"
reason: introduced in 8.0.0 to be backported to 7.16.0
reason: introduced in 8.1.0

- do:
catch: /\[_data_stream_timestamp\] meta field has been disabled/
Expand All @@ -177,3 +177,138 @@ reject timestamp meta field with wrong type:
mappings:
_data_stream_timestamp:
enabled: false

---
enable timestamp meta field:
- skip:
version: " - 8.0.99"
reason: introduced in 8.1.0

- do:
indices.create:
index: test
body:
settings:
index:
mode: time_series
routing_path: [metricset]
number_of_replicas: 0
number_of_shards: 2
mappings:
_data_stream_timestamp:
enabled: true

- do:
indices.get_mapping:
index: test
- match: { "[email protected]": date }
- match: { 'test.mappings._data_stream_timestamp.enabled': true }

---
reject bad timestamp meta field:
- skip:
version: " - 8.0.99"
reason: introduced in 8.1.0

- do:
catch: /\[_data_stream_timestamp\] config must be an object/
indices.create:
index: test
body:
settings:
index:
mode: time_series
routing_path: [metricset]
number_of_replicas: 0
number_of_shards: 2
mappings:
_data_stream_timestamp: enabled

---
write without timestamp:
- skip:
version: " - 8.0.99"
reason: introduced in 8.1.0

- do:
indices.create:
index: test
body:
settings:
index:
mode: time_series
routing_path: [metricset]
number_of_replicas: 0
number_of_shards: 2
mappings:
properties:
"@timestamp":
type: date
metricset:
type: keyword
time_series_dimension: true

- do:
indices.get_mapping:
index: test
- match: { "[email protected]": date }
- match: { 'test.mappings._data_stream_timestamp.enabled': true }

- do:
catch: /data stream timestamp field \[@timestamp\] is missing/
index:
index: test
body:
"metricset": "pod"

---
explicitly enable timestamp meta field:
- skip:
version: " - 8.0.99"
reason: introduced in 8.1.0

- do:
indices.create:
index: test
body:
settings:
index:
mode: time_series
routing_path: [metricset]
number_of_replicas: 0
number_of_shards: 2
mappings:
properties:
"@timestamp":
type: date
meta:
field_meta: time_series
metricset:
type: keyword
time_series_dimension: true

- do:
index:
refresh: true
index: test
body: {
"@timestamp": 1632625793000,
"metricset": "pod",
"new_field" : "value"
}

- do:
search:
index: test
body:
docvalue_fields: [ '@timestamp', 'new_field.keyword' ]
- match: { hits.total.value: 1 }
- match: { hits.hits.0.fields.@timestamp: [ "2021-09-26T03:09:53.000Z" ] }
- match: { hits.hits.0.fields.new_field\.keyword: [ "value" ] }

- do:
indices.get_mapping:
index: test
- match: { "[email protected]": date }
- match: { "[email protected]_meta": time_series }
- match: { 'test.mappings._data_stream_timestamp.enabled': true }
Loading

0 comments on commit a6d5899

Please sign in to comment.