---
setup:
- skip:
    known_issues:
    - cluster_feature: "gte_v8.7.0"
      fixed_by: "gte_v8.10.0"
    reason: "Synthetic source shows up in the mapping in 8.10 and on, may trigger\
      \ assert failures in mixed cluster tests"
    features:
    - "headers"
    - "allowed_warnings_regex"
---
date:
- requires:
    cluster_features:
    - "gte_v8.2.0"
    reason: "tsdb indexing changed in 8.2.0"
- do:
    indices.create:
      index: "test"
      body:
        settings:
          index:
            mode: "time_series"
            routing_path:
            - "metricset"
            time_series:
              start_time: "2021-04-28T00:00:00Z"
              end_time: "2021-04-29T00:00:00Z"
            number_of_shards: 2
        mappings:
          properties:
            '@timestamp':
              type: "date"
            metricset:
              type: "keyword"
              time_series_dimension: true
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    indices.get_mapping:
      index: "test"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    test.mappings.properties.@timestamp.type: "date"
- match:
    test.mappings._data_stream_timestamp.enabled: true
- do:
    bulk:
      refresh: true
      index: "test_index"
      body:
      - "{\"index\": {}}"
      - "{\"@timestamp\": \"2021-04-28T18:50:04.467Z\", \"metricset\": \"pod\"}"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    search:
      index: "test_index"
      body:
        docvalue_fields:
        - "@timestamp"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    hits.total.value: 1
- match:
    hits.hits.0.fields.@timestamp:
    - "2021-04-28T18:50:04.467Z"
---
date_nanos:
- requires:
    cluster_features:
    - "gte_v8.2.0"
    reason: "tsdb indexing changed in 8.2.0"
- do:
    indices.create:
      index: "test"
      body:
        settings:
          index:
            mode: "time_series"
            routing_path:
            - "metricset"
            time_series:
              start_time: "2021-04-28T00:00:00Z"
              end_time: "2021-04-29T00:00:00Z"
            number_of_shards: 2
        mappings:
          properties:
            '@timestamp':
              type: "date_nanos"
            metricset:
              type: "keyword"
              time_series_dimension: true
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    indices.get_mapping:
      index: "test"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    test.mappings.properties.@timestamp.type: "date_nanos"
- match:
    test.mappings._data_stream_timestamp.enabled: true
- do:
    bulk:
      refresh: true
      index: "test_index"
      body:
      - "{\"index\": {}}"
      - "{\"@timestamp\": \"2021-04-28T18:50:04.467Z\", \"metricset\": \"pod\"}"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    search:
      index: "test_index"
      body:
        docvalue_fields:
        - "@timestamp"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    hits.total.value: 1
- match:
    hits.hits.0.fields.@timestamp:
    - "2021-04-28T18:50:04.467Z"
---
automatically add with date:
- requires:
    cluster_features:
    - "gte_v8.2.0"
    reason: "tsdb indexing changed in 8.2.0"
- do:
    indices.create:
      index: "test"
      body:
        settings:
          index:
            mode: "time_series"
            routing_path:
            - "metricset"
            time_series:
              start_time: "2021-04-28T00:00:00Z"
              end_time: "2021-04-29T00:00:00Z"
            number_of_shards: 2
        mappings:
          properties:
            metricset:
              type: "keyword"
              time_series_dimension: true
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    indices.get_mapping:
      index: "test"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    test.mappings.properties.@timestamp:
      type: "date"
- match:
    test.mappings._data_stream_timestamp.enabled: true
- do:
    bulk:
      refresh: true
      index: "test_index"
      body:
      - "{\"index\": {}}"
      - "{\"@timestamp\": \"2021-04-28T18:50:04.467Z\", \"metricset\": \"pod\"}"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    search:
      index: "test_index"
      body:
        docvalue_fields:
        - "@timestamp"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    hits.total.value: 1
- match:
    hits.hits.0.fields.@timestamp:
    - "2021-04-28T18:50:04.467Z"
---
reject @timestamp with wrong type:
- requires:
    cluster_features:
    - "gte_v8.1.0"
    reason: "introduced in 8.1.0"
- do:
    catch: "/data stream timestamp field \\[@timestamp\\] is of type \\[long\\], but\
      \ \\[date,date_nanos\\] is expected/"
    indices.create:
      index: "test"
      body:
        settings:
          index:
            mode: "time_series"
            routing_path:
            - "metricset"
            time_series:
              start_time: "2021-04-28T00:00:00Z"
              end_time: "2021-04-29T00:00:00Z"
            number_of_shards: 2
        mappings:
          properties:
            '@timestamp':
              type: "long"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
---
reject timestamp meta field with wrong type:
- requires:
    cluster_features:
    - "gte_v8.1.0"
    reason: "introduced in 8.1.0"
- do:
    catch: "/\\[_data_stream_timestamp\\] meta field has been disabled/"
    indices.create:
      index: "test"
      body:
        settings:
          index:
            mode: "time_series"
            routing_path:
            - "metricset"
            time_series:
              start_time: "2021-04-28T00:00:00Z"
              end_time: "2021-04-29T00:00:00Z"
            number_of_shards: 2
        mappings:
          _data_stream_timestamp:
            enabled: false
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
---
enable timestamp meta field:
- requires:
    cluster_features:
    - "gte_v8.1.0"
    reason: "introduced in 8.1.0"
- do:
    indices.create:
      index: "test"
      body:
        settings:
          index:
            mode: "time_series"
            routing_path:
            - "metricset"
            time_series:
              start_time: "2021-04-28T00:00:00Z"
              end_time: "2021-04-29T00:00:00Z"
            number_of_shards: 2
        mappings:
          _data_stream_timestamp:
            enabled: true
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    indices.get_mapping:
      index: "test"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    test.mappings.properties.@timestamp.type: "date"
- match:
    test.mappings._data_stream_timestamp.enabled: true
---
reject bad timestamp meta field:
- requires:
    cluster_features:
    - "gte_v8.1.0"
    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"
            time_series:
              start_time: "2021-04-28T00:00:00Z"
              end_time: "2021-04-29T00:00:00Z"
            number_of_shards: 2
        mappings:
          _data_stream_timestamp: "enabled"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
---
write without timestamp:
- requires:
    cluster_features:
    - "gte_v8.2.0"
    reason: "tsdb indexing changed in 8.2.0"
- do:
    indices.create:
      index: "test"
      body:
        settings:
          index:
            mode: "time_series"
            routing_path:
            - "metricset"
            time_series:
              start_time: "2021-04-28T00:00:00Z"
              end_time: "2021-04-29T00:00:00Z"
            number_of_shards: 2
        mappings:
          properties:
            '@timestamp':
              type: "date"
            metricset:
              type: "keyword"
              time_series_dimension: true
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    indices.get_mapping:
      index: "test"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    test.mappings.properties.@timestamp.type: "date"
- match:
    test.mappings._data_stream_timestamp.enabled: true
- do:
    catch: "/data stream timestamp field \\[@timestamp\\] is missing/"
    index:
      index: "test"
      body:
        metricset: "pod"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
---
explicitly enable timestamp meta field:
- requires:
    cluster_features:
    - "gte_v8.2.0"
    reason: "tsdb indexing changed in 8.2.0"
- do:
    indices.create:
      index: "test"
      body:
        settings:
          index:
            mode: "time_series"
            routing_path:
            - "metricset"
            time_series:
              start_time: "2021-04-28T00:00:00Z"
              end_time: "2021-04-29T00:00:00Z"
            number_of_shards: 2
        mappings:
          properties:
            '@timestamp':
              type: "date"
              meta:
                field_meta: "time_series"
            metricset:
              type: "keyword"
              time_series_dimension: true
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    index:
      refresh: true
      index: "test"
      body:
        '@timestamp': "2021-04-28T18:50:53.142Z"
        metricset: "pod"
        new_field: "value"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    search:
      index: "test"
      body:
        docvalue_fields:
        - "@timestamp"
        - "new_field.keyword"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    hits.total.value: 1
- match:
    hits.hits.0.fields.@timestamp:
    - "2021-04-28T18:50:53.142Z"
- match:
    hits.hits.0.fields.new_field\.keyword:
    - "value"
- do:
    indices.get_mapping:
      index: "test"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    test.mappings.properties.@timestamp.type: "date"
- match:
    test.mappings.properties.@timestamp.meta.field_meta: "time_series"
- match:
    test.mappings._data_stream_timestamp.enabled: true
---
unable to create a time series index with @timestamp runtime field:
- skip:
    awaits_fix: "error message changed when sort field shadow rejection was added"
- requires:
    cluster_features:
    - "gte_v8.2.0"
    reason: "tsdb indexing changed in 8.2.0"
- do:
    catch: "/docvalues not found for index sort field:\\[\\@timestamp\\]/"
    indices.create:
      index: "test_1"
      body:
        settings:
          number_of_shards: 1
          index:
            mode: "time_series"
            routing_path:
            - "metricset"
            - "k8s.pod.uid"
            time_series:
              start_time: "2021-04-28T00:00:00Z"
              end_time: "2021-04-29T00:00:00Z"
        mappings:
          runtime:
            '@timestamp':
              type: "date"
          properties:
            '@timestamp':
              type: "date"
            metricset:
              type: "keyword"
              time_series_dimension: true
            k8s:
              properties:
                pod:
                  properties:
                    uid:
                      type: "keyword"
                      time_series_dimension: true
                    name:
                      type: "keyword"
                    network:
                      properties:
                        tx:
                          type: "long"
                          time_series_metric: "gauge"
                        rx:
                          type: "long"
                          time_series_metric: "gauge"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
