---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
---
Bulk indexing of monitoring data:
- skip:
    features:
    - "allowed_warnings_regex"
- do:
    allowed_warnings_regex:
    - "\\[xpack.monitoring.collection.enabled] setting was deprecated in Elasticsearch\
      \ and will be removed in a future release.*"
    - ".*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"
    cluster.put_settings:
      body:
        persistent:
          xpack.monitoring.collection.enabled: true
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
- do:
    monitoring.bulk:
      system_id: "kibana"
      system_api_version: "7"
      interval: "10s"
      body:
      - index:
          _type: "test_type"
      - avg-cpu:
          user: 13.26
          nice: 0.17
          system: 1.51
          iowait: 0.85
          idle: 84.2
      - index:
          _type: "test_type"
      - avg-cpu:
          user: 13.23
          nice: 0.17
          system: 1.51
          iowait: 0.85
          idle: 84.24
    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"
- is_false: "errors"
- do:
    indices.refresh: {}
    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:
    search:
      rest_total_hits_as_int: true
      index: ".monitoring-kibana-*"
      body:
        query:
          term:
            type: "test_type"
    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:
    hits.total: 2
- do:
    monitoring.bulk:
      system_id: "kibana"
      system_api_version: "7"
      interval: "123456ms"
      body:
      - "{\"index\": {\"_type\":\"default_type\"}}"
      - "{\"field_1\": \"value_1\"}"
      - "{\"index\": {\"_type\": \"custom_type\"}}"
      - "{\"field_1\": \"value_2\"}"
      - "{\"index\": {\"_type\":\"default_type\"}}"
      - "{\"field_1\": \"value_3\"}"
      - "{\"index\": {\"_index\": \"_data\", \"_type\": \"kibana\"}}"
      - "{\"field_1\": \"value_4\"}"
    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"
- is_false: "errors"
- do:
    indices.refresh: {}
    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:
    search:
      rest_total_hits_as_int: true
      index: ".monitoring-kibana-*"
      body:
        query:
          term:
            type: "default_type"
    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:
    hits.total: 2
- match:
    hits.hits.0._source.interval_ms: 123456
- match:
    hits.hits.1._source.interval_ms: 123456
- do:
    search:
      rest_total_hits_as_int: true
      index: ".monitoring-kibana-*"
      body:
        query:
          term:
            type: "custom_type"
    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:
    hits.total: 1
- match:
    hits.hits.0._source.interval_ms: 123456
- do:
    search:
      rest_total_hits_as_int: true
      index: ".monitoring-data-*"
    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:
    hits.total: 0
- do:
    monitoring.bulk:
      system_id: "kibana"
      system_api_version: "6"
      interval: "10000ms"
      body:
      - "{\"index\": {\"_type\": \"default_type\"}}"
      - "{\"field_1\": \"value_1\"}"
      - "{\"index\": {\"_type\": \"custom_type\"}}"
      - "{\"field_1\": \"value_2\"}"
      - "{\"index\": {\"_type\": \"default_type\"}}"
      - "{\"field_1\": \"value_3\"}"
      - "{\"index\": {\"_index\": \"_data\", \"_type\": \"kibana\"}}"
      - "{\"field_1\": \"value_4\"}"
    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"
- is_false: "errors"
- do:
    indices.refresh: {}
    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:
    search:
      rest_total_hits_as_int: true
      index: ".monitoring-kibana-*"
      body:
        query:
          term:
            type: "default_type"
    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:
    hits.total: 4
- do:
    search:
      rest_total_hits_as_int: true
      index: ".monitoring-kibana-*"
      body:
        query:
          term:
            type: "custom_type"
    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:
    hits.total: 2
- do:
    search:
      rest_total_hits_as_int: true
      index: ".monitoring-data-*"
    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:
    hits.total: 0
---
Bulk indexing of monitoring data on closed indices should throw an export exception:
- skip:
    features:
    - "allowed_warnings"
    - "allowed_warnings_regex"
- do:
    allowed_warnings_regex:
    - "\\[xpack.monitoring.collection.enabled] setting was deprecated in Elasticsearch\
      \ and will be removed in a future release.*"
    - ".*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"
    cluster.put_settings:
      body:
        persistent:
          xpack.monitoring.collection.enabled: true
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
- do:
    monitoring.bulk:
      system_id: "beats"
      system_api_version: "7"
      interval: "5s"
      body:
      - index:
          _type: "metric_beat"
      - modules:
          nginx: true
          mysql: false
      - index:
          _type: "file_beat"
      - file:
          path: "/var/log/dmesg"
          size: "31kb"
    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"
- is_false: "errors"
- do:
    indices.refresh: {}
    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:
    search:
      rest_total_hits_as_int: true
      index: ".monitoring-beats-*"
    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:
    hits.total: 2
- do:
    indices.close:
      index: ".monitoring-beats-*"
    allowed_warnings:
    - "the default value for the ?wait_for_active_shards parameter will change from\
      \ '0' to 'index-setting' in version 8; specify '?wait_for_active_shards=index-setting'\
      \ to adopt the future default behaviour, or '?wait_for_active_shards=0' to preserve\
      \ today's behaviour"
    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:
    catch: "/export_exception/"
    monitoring.bulk:
      system_id: "beats"
      system_api_version: "7"
      interval: "5s"
      body:
      - index:
          _type: "file_beat"
      - file:
          path: "/var/log/auth.log"
          size: "5kb"
    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"
