---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
- do:
    indices.create:
      index: "index-source"
    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:
    headers:
      Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    ml.put_data_frame_analytics:
      id: "dfa-outlier-detection-job"
      body: "{\n  \"source\": { \"index\": \"index-source\" },\n  \"dest\": { \"index\"\
        : \"index-dest-od\" },\n  \"analysis\": {\"outlier_detection\": {}}\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_data_frame_analytics:
      id: "dfa-regression-job"
      body: "{\n  \"source\": { \"index\": \"index-source\" },\n  \"dest\": { \"index\"\
        : \"index-dest-r\" },\n  \"analysis\": { \"regression\": { \"dependent_variable\"\
        : \"dep_var\" } }\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_data_frame_analytics:
      id: "dfa-classification-job"
      body: "{\n  \"source\": { \"index\": \"index-source\" },\n  \"dest\": { \"index\"\
        : \"index-dest-c\" },\n  \"analysis\": { \"classification\": { \"dependent_variable\"\
        : \"dep_var\" } }\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 cat data frame analytics single job:
- do:
    cat.ml_data_frame_analytics:
      id: "dfa-outlier-detection-job"
    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:
    $body: "/ #id                               type                  create_time\
      \ state\n^ (dfa\\-outlier\\-detection\\-job \\s+ outlier_detection \\s+ [^\\\
      s]+ \\s+  stopped \\n)+  $/\n"
---
Test cat data frame analytics single job with header:
- do:
    cat.ml_data_frame_analytics:
      id: "dfa-outlier-detection-job"
      v: 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"
- match:
    $body: "/^  id                           \\s+ type              \\s+ create_time\
      \ \\s+ state   \\n\n   (dfa\\-outlier\\-detection\\-job \\s+ outlier_detection\
      \ \\s+ [^\\s]+      \\s+ stopped \\n)+  $/\n"
---
Test cat data frame analytics all jobs with header:
- do:
    cat.ml_data_frame_analytics:
      v: 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"
- match:
    $body: "/^  id                           \\s+ type              \\s+ create_time\
      \ \\s+ state   \\n\n   (dfa\\-classification\\-job     \\s+ classification \
      \   \\s+ [^\\s]+      \\s+ stopped \\n)+\n   (dfa\\-outlier\\-detection\\-job\
      \ \\s+ outlier_detection \\s+ [^\\s]+      \\s+ stopped \\n)+\n   (dfa\\-regression\\\
      -job         \\s+ regression        \\s+ [^\\s]+      \\s+ stopped \\n)+  $/\n"
---
Test cat data frame analytics all jobs with header and column selection:
- do:
    cat.ml_data_frame_analytics:
      v: true
      h: "id,t,s,p,source_index,dest_index"
    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:
    $body: "/^  id                           \\s+ t                 \\s+ s       \\\
      s+ p                                                         \\s+ source_index\
      \ \\s+ dest_index    \\n\n   (dfa\\-classification\\-job     \\s+ classification\
      \    \\s+ stopped \\s+ reindexing:0,loading_data:0,feature_selection:0,coarse_parameter_search:0,fine_tuning_parameters:0,final_training:0,writing_results:0,inference:0\
      \ \\s+ index-source \\s+ index-dest-c  \\n)+\n   (dfa\\-outlier\\-detection\\\
      -job \\s+ outlier_detection \\s+ stopped \\s+ reindexing:0,loading_data:0,computing_outliers:0,writing_results:0\
      \ \\s+ index-source \\s+ index-dest-od \\n)+\n   (dfa\\-regression\\-job   \
      \      \\s+ regression        \\s+ stopped \\s+ reindexing:0,loading_data:0,feature_selection:0,coarse_parameter_search:0,fine_tuning_parameters:0,final_training:0,writing_results:0,inference:0\
      \ \\s+ index-source \\s+ index-dest-r  \\n)+  $/\n"
