---
setup:
- skip:
    features:
    - "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: "revert-model-snapshot"
      body: "{\n  \"job_id\":\"revert-model-snapshot\",\n  \"description\":\"Analysis\
        \ of response time by airline\",\n  \"analysis_config\" : {\n      \"bucket_span\"\
        : \"1h\",\n      \"detectors\" :[{\"function\":\"metric\",\"field_name\":\"\
        responsetime\",\"by_field_name\":\"airline\"}]\n  },\n  \"data_description\"\
        \ : {\n      \"time_field\":\"time\",\n      \"time_format\":\"yyyy-MM-dd\
        \ HH:mm:ssX\"\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"
---
Test revert model with invalid snapshotId:
- do:
    catch: "/resource_not_found_exception/"
    ml.revert_model_snapshot:
      job_id: "revert-model-snapshot"
      snapshot_id: "not_exist"
    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 with unknown job id:
- do:
    catch: "missing"
    ml.revert_model_snapshot:
      job_id: "non-existent-job"
      snapshot_id: "second"
    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"
