---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
- requires:
    cluster_features:
    - "gte_v8.5.0"
    reason: "metric params only on time series indices introduced in 8.5.0"
- do:
    indices.create:
      index: "test_rollup"
      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"
        mappings:
          properties:
            '@timestamp':
              type: "date"
            metricset:
              type: "keyword"
              time_series_dimension: true
            metric:
              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"
- do:
    indices.create:
      index: "test_time_series"
      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"
        mappings:
          properties:
            '@timestamp':
              type: "date"
            metricset:
              type: "keyword"
              time_series_dimension: true
            metric:
              type: "double"
              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:
    indices.create:
      index: "test_non_time_series"
      body:
        mappings:
          properties:
            '@timestamp':
              type: "date"
            metricset:
              type: "keyword"
              time_series_dimension: true
            metric:
              type: "double"
              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:
    indices.create:
      index: "test_aggregate_metric"
      body:
        mappings:
          properties:
            metric:
              type: "aggregate_metric_double"
              metrics:
              - "min"
              - "max"
              - "value_count"
              default_metric: "max"
    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_metric on standard index:
- requires:
    cluster_features:
    - "gte_v8.5.0"
    reason: "aggregate_metric_double field caps changed in 8.5.0"
- do:
    field_caps:
      index: "test_aggregate_metric"
      fields:
      - "metric"
    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:
    fields.metric.aggregate_metric_double.searchable: true
- match:
    fields.metric.aggregate_metric_double.aggregatable: true
- is_false: "fields.metric.aggregate_metric_double.indices"
---
aggregate_metric on standard index conflict with double:
- requires:
    cluster_features:
    - "gte_v8.5.0"
    reason: "aggregate_metric_double field caps changed in 8.5.0"
- do:
    indices.create:
      index: "test_double"
      body:
        mappings:
          properties:
            metric:
              type: "double"
    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:
      - "test_double"
      - "test_aggregate_metric"
      fields:
      - "metric"
    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:
    fields.metric.aggregate_metric_double.searchable: true
- match:
    fields.metric.aggregate_metric_double.aggregatable: true
- match:
    fields.metric.aggregate_metric_double.indices:
    - "test_aggregate_metric"
- match:
    fields.metric.double.searchable: true
- match:
    fields.metric.double.aggregatable: true
- match:
    fields.metric.double.indices:
    - "test_double"
---
field caps on rollup indices:
- requires:
    cluster_features:
    - "gte_v8.5.0"
    reason: "metric params only on time series indices introduced in 8.5.0"
- do:
    field_caps:
      index: "test_rollup"
      fields:
      - "metric"
    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:
    fields.metric.aggregate_metric_double.type: "aggregate_metric_double"
- match:
    fields.metric.aggregate_metric_double.searchable: true
- match:
    fields.metric.aggregate_metric_double.aggregatable: true
- match:
    fields.metric.aggregate_metric_double.time_series_metric: "gauge"
- is_false: "fields.metric.aggregate_metric_double.indices"
- is_false: "fields.metric.aggregate_metric_double.non_searchable_indices"
- is_false: "fields.metric.aggregate_metric_double.non_aggregatable_indices"
- is_false: "fields.metric.aggregate_metric_double.metric_conflicts_indices"
- is_false: "fields.metric.double"
---
field caps on time series indices:
- requires:
    cluster_features:
    - "gte_v8.5.0"
    reason: "metric params only on time series indices introduced in 8.5.0"
- do:
    field_caps:
      index:
      - "test_time_series"
      - "test_rollup"
      fields:
      - "metric"
    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:
    fields.metric.double.type: "double"
- match:
    fields.metric.double.searchable: true
- match:
    fields.metric.double.aggregatable: true
- match:
    fields.metric.double.time_series_metric: "gauge"
- match:
    fields.metric.double.indices:
    - "test_time_series"
- is_false: "fields.metric.double.non_searchable_indices"
- is_false: "fields.metric.double.non_aggregatable_indices"
- is_false: "fields.metric.double.metric_conflicts_indices"
- match:
    fields.metric.aggregate_metric_double.type: "aggregate_metric_double"
- match:
    fields.metric.aggregate_metric_double.searchable: true
- match:
    fields.metric.aggregate_metric_double.aggregatable: true
- match:
    fields.metric.aggregate_metric_double.time_series_metric: "gauge"
- match:
    fields.metric.aggregate_metric_double.indices:
    - "test_rollup"
- is_false: "fields.metric.aggregate_metric_double.non_searchable_indices"
- is_false: "fields.metric.aggregate_metric_double.non_aggregatable_indices"
- is_false: "fields.metric.aggregate_metric_double.metric_conflicts_indices"
---
field caps on all indices:
- requires:
    cluster_features:
    - "gte_v8.5.0"
    reason: "metric params only on time series indices introduced in 8.5.0"
- do:
    field_caps:
      index:
      - "test_time_series"
      - "test_rollup"
      - "test_non_time_series"
      fields:
      - "metric"
    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:
    fields.metric.double.type: "double"
- match:
    fields.metric.double.searchable: true
- match:
    fields.metric.double.aggregatable: true
- match:
    fields.metric.double.indices:
    - "test_non_time_series"
    - "test_time_series"
- match:
    fields.metric.double.metric_conflicts_indices:
    - "test_non_time_series"
    - "test_time_series"
- is_false: "fields.metric.double.non_searchable_indices"
- is_false: "fields.metric.double.non_aggregatable_indices"
- is_false: "fields.metric.double.time_series_metric"
- match:
    fields.metric.aggregate_metric_double.type: "aggregate_metric_double"
- match:
    fields.metric.aggregate_metric_double.searchable: true
- match:
    fields.metric.aggregate_metric_double.aggregatable: true
- match:
    fields.metric.aggregate_metric_double.time_series_metric: "gauge"
- match:
    fields.metric.aggregate_metric_double.indices:
    - "test_rollup"
- is_false: "fields.metric.aggregate_metric_double.non_searchable_indices"
- is_false: "fields.metric.aggregate_metric_double.non_aggregatable_indices"
- is_false: "fields.metric.aggregate_metric_double.metric_conflicts_indices"
