Skip to content

Commit

Permalink
replace
Browse files Browse the repository at this point in the history
  • Loading branch information
weizijun committed Nov 23, 2021
1 parent 564ff9d commit 8f1c4ae
Show file tree
Hide file tree
Showing 3 changed files with 198 additions and 599 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,15 @@ set start_time and end_time:
settings:
index:
mode: time_series
routing_path: [metricset]
routing_path: [ metricset ]
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 @@ -230,3 +252,43 @@ set start_time and end_time without timeseries mode:
index:
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 \[1632625781000\] must be larger than 1632625782000/
index:
index: test_index
body: {
"@timestamp": 1632625781000,
"metricset": "pod"
}

- do:
catch: /time series index @timestamp value \[1632625793000\] must be smaller than 1632625792000/
index:
index: test_index
body: {
"@timestamp": 1632625793000,
"metricset": "pod"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.0.0 to be backported to 7.16.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.0.0 to be backported to 7.16.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: " - 7.99.99"
reason: introduced in 8.0.0 to be backported to 7.16.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"

---
add timestamp meta:
- skip:
version: " - 7.99.99"
reason: introduced in 8.0.0 to be backported to 7.16.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 8f1c4ae

Please sign in to comment.