---
setup:
- requires:
    cluster_features: "gte_v8.2.0"
    reason: "tsdb indexing changed in 8.2.0"
- 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"
    - "allowed_warnings_regex"
- do:
    indices.create:
      index: "test"
      body:
        settings:
          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"
            number_of_shards: 2
        mappings:
          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"
                    ip:
                      type: "ip"
                    network:
                      properties:
                        tx:
                          type: "long"
                        rx:
                          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"
- do:
    bulk:
      refresh: true
      index: "test"
      body:
      - "{\"index\": {}}"
      - "{\"@timestamp\": \"2021-04-28T18:50:04.467Z\", \"metricset\": \"pod\", \"\
        k8s\": {\"pod\": {\"name\": \"cat\", \"uid\":\"947e4ced-1786-4e53-9e0c-5c447e959507\"\
        , \"ip\": \"10.10.55.1\", \"network\": {\"tx\": 2001818691, \"rx\": 802133794}}}}"
      - "{\"index\": {}}"
      - "{\"@timestamp\": \"2021-04-28T18:50:24.467Z\", \"metricset\": \"pod\", \"\
        k8s\": {\"pod\": {\"name\": \"cat\", \"uid\":\"947e4ced-1786-4e53-9e0c-5c447e959507\"\
        , \"ip\": \"10.10.55.1\", \"network\": {\"tx\": 2005177954, \"rx\": 801479970}}}}"
      - "{\"index\": {}}"
      - "{\"@timestamp\": \"2021-04-28T18:50:44.467Z\", \"metricset\": \"pod\", \"\
        k8s\": {\"pod\": {\"name\": \"cat\", \"uid\":\"947e4ced-1786-4e53-9e0c-5c447e959507\"\
        , \"ip\": \"10.10.55.1\", \"network\": {\"tx\": 2006223737, \"rx\": 802337279}}}}"
      - "{\"index\": {}}"
      - "{\"@timestamp\": \"2021-04-28T18:51:04.467Z\", \"metricset\": \"pod\", \"\
        k8s\": {\"pod\": {\"name\": \"cat\", \"uid\":\"947e4ced-1786-4e53-9e0c-5c447e959507\"\
        , \"ip\": \"10.10.55.2\", \"network\": {\"tx\": 2012916202, \"rx\": 803685721}}}}"
      - "{\"index\": {}}"
      - "{\"@timestamp\": \"2021-04-28T18:50:03.142Z\", \"metricset\": \"pod\", \"\
        k8s\": {\"pod\": {\"name\": \"dog\", \"uid\":\"df3145b3-0563-4d3b-a0f7-897eb2876ea9\"\
        , \"ip\": \"10.10.55.3\", \"network\": {\"tx\": 1434521831, \"rx\": 530575198}}}}"
      - "{\"index\": {}}"
      - "{\"@timestamp\": \"2021-04-28T18:50:23.142Z\", \"metricset\": \"pod\", \"\
        k8s\": {\"pod\": {\"name\": \"dog\", \"uid\":\"df3145b3-0563-4d3b-a0f7-897eb2876ea9\"\
        , \"ip\": \"10.10.55.3\", \"network\": {\"tx\": 1434577921, \"rx\": 530600088}}}}"
      - "{\"index\": {}}"
      - "{\"@timestamp\": \"2021-04-28T18:50:53.142Z\", \"metricset\": \"pod\", \"\
        k8s\": {\"pod\": {\"name\": \"dog\", \"uid\":\"df3145b3-0563-4d3b-a0f7-897eb2876ea9\"\
        , \"ip\": \"10.10.55.3\", \"network\": {\"tx\": 1434587694, \"rx\": 530604797}}}}"
      - "{\"index\": {}}"
      - "{\"@timestamp\": \"2021-04-28T18:51:03.142Z\", \"metricset\": \"pod\", \"\
        k8s\": {\"pod\": {\"name\": \"dog\", \"uid\":\"df3145b3-0563-4d3b-a0f7-897eb2876ea9\"\
        , \"ip\": \"10.10.55.3\", \"network\": {\"tx\": 1434595272, \"rx\": 530605511}}}}"
    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"
---
index with routing:
- requires:
    cluster_features:
    - "gte_v8.2.0"
    reason: "tsdb indexing changed in 8.2.0"
- do:
    catch: "/specifying routing is not supported because the destination index \\\
      [test\\] is in time.series mode/"
    index:
      index: "test"
      routing: "foo"
      body:
        '@timestamp': "2021-04-28T18:35:24.467Z"
        metricset: "pod"
        k8s:
          pod:
            name: "cat"
            uid: "947e4ced-1786-4e53-9e0c-5c447e959507"
            ip: "10.10.55.1"
            network:
              tx: 2001818691
              rx: 802133794
    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"
---
index with routing over _bulk:
- requires:
    cluster_features:
    - "gte_v8.2.0"
    reason: "tsdb indexing changed in 8.2.0"
- do:
    bulk:
      refresh: true
      index: "test"
      body:
      - "{\"index\": {\"routing\": \"foo\"}}"
      - "{\"@timestamp\": \"2021-04-28T18:50:04.467Z\", \"metricset\": \"pod\", \"\
        k8s\": {\"pod\": {\"name\": \"cat\", \"uid\":\"947e4ced-1786-4e53-9e0c-5c447e959507\"\
        , \"ip\": \"10.10.55.1\", \"network\": {\"tx\": 2001818691, \"rx\": 802133794}}}}"
    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:
    items.0.index.error.reason: "/specifying\\ routing\\ is\\ not\\ supported\\ because\\\
      \ the\\ destination\\ index\\ \\[test\\]\\ is\\ in\\ time.series\\ mode/"
---
noop update:
- requires:
    cluster_features:
    - "gte_v8.2.0"
    reason: "tsdb indexing changed in 8.2.0"
- do:
    search:
      index: "test"
      size: 1
    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"
- length:
    hits.hits: 1
- do:
    catch: "/update is not supported because the destination index \\[test\\] is in\
      \ time.series mode/"
    update:
      index: "test"
      id: "1"
      body:
        doc: {}
    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"
---
regular update:
- requires:
    cluster_features:
    - "gte_v8.2.0"
    reason: "tsdb indexing changed in 8.2.0"
- do:
    catch: "/update is not supported because the destination index \\[test\\] is in\
      \ time.series mode/"
    update:
      index: "test"
      id: "1"
      body:
        doc:
          '@timestamp': "2021-04-28T18:35:24.467Z"
          metricset: "pod"
          k8s:
            pod:
              name: "cat"
              uid: "947e4ced-1786-4e53-9e0c-5c447e959507"
              ip: "10.10.55.1"
              network:
                tx: 2001818691
                rx: 802133794
    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"
---
update over _bulk:
- requires:
    cluster_features:
    - "gte_v8.2.0"
    reason: "tsdb indexing changed in 8.2.0"
- do:
    bulk:
      index: "test"
      body:
      - "{\"update\": {\"_id\": 1}}"
      - "{\"doc\":{\"@timestamp\": \"2021-04-28T18:03:24.467Z\", \"metricset\": \"\
        pod\", \"k8s\": {\"pod\": {\"name\": \"dog\", \"uid\":\"df3145b3-0563-4d3b-a0f7-897eb2876ea9\"\
        , \"ip\": \"10.10.55.3\", \"network\": {\"tx\": 1434595272, \"rx\": 530605511}}}}}"
    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:
    items.0.update.error.reason: "/update\\ is\\ not\\ supported\\ because\\ the\\\
      \ destination\\ index\\ \\[test\\]\\ is\\ in\\ time.series\\ mode/"
---
search with routing:
- requires:
    cluster_features:
    - "gte_v8.2.0"
    reason: "tsdb indexing changed in 8.2.0"
- do:
    catch: "/searching with a specified routing is not supported because the destination\
      \ index \\[test\\] is in time.series mode/"
    search:
      index: "test"
      routing: "rrrr"
    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"
---
alias with routing:
- requires:
    cluster_features:
    - "gte_v8.2.0"
    reason: "tsdb indexing changed in 8.2.0"
- do:
    catch: "/routing is forbidden on CRUD operations that target indices in \\[index.mode=time_series\\\
      ]/"
    indices.put_alias:
      index: "test"
      name: "alias"
      body:
        routing: "foo"
    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"
---
alias with search_routing:
- requires:
    cluster_features:
    - "gte_v8.2.0"
    reason: "tsdb indexing changed in 8.2.0"
- do:
    catch: "/routing is forbidden on CRUD operations that target indices in \\[index.mode=time_series\\\
      ]/"
    indices.put_alias:
      index: "test"
      name: "alias"
      body:
        search_routing: "foo"
    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"
---
sort by _id:
- requires:
    cluster_features:
    - "gte_v8.2.0"
    reason: "tsdb indexing changed in 8.2.0"
- do:
    catch: "/Fielddata is not supported on \\[_id\\] field in \\[time_series\\] indices/"
    search:
      index: "test"
      body:
        size: 1
        sort: "_id"
    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"
---
aggregate on _id:
- requires:
    cluster_features:
    - "gte_v8.2.0"
    reason: "tsdb indexing changed in 8.2.0"
- do:
    catch: "/Fielddata is not supported on \\[_id\\] field in \\[time_series\\] indices/"
    search:
      index: "test"
      body:
        size: 1
        aggs:
          id:
            terms:
              field: "_id"
    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"
