---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
---
aggregate_double_metric with time series mappings:
- requires:
    cluster_features:
    - "gte_v7.16.0"
    reason: "introduced in 7.16.0"
- do:
    indices.create:
      index: "test_index"
      body:
        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"
                    network:
                      properties:
                        tx:
                          type: "aggregate_metric_double"
                          metrics:
                          - "min"
                          - "max"
                          - "sum"
                          - "value_count"
                          default_metric: "max"
                          time_series_metric: "gauge"
                        rx:
                          type: "aggregate_metric_double"
                          metrics:
                          - "min"
                          - "max"
                          - "sum"
                          - "value_count"
                          default_metric: "max"
                          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:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
---
aggregate_double_metric with wrong time series mappings:
- requires:
    cluster_features:
    - "gte_v7.16.0"
    reason: "introduced in 7.16.0"
- do:
    catch: "/Unknown value \\[histogram\\] for field \\[time_series_metric\\] \\-\
      \ accepted values are \\[gauge\\]/"
    indices.create:
      index: "tsdb_index"
      body:
        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"
                    network:
                      properties:
                        tx:
                          type: "aggregate_metric_double"
                          metrics:
                          - "min"
                          - "max"
                          - "sum"
                          - "value_count"
                          default_metric: "max"
                          time_series_metric: "gauge"
                        rx:
                          type: "aggregate_metric_double"
                          metrics:
                          - "min"
                          - "max"
                          - "sum"
                          - "value_count"
                          default_metric: "max"
                          time_series_metric: "histogram"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
---
Field caps with tsdb:
- requires:
    cluster_features:
    - "gte_v8.8.0"
    reason: "Field caps fix in 8.9"
- do:
    indices.create:
      index: "tsdb-fieldcap"
      body:
        settings:
          mode: "time_series"
          routing_path:
          - "field1"
          time_series:
            start_time: "2000-01-01T00:00:00Z"
            end_time: "2099-12-31T23:59:59Z"
        mappings:
          properties:
            field1:
              type: "keyword"
              time_series_dimension: true
            field2:
              type: "long"
              time_series_metric: "gauge"
            field3:
              type: "scaled_float"
              scaling_factor: 100
              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:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    field_caps:
      index: "tsdb-fieldcap"
      fields: "field*"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    indices:
    - "tsdb-fieldcap"
- match:
    fields.field1.keyword.type: "keyword"
- match:
    fields.field3.scaled_float.type: "scaled_float"
- match:
    fields.field3.scaled_float.searchable: true
