---
setup:
- skip:
    features:
    - "warnings"
    - "headers"
    - "allowed_warnings_regex"
- do:
    headers:
      Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    ml.put_job:
      job_id: "jobs-get-result-overall-buckets-60"
      body: "{\n  \"groups\": [ \"jobs-get-result-overall-buckets-group\"],\n  \"\
        analysis_config\" : {\n      \"bucket_span\": \"60m\",\n      \"detectors\"\
        \ :[{\"function\":\"metric\",\"field_name\":\"responsetime\",\"by_field_name\"\
        :\"airline\"}]\n  },\n  \"data_description\" : {\n      \"time_field\":\"\
        time\"\n  }\n}\n"
    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:
    headers:
      Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    ml.put_job:
      job_id: "jobs-get-result-overall-buckets-30"
      body: "{\n  \"groups\": [ \"jobs-get-result-overall-buckets-group\"],\n  \"\
        analysis_config\" : {\n      \"bucket_span\": \"30m\",\n      \"detectors\"\
        \ :[{\"function\":\"metric\",\"field_name\":\"responsetime\",\"by_field_name\"\
        :\"airline\"}]\n  },\n  \"data_description\" : {\n      \"time_field\":\"\
        time\"\n  }\n}\n"
    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:
    warnings:
    - "bucket_span 17m [1020s] is not an integral divisor of the number of seconds\
      \ in 1d [86400s]. This is now deprecated."
    headers:
      Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    ml.put_job:
      job_id: "jobs-get-result-overall-buckets-17"
      body: "{\n  \"groups\": [ \"jobs-get-result-overall-buckets-group\"],\n  \"\
        analysis_config\" : {\n      \"bucket_span\": \"17m\",\n      \"detectors\"\
        \ :[{\"function\":\"metric\",\"field_name\":\"responsetime\",\"by_field_name\"\
        :\"airline\"}],\n      \"model_prune_window\":\"34d\"\n  },\n  \"data_description\"\
        \ : {\n      \"time_field\":\"time\"\n  }\n}\n"
    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:
    headers:
      Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    index:
      index: ".ml-anomalies-shared-000001"
      id: "jobs-get-result-overall-buckets-60_1"
      body:
        job_id: "jobs-get-result-overall-buckets-60"
        result_type: "bucket"
        timestamp: "2016-06-01T00:00:00Z"
        anomaly_score: 30.0
        bucket_span: 3600
    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:
    headers:
      Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    index:
      index: ".ml-anomalies-shared-000001"
      id: "jobs-get-result-overall-buckets-60_2"
      body:
        job_id: "jobs-get-result-overall-buckets-60"
        result_type: "bucket"
        timestamp: "2016-06-01T01:00:00Z"
        anomaly_score: 0.0
        bucket_span: 3600
    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:
    headers:
      Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    index:
      index: ".ml-anomalies-shared-000001"
      id: "jobs-get-result-overall-buckets-60_3"
      body:
        job_id: "jobs-get-result-overall-buckets-60"
        result_type: "bucket"
        timestamp: "2016-06-01T02:00:00Z"
        anomaly_score: 20.0
        bucket_span: 3600
    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:
    headers:
      Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    index:
      index: ".ml-anomalies-shared-000001"
      id: "jobs-get-result-overall-buckets-30_1"
      body:
        job_id: "jobs-get-result-overall-buckets-30"
        result_type: "bucket"
        timestamp: "2016-06-01T01:00:00Z"
        anomaly_score: 0.0
        bucket_span: 1800
    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:
    headers:
      Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    index:
      index: ".ml-anomalies-shared-000001"
      id: "jobs-get-result-overall-buckets-30_2"
      body:
        job_id: "jobs-get-result-overall-buckets-30"
        result_type: "bucket"
        timestamp: "2016-06-01T02:00:00Z"
        anomaly_score: 10.0
        bucket_span: 1800
    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:
    headers:
      Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    index:
      index: ".ml-anomalies-shared-000001"
      id: "jobs-get-result-overall-buckets-30_3"
      body:
        job_id: "jobs-get-result-overall-buckets-30"
        result_type: "bucket"
        timestamp: "2016-06-01T02:30:00Z"
        anomaly_score: 40.0
        bucket_span: 1800
    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:
    headers:
      Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    index:
      index: ".ml-anomalies-shared-000001"
      id: "jobs-get-result-overall-buckets-17_1"
      body:
        job_id: "jobs-get-result-overall-buckets-17"
        result_type: "bucket"
        timestamp: "2016-06-01T01:00:00Z"
        anomaly_score: 0.0
        bucket_span: 1020
    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:
    headers:
      Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    index:
      index: ".ml-anomalies-shared-000001"
      id: "jobs-get-result-overall-buckets-17_2"
      body:
        job_id: "jobs-get-result-overall-buckets-17"
        result_type: "bucket"
        timestamp: "2016-06-01T02:08:00Z"
        anomaly_score: 1.0
        bucket_span: 1020
    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:
    headers:
      Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    index:
      index: ".ml-anomalies-shared-000001"
      id: "jobs-get-result-overall-buckets-17_3"
      body:
        job_id: "jobs-get-result-overall-buckets-17"
        result_type: "bucket"
        timestamp: "2016-06-01T02:25:00Z"
        anomaly_score: 0.0
        bucket_span: 1020
    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:
    headers:
      Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    index:
      index: ".ml-anomalies-shared-000001"
      id: "jobs-get-result-overall-buckets-17_4"
      body:
        job_id: "jobs-get-result-overall-buckets-17"
        result_type: "bucket"
        timestamp: "2016-06-01T02:42:00Z"
        anomaly_score: 60.0
        bucket_span: 1020
        is_interim: true
    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:
    headers:
      Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    indices.refresh:
      index: ".ml-anomalies-shared-000001"
    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"
---
Test overall buckets given missing job:
- do:
    catch: "missing"
    ml.get_overall_buckets:
      job_id: "missing-job"
    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"
---
Test overall buckets given non-matching expression and allow_no_match:
- do:
    ml.get_overall_buckets:
      job_id: "none-matching-*"
    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:
    count: 0
---
Test overall buckets given non-matching expression and not allow_no_match:
- skip:
    features:
    - "warnings"
- do:
    catch: "missing"
    ml.get_overall_buckets:
      job_id: "none-matching-*"
      allow_no_match: false
    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"
---
Test overall buckets given top_n is 0:
- do:
    catch: "/\\[topN\\] parameter must be positive, found \\[0\\]/"
    ml.get_overall_buckets:
      job_id: "jobs-get-result-overall-buckets-*"
      top_n: 0
    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"
---
Test overall buckets given top_n is negative:
- do:
    catch: "/\\[topN\\] parameter must be positive, found \\[-1\\]/"
    ml.get_overall_buckets:
      job_id: "jobs-get-result-overall-buckets-*"
      top_n: -1
    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"
---
Test overall buckets given default:
- do:
    ml.get_overall_buckets:
      job_id: "jobs-get-result-overall-buckets-*"
    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:
    count: 3
- match:
    overall_buckets.0.timestamp: 1464739200000
- match:
    overall_buckets.0.bucket_span: 3600
- match:
    overall_buckets.0.overall_score: 30.0
- length:
    overall_buckets.0.jobs: 1
- match:
    overall_buckets.0.jobs.0.job_id: "jobs-get-result-overall-buckets-60"
- match:
    overall_buckets.0.jobs.0.max_anomaly_score: 30.0
- match:
    overall_buckets.0.is_interim: false
- match:
    overall_buckets.0.result_type: "overall_bucket"
- match:
    overall_buckets.1.timestamp: 1464742800000
- match:
    overall_buckets.1.bucket_span: 3600
- match:
    overall_buckets.1.overall_score: 0.0
- length:
    overall_buckets.1.jobs: 3
- match:
    overall_buckets.1.jobs.0.job_id: "jobs-get-result-overall-buckets-17"
- match:
    overall_buckets.1.jobs.0.max_anomaly_score: 0.0
- match:
    overall_buckets.1.jobs.1.job_id: "jobs-get-result-overall-buckets-30"
- match:
    overall_buckets.1.jobs.1.max_anomaly_score: 0.0
- match:
    overall_buckets.1.jobs.2.job_id: "jobs-get-result-overall-buckets-60"
- match:
    overall_buckets.1.jobs.2.max_anomaly_score: 0.0
- match:
    overall_buckets.1.is_interim: false
- match:
    overall_buckets.1.result_type: "overall_bucket"
- match:
    overall_buckets.2.timestamp: 1464746400000
- match:
    overall_buckets.2.bucket_span: 3600
- match:
    overall_buckets.2.overall_score: 60.0
- length:
    overall_buckets.2.jobs: 3
- match:
    overall_buckets.2.jobs.0.job_id: "jobs-get-result-overall-buckets-17"
- match:
    overall_buckets.2.jobs.0.max_anomaly_score: 60.0
- match:
    overall_buckets.2.jobs.1.job_id: "jobs-get-result-overall-buckets-30"
- match:
    overall_buckets.2.jobs.1.max_anomaly_score: 40.0
- match:
    overall_buckets.2.jobs.2.job_id: "jobs-get-result-overall-buckets-60"
- match:
    overall_buckets.2.jobs.2.max_anomaly_score: 20.0
- match:
    overall_buckets.2.is_interim: true
- match:
    overall_buckets.2.result_type: "overall_bucket"
---
Test overall buckets given top_n is 2:
- do:
    ml.get_overall_buckets:
      job_id: "jobs-get-result-overall-buckets-group"
      top_n: 2
    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:
    count: 3
- match:
    overall_buckets.0.timestamp: 1464739200000
- match:
    overall_buckets.0.bucket_span: 3600
- match:
    overall_buckets.0.overall_score: 30.0
- length:
    overall_buckets.0.jobs: 1
- match:
    overall_buckets.0.jobs.0.job_id: "jobs-get-result-overall-buckets-60"
- match:
    overall_buckets.0.jobs.0.max_anomaly_score: 30.0
- match:
    overall_buckets.0.is_interim: false
- match:
    overall_buckets.0.result_type: "overall_bucket"
- match:
    overall_buckets.1.timestamp: 1464742800000
- match:
    overall_buckets.1.bucket_span: 3600
- match:
    overall_buckets.1.overall_score: 0.0
- length:
    overall_buckets.1.jobs: 3
- match:
    overall_buckets.1.jobs.0.job_id: "jobs-get-result-overall-buckets-17"
- match:
    overall_buckets.1.jobs.0.max_anomaly_score: 0.0
- match:
    overall_buckets.1.jobs.1.job_id: "jobs-get-result-overall-buckets-30"
- match:
    overall_buckets.1.jobs.1.max_anomaly_score: 0.0
- match:
    overall_buckets.1.jobs.2.job_id: "jobs-get-result-overall-buckets-60"
- match:
    overall_buckets.1.jobs.2.max_anomaly_score: 0.0
- match:
    overall_buckets.1.is_interim: false
- match:
    overall_buckets.1.result_type: "overall_bucket"
- match:
    overall_buckets.2.timestamp: 1464746400000
- match:
    overall_buckets.2.bucket_span: 3600
- match:
    overall_buckets.2.overall_score: 50.0
- length:
    overall_buckets.2.jobs: 3
- match:
    overall_buckets.2.jobs.0.job_id: "jobs-get-result-overall-buckets-17"
- match:
    overall_buckets.2.jobs.0.max_anomaly_score: 60.0
- match:
    overall_buckets.2.jobs.1.job_id: "jobs-get-result-overall-buckets-30"
- match:
    overall_buckets.2.jobs.1.max_anomaly_score: 40.0
- match:
    overall_buckets.2.jobs.2.job_id: "jobs-get-result-overall-buckets-60"
- match:
    overall_buckets.2.jobs.2.max_anomaly_score: 20.0
- match:
    overall_buckets.2.is_interim: true
- match:
    overall_buckets.2.result_type: "overall_bucket"
---
Test overall buckets given top_n is 3:
- do:
    ml.get_overall_buckets:
      job_id: "jobs-get-result-overall-buckets-group"
      top_n: 3
    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:
    count: 3
- match:
    overall_buckets.0.timestamp: 1464739200000
- match:
    overall_buckets.0.bucket_span: 3600
- match:
    overall_buckets.0.overall_score: 30.0
- length:
    overall_buckets.0.jobs: 1
- match:
    overall_buckets.0.jobs.0.job_id: "jobs-get-result-overall-buckets-60"
- match:
    overall_buckets.0.jobs.0.max_anomaly_score: 30.0
- match:
    overall_buckets.0.is_interim: false
- match:
    overall_buckets.0.result_type: "overall_bucket"
- match:
    overall_buckets.1.timestamp: 1464742800000
- match:
    overall_buckets.1.bucket_span: 3600
- match:
    overall_buckets.1.overall_score: 0.0
- length:
    overall_buckets.1.jobs: 3
- match:
    overall_buckets.1.jobs.0.job_id: "jobs-get-result-overall-buckets-17"
- match:
    overall_buckets.1.jobs.0.max_anomaly_score: 0.0
- match:
    overall_buckets.1.jobs.1.job_id: "jobs-get-result-overall-buckets-30"
- match:
    overall_buckets.1.jobs.1.max_anomaly_score: 0.0
- match:
    overall_buckets.1.jobs.2.job_id: "jobs-get-result-overall-buckets-60"
- match:
    overall_buckets.1.jobs.2.max_anomaly_score: 0.0
- match:
    overall_buckets.1.is_interim: false
- match:
    overall_buckets.1.result_type: "overall_bucket"
- match:
    overall_buckets.2.timestamp: 1464746400000
- match:
    overall_buckets.2.bucket_span: 3600
- match:
    overall_buckets.2.overall_score: 40.0
- length:
    overall_buckets.2.jobs: 3
- match:
    overall_buckets.2.jobs.0.job_id: "jobs-get-result-overall-buckets-17"
- match:
    overall_buckets.2.jobs.0.max_anomaly_score: 60.0
- match:
    overall_buckets.2.jobs.1.job_id: "jobs-get-result-overall-buckets-30"
- match:
    overall_buckets.2.jobs.1.max_anomaly_score: 40.0
- match:
    overall_buckets.2.jobs.2.job_id: "jobs-get-result-overall-buckets-60"
- match:
    overall_buckets.2.jobs.2.max_anomaly_score: 20.0
- match:
    overall_buckets.2.is_interim: true
- match:
    overall_buckets.2.result_type: "overall_bucket"
---
Test overall buckets given top_n is greater than the job count:
- do:
    ml.get_overall_buckets:
      job_id: "jobs-get-result-overall-buckets-*"
      top_n: 333
    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:
    count: 3
- match:
    overall_buckets.0.timestamp: 1464739200000
- match:
    overall_buckets.0.bucket_span: 3600
- match:
    overall_buckets.0.overall_score: 30.0
- length:
    overall_buckets.0.jobs: 1
- match:
    overall_buckets.0.jobs.0.job_id: "jobs-get-result-overall-buckets-60"
- match:
    overall_buckets.0.jobs.0.max_anomaly_score: 30.0
- match:
    overall_buckets.0.is_interim: false
- match:
    overall_buckets.0.result_type: "overall_bucket"
- match:
    overall_buckets.1.timestamp: 1464742800000
- match:
    overall_buckets.1.bucket_span: 3600
- match:
    overall_buckets.1.overall_score: 0.0
- length:
    overall_buckets.1.jobs: 3
- match:
    overall_buckets.1.jobs.0.job_id: "jobs-get-result-overall-buckets-17"
- match:
    overall_buckets.1.jobs.0.max_anomaly_score: 0.0
- match:
    overall_buckets.1.jobs.1.job_id: "jobs-get-result-overall-buckets-30"
- match:
    overall_buckets.1.jobs.1.max_anomaly_score: 0.0
- match:
    overall_buckets.1.jobs.2.job_id: "jobs-get-result-overall-buckets-60"
- match:
    overall_buckets.1.jobs.2.max_anomaly_score: 0.0
- match:
    overall_buckets.1.is_interim: false
- match:
    overall_buckets.1.result_type: "overall_bucket"
- match:
    overall_buckets.2.timestamp: 1464746400000
- match:
    overall_buckets.2.bucket_span: 3600
- match:
    overall_buckets.2.overall_score: 40.0
- length:
    overall_buckets.2.jobs: 3
- match:
    overall_buckets.2.jobs.0.job_id: "jobs-get-result-overall-buckets-17"
- match:
    overall_buckets.2.jobs.0.max_anomaly_score: 60.0
- match:
    overall_buckets.2.jobs.1.job_id: "jobs-get-result-overall-buckets-30"
- match:
    overall_buckets.2.jobs.1.max_anomaly_score: 40.0
- match:
    overall_buckets.2.jobs.2.job_id: "jobs-get-result-overall-buckets-60"
- match:
    overall_buckets.2.jobs.2.max_anomaly_score: 20.0
- match:
    overall_buckets.2.is_interim: true
- match:
    overall_buckets.2.result_type: "overall_bucket"
---
Test overall buckets given overall_score filter:
- do:
    ml.get_overall_buckets:
      job_id: "jobs-get-result-overall-buckets-*"
      top_n: 2
      overall_score: 50.0
    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:
    count: 1
- match:
    overall_buckets.0.timestamp: 1464746400000
- match:
    overall_buckets.0.overall_score: 50.0
---
Test overall buckets given exclude_interim:
- do:
    ml.get_overall_buckets:
      job_id: "jobs-get-result-overall-buckets-*"
      exclude_interim: true
    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:
    count: 3
- match:
    overall_buckets.0.timestamp: 1464739200000
- match:
    overall_buckets.0.bucket_span: 3600
- match:
    overall_buckets.0.overall_score: 30.0
- length:
    overall_buckets.0.jobs: 1
- match:
    overall_buckets.0.jobs.0.job_id: "jobs-get-result-overall-buckets-60"
- match:
    overall_buckets.0.jobs.0.max_anomaly_score: 30.0
- match:
    overall_buckets.0.is_interim: false
- match:
    overall_buckets.0.result_type: "overall_bucket"
- match:
    overall_buckets.1.timestamp: 1464742800000
- match:
    overall_buckets.1.bucket_span: 3600
- match:
    overall_buckets.1.overall_score: 0.0
- length:
    overall_buckets.1.jobs: 3
- match:
    overall_buckets.1.jobs.0.job_id: "jobs-get-result-overall-buckets-17"
- match:
    overall_buckets.1.jobs.0.max_anomaly_score: 0.0
- match:
    overall_buckets.1.jobs.1.job_id: "jobs-get-result-overall-buckets-30"
- match:
    overall_buckets.1.jobs.1.max_anomaly_score: 0.0
- match:
    overall_buckets.1.jobs.2.job_id: "jobs-get-result-overall-buckets-60"
- match:
    overall_buckets.1.jobs.2.max_anomaly_score: 0.0
- match:
    overall_buckets.1.is_interim: false
- match:
    overall_buckets.1.result_type: "overall_bucket"
- match:
    overall_buckets.2.timestamp: 1464746400000
- match:
    overall_buckets.2.bucket_span: 3600
- match:
    overall_buckets.2.overall_score: 40.0
- length:
    overall_buckets.2.jobs: 3
- match:
    overall_buckets.2.jobs.0.job_id: "jobs-get-result-overall-buckets-17"
- match:
    overall_buckets.2.jobs.0.max_anomaly_score: 1.0
- match:
    overall_buckets.2.jobs.1.job_id: "jobs-get-result-overall-buckets-30"
- match:
    overall_buckets.2.jobs.1.max_anomaly_score: 40.0
- match:
    overall_buckets.2.jobs.2.job_id: "jobs-get-result-overall-buckets-60"
- match:
    overall_buckets.2.jobs.2.max_anomaly_score: 20.0
- match:
    overall_buckets.2.is_interim: false
- match:
    overall_buckets.2.result_type: "overall_bucket"
---
Test overall buckets given string start and end params:
- do:
    ml.get_overall_buckets:
      job_id: "jobs-get-result-overall-buckets-*"
      top_n: 2
      start: "2016-06-01T00:30:00Z"
      end: "2016-06-01T02:30:00Z"
    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:
    count: 1
- match:
    overall_buckets.0.timestamp: 1464742800000
- match:
    overall_buckets.0.overall_score: 0.0
- length:
    overall_buckets.0.jobs: 3
---
Test overall buckets given epoch start and end params:
- do:
    ml.get_overall_buckets:
      job_id: "jobs-get-result-overall-buckets-*"
      top_n: 2
      start: 1464744600000
      end: 1464751800000
    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:
    count: 1
- match:
    overall_buckets.0.timestamp: 1464746400000
- match:
    overall_buckets.0.overall_score: 50.0
- length:
    overall_buckets.0.jobs: 3
- match:
    overall_buckets.0.jobs.0.job_id: "jobs-get-result-overall-buckets-17"
- match:
    overall_buckets.0.jobs.0.max_anomaly_score: 60.0
- match:
    overall_buckets.0.jobs.1.job_id: "jobs-get-result-overall-buckets-30"
- match:
    overall_buckets.0.jobs.1.max_anomaly_score: 40.0
- match:
    overall_buckets.0.jobs.2.job_id: "jobs-get-result-overall-buckets-60"
- match:
    overall_buckets.0.jobs.2.max_anomaly_score: 20.0
---
Test overall buckets given invalid start param:
- do:
    catch: "/.*Query param \\[start\\] with value \\[invalid\\] cannot be parsed as\
      \ a date or converted to a number.*/"
    ml.get_overall_buckets:
      job_id: "jobs-get-result-overall-buckets-*"
      start: "invalid"
    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"
---
Test overall buckets given invalid end param:
- do:
    catch: "/.*Query param \\[end\\] with value \\[invalid\\] cannot be parsed as\
      \ a date or converted to a number.*/"
    ml.get_overall_buckets:
      job_id: "jobs-get-result-overall-buckets-*"
      end: "invalid"
    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"
---
Test overall buckets given bucket_span:
- do:
    ml.get_overall_buckets:
      job_id: "jobs-get-result-overall-buckets-*"
      bucket_span: "2h"
    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:
    count: 2
- match:
    overall_buckets.0.timestamp: 1464739200000
- match:
    overall_buckets.0.bucket_span: 7200
- match:
    overall_buckets.0.overall_score: 30.0
- length:
    overall_buckets.0.jobs: 3
- match:
    overall_buckets.0.jobs.0.job_id: "jobs-get-result-overall-buckets-17"
- match:
    overall_buckets.0.jobs.0.max_anomaly_score: 0.0
- match:
    overall_buckets.0.jobs.1.job_id: "jobs-get-result-overall-buckets-30"
- match:
    overall_buckets.0.jobs.1.max_anomaly_score: 0.0
- match:
    overall_buckets.0.jobs.2.job_id: "jobs-get-result-overall-buckets-60"
- match:
    overall_buckets.0.jobs.2.max_anomaly_score: 30.0
- match:
    overall_buckets.0.is_interim: false
- match:
    overall_buckets.0.result_type: "overall_bucket"
- match:
    overall_buckets.1.timestamp: 1464746400000
- match:
    overall_buckets.1.bucket_span: 7200
- match:
    overall_buckets.1.overall_score: 60.0
- length:
    overall_buckets.1.jobs: 3
- match:
    overall_buckets.1.jobs.0.job_id: "jobs-get-result-overall-buckets-17"
- match:
    overall_buckets.1.jobs.0.max_anomaly_score: 60.0
- match:
    overall_buckets.1.jobs.1.job_id: "jobs-get-result-overall-buckets-30"
- match:
    overall_buckets.1.jobs.1.max_anomaly_score: 40.0
- match:
    overall_buckets.1.jobs.2.job_id: "jobs-get-result-overall-buckets-60"
- match:
    overall_buckets.1.jobs.2.max_anomaly_score: 20.0
- match:
    overall_buckets.1.is_interim: true
- match:
    overall_buckets.1.result_type: "overall_bucket"
---
Test overall buckets given bucket_span and top_n is 2:
- do:
    ml.get_overall_buckets:
      job_id: "jobs-get-result-overall-buckets-*"
      top_n: 2
      bucket_span: "2h"
    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:
    count: 2
- match:
    overall_buckets.0.timestamp: 1464739200000
- match:
    overall_buckets.0.bucket_span: 7200
- match:
    overall_buckets.0.overall_score: 30.0
- length:
    overall_buckets.0.jobs: 3
- match:
    overall_buckets.0.jobs.0.job_id: "jobs-get-result-overall-buckets-17"
- match:
    overall_buckets.0.jobs.0.max_anomaly_score: 0.0
- match:
    overall_buckets.0.jobs.1.job_id: "jobs-get-result-overall-buckets-30"
- match:
    overall_buckets.0.jobs.1.max_anomaly_score: 0.0
- match:
    overall_buckets.0.jobs.2.job_id: "jobs-get-result-overall-buckets-60"
- match:
    overall_buckets.0.jobs.2.max_anomaly_score: 30.0
- match:
    overall_buckets.0.is_interim: false
- match:
    overall_buckets.0.result_type: "overall_bucket"
- match:
    overall_buckets.1.timestamp: 1464746400000
- match:
    overall_buckets.1.bucket_span: 7200
- match:
    overall_buckets.1.overall_score: 50.0
- length:
    overall_buckets.1.jobs: 3
- match:
    overall_buckets.1.jobs.0.job_id: "jobs-get-result-overall-buckets-17"
- match:
    overall_buckets.1.jobs.0.max_anomaly_score: 60.0
- match:
    overall_buckets.1.jobs.1.job_id: "jobs-get-result-overall-buckets-30"
- match:
    overall_buckets.1.jobs.1.max_anomaly_score: 40.0
- match:
    overall_buckets.1.jobs.2.job_id: "jobs-get-result-overall-buckets-60"
- match:
    overall_buckets.1.jobs.2.max_anomaly_score: 20.0
- match:
    overall_buckets.1.is_interim: true
- match:
    overall_buckets.1.result_type: "overall_bucket"
---
Test overall buckets given bucket_span and overall_score filter:
- do:
    ml.get_overall_buckets:
      job_id: "jobs-get-result-overall-buckets-*"
      bucket_span: "2h"
      overall_score: 41.0
    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:
    count: 1
- match:
    overall_buckets.0.timestamp: 1464746400000
- match:
    overall_buckets.0.bucket_span: 7200
- match:
    overall_buckets.0.overall_score: 60.0
- length:
    overall_buckets.0.jobs: 3
- match:
    overall_buckets.0.jobs.0.job_id: "jobs-get-result-overall-buckets-17"
- match:
    overall_buckets.0.jobs.0.max_anomaly_score: 60.0
- match:
    overall_buckets.0.jobs.1.job_id: "jobs-get-result-overall-buckets-30"
- match:
    overall_buckets.0.jobs.1.max_anomaly_score: 40.0
- match:
    overall_buckets.0.jobs.2.job_id: "jobs-get-result-overall-buckets-60"
- match:
    overall_buckets.0.jobs.2.max_anomaly_score: 20.0
- match:
    overall_buckets.0.is_interim: true
- match:
    overall_buckets.0.result_type: "overall_bucket"
---
Test overall buckets given no matching jobs:
- do:
    ml.get_overall_buckets:
      job_id: "jobs-that-do-not-exist-*"
      bucket_span: "2h"
      overall_score: 41.0
      allow_no_match: true
    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:
    count: 0
- length:
    overall_buckets: 0
---
Test overall buckets given bucket_span is smaller than max job bucket_span:
- do:
    catch: "/.*Param \\[bucket_span\\] must be greater or equal to the max bucket_span\
      \ \\[60m\\]*/"
    ml.get_overall_buckets:
      job_id: "jobs-get-result-overall-buckets-*"
      bucket_span: "59m"
    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"
