---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
- do:
    indices.create:
      index: "airline-data"
      body:
        mappings:
          properties:
            time:
              type: "date"
            airline:
              type: "keyword"
            responsetime:
              type: "float"
            event_rate:
              type: "integer"
    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 get all transforms when there are none:
- do:
    transform.get_transform:
      transform_id: "*"
    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
- match:
    transforms: []
- do:
    catch: "missing"
    transform.get_transform:
      transform_id: "*"
      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 get transform when it does not exist:
- do:
    catch: "/Transform with id \\[missing-transform-id\\] could not be found/"
    transform.get_transform:
      transform_id: "missing-transform-id"
    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 delete transform when it does not exist:
- do:
    catch: "missing"
    transform.delete_transform:
      transform_id: "missing transform"
    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 put transform with frequency too low:
- do:
    catch: "/minimum permitted \\[frequency\\] is \\[1s\\]/"
    transform.put_transform:
      transform_id: "frequency-too-low"
      body: "{\n  \"source\": { \"index\": \"airline-data\" },\n  \"dest\": { \"index\"\
        : \"airline-dest\" },\n  \"frequency\": \"999ms\",\n  \"pivot\": {\n    \"\
        group_by\": { \"airline\": {\"terms\": {\"field\": \"airline\"}}},\n    \"\
        aggs\": {\"avg_response\": {\"avg\": {\"field\": \"responsetime\"}}}\n  }\n\
        }\n"
    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 put transform with frequency too high:
- do:
    catch: "/highest permitted \\[frequency\\] is \\[1h\\]/"
    transform.put_transform:
      transform_id: "frequency-too-low"
      body: "{\n  \"source\": { \"index\": \"airline-data\" },\n  \"dest\": { \"index\"\
        : \"airline-dest\" },\n  \"frequency\": \"3600001ms\",\n  \"pivot\": {\n \
        \   \"group_by\": { \"airline\": {\"terms\": {\"field\": \"airline\"}}},\n\
        \    \"aggs\": {\"avg_response\": {\"avg\": {\"field\": \"responsetime\"}}}\n\
        \  }\n}\n"
    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 put transform with invalid source index:
- do:
    catch: "/.*Validation Failed.* no such index \\[missing-index\\]/"
    transform.put_transform:
      transform_id: "missing-source-transform"
      body: "{\n  \"source\": { \"index\": \"missing-index\" },\n  \"dest\": { \"\
        index\": \"missing-source-dest\" },\n  \"pivot\": {\n    \"group_by\": { \"\
        airline\": {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"avg_response\"\
        : {\"avg\": {\"field\": \"responsetime\"}}}\n  }\n}\n"
    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:
    transform.put_transform:
      transform_id: "missing-source-transform"
      defer_validation: true
      body: "{\n  \"source\": { \"index\": \"missing-index\" },\n  \"dest\": { \"\
        index\": \"missing-source-dest\" },\n  \"pivot\": {\n    \"group_by\": { \"\
        airline\": {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"avg_response\"\
        : {\"avg\": {\"field\": \"responsetime\"}}}\n  }\n}\n"
    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:
    acknowledged: true
---
Test put transform with invalid source index pattern:
- do:
    transform.put_transform:
      transform_id: "missing-source-transform-pattern"
      body: "{\n  \"source\": { \"index\": \"missing-index*\" },\n  \"dest\": { \"\
        index\": \"missing-source-dest\" },\n  \"pivot\": {\n    \"group_by\": { \"\
        airline\": {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"avg_response\"\
        : {\"avg\": {\"field\": \"responsetime\"}}}\n  }\n}\n"
    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:
    acknowledged: true
- do:
    transform.update_transform:
      transform_id: "missing-source-transform-pattern"
      body: "{\n  \"description\": \"updated description\"\n}\n"
    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:
    id: "missing-source-transform-pattern"
- match:
    description: "updated description"
- do:
    transform.start_transform:
      transform_id: "missing-source-transform-pattern"
    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:
    acknowledged: true
---
Test basic transform crud:
- do:
    transform.put_transform:
      transform_id: "airline-transform"
      body: "{\n  \"source\": { \"index\": \"airline-data\" },\n  \"dest\": { \"index\"\
        : \"airline-data-by-airline\" },\n  \"pivot\": {\n    \"group_by\": { \"airline\"\
        : {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"avg_response\"\
        : {\"avg\": {\"field\": \"responsetime\"}}}\n  },\n  \"description\": \"yaml\
        \ test transform on airline-data\"\n}\n"
    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:
    acknowledged: true
- do:
    ingest.put_pipeline:
      id: "airline-pipeline"
      body: "{\n  \"processors\": [\n    {\n      \"set\" : {\n        \"field\" :\
        \ \"some_field\",\n        \"value\" : 42\n      }\n    }\n  ]\n}\n"
    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:
    acknowledged: true
- do:
    transform.put_transform:
      transform_id: "airline-transform-dos"
      body: "{\n  \"source\": { \"index\": \"airline-data\" },\n  \"dest\": { \"index\"\
        : \"airline-data-by-airline-again\", \"pipeline\": \"airline-pipeline\" },\n\
        \  \"pivot\": {\n    \"group_by\": { \"airline\": {\"terms\": {\"field\":\
        \ \"airline\"}}},\n    \"aggs\": {\"avg_response\": {\"avg\": {\"field\":\
        \ \"responsetime\"}}}\n  }\n}\n"
    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:
    acknowledged: true
- do:
    transform.get_transform:
      transform_id: "airline-transform"
    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:
    transforms.0.id: "airline-transform"
- match:
    transforms.0.source.index.0: "airline-data"
- match:
    transforms.0.dest.index: "airline-data-by-airline"
- is_true: "transforms.0.source.query.match_all"
- is_true: "transforms.0.create_time"
- is_true: "transforms.0.version"
- match:
    transforms.0.pivot.group_by.airline.terms.field: "airline"
- match:
    transforms.0.pivot.aggregations.avg_response.avg.field: "responsetime"
- match:
    transforms.0.description: "yaml test transform on airline-data"
- is_true: "transforms.0.authorization.roles"
- do:
    transform.get_transform:
      transform_id: "*"
    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:
    transforms.0.id: "airline-transform"
- match:
    transforms.1.id: "airline-transform-dos"
- is_false: "transforms.1.description"
- do:
    transform.get_transform:
      transform_id: "_all"
    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:
    transforms.0.id: "airline-transform"
- match:
    transforms.1.id: "airline-transform-dos"
- do:
    transform.get_transform:
      transform_id: "airline-transform,airline-transform-dos"
    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:
    transforms.0.id: "airline-transform"
- match:
    transforms.1.id: "airline-transform-dos"
- is_true: "transforms.0.authorization.roles"
- is_true: "transforms.1.authorization.roles"
- do:
    transform.get_transform:
      transform_id: "airline-transform*"
    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:
    transforms.0.id: "airline-transform"
- match:
    transforms.1.id: "airline-transform-dos"
- do:
    transform.get_transform:
      transform_id: "airline-transform*"
      from: 0
      size: 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"
- match:
    count: 2
- match:
    transforms.0.id: "airline-transform"
- do:
    transform.get_transform:
      transform_id: "airline-transform*"
      from: 1
      size: 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"
- match:
    count: 2
- match:
    transforms.0.id: "airline-transform-dos"
---
Test transform with query and array of indices in source:
- do:
    indices.create:
      index: "airline-data-other"
      body:
        mappings:
          properties:
            time:
              type: "date"
            airline:
              type: "keyword"
            responsetime:
              type: "float"
            event_rate:
              type: "integer"
    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:
    transform.put_transform:
      transform_id: "airline-transform"
      body: "{\n  \"source\": {\n    \"index\": [\"airline-data\", \"airline-data-other\"\
        ],\n    \"query\": {\"bool\":{\"filter\":{\"term\":{\"airline\":\"FOO\"}}}}\n\
        \  },\n  \"dest\": { \"index\": \"airline-data-by-airline\" },\n  \"pivot\"\
        : {\n    \"group_by\": { \"airline\": {\"terms\": {\"field\": \"airline\"\
        }}},\n    \"aggs\": {\"avg_response\": {\"avg\": {\"field\": \"responsetime\"\
        }}}\n  }\n}\n"
    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:
    acknowledged: true
- do:
    transform.get_transform:
      transform_id: "airline-transform"
    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:
    transforms.0.id: "airline-transform"
- match:
    transforms.0.source.index.0: "airline-data"
- match:
    transforms.0.source.index.1: "airline-data-other"
- match:
    transforms.0.source.query.bool.filter.term.airline: "FOO"
- match:
    transforms.0.dest.index: "airline-data-by-airline"
- match:
    transforms.0.pivot.group_by.airline.terms.field: "airline"
- match:
    transforms.0.pivot.aggregations.avg_response.avg.field: "responsetime"
---
Test PUT continuous transform:
- do:
    transform.put_transform:
      transform_id: "airline-transform-continuous"
      body: "{\n  \"source\": {\n    \"index\": \"airline-data\"\n  },\n  \"dest\"\
        : { \"index\": \"airline-data-by-airline-continuous\" },\n  \"pivot\": {\n\
        \    \"group_by\": { \"airline\": {\"terms\": {\"field\": \"airline\"}}},\n\
        \    \"aggs\": {\"avg_response\": {\"avg\": {\"field\": \"responsetime\"}}}\n\
        \  },\n  \"sync\": {\n    \"time\": {\n      \"field\": \"time\",\n      \"\
        delay\": \"90m\"\n    }\n  }\n}\n"
    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:
    acknowledged: true
- do:
    transform.get_transform:
      transform_id: "airline-transform-continuous"
    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:
    transforms.0.id: "airline-transform-continuous"
- match:
    transforms.0.source.index.0: "airline-data"
- match:
    transforms.0.dest.index: "airline-data-by-airline-continuous"
- match:
    transforms.0.pivot.group_by.airline.terms.field: "airline"
- match:
    transforms.0.pivot.aggregations.avg_response.avg.field: "responsetime"
- match:
    transforms.0.sync.time.field: "time"
- match:
    transforms.0.sync.time.delay: "90m"
- is_true: "transforms.0.authorization.roles"
---
Test PUT continuous transform without delay set:
- do:
    transform.put_transform:
      transform_id: "airline-transform-continuous"
      body: "{\n  \"source\": {\n    \"index\": \"airline-data\"\n  },\n  \"dest\"\
        : { \"index\": \"airline-data-by-airline-continuous\" },\n  \"pivot\": {\n\
        \    \"group_by\": { \"airline\": {\"terms\": {\"field\": \"airline\"}}},\n\
        \    \"aggs\": {\"avg_response\": {\"avg\": {\"field\": \"responsetime\"}}}\n\
        \  },\n  \"sync\": {\n    \"time\": {\n      \"field\": \"time\"\n    }\n\
        \  }\n}\n"
    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:
    acknowledged: true
- do:
    transform.get_transform:
      transform_id: "airline-transform-continuous"
    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:
    transforms.0.id: "airline-transform-continuous"
- match:
    transforms.0.source.index.0: "airline-data"
- match:
    transforms.0.dest.index: "airline-data-by-airline-continuous"
- match:
    transforms.0.pivot.group_by.airline.terms.field: "airline"
- match:
    transforms.0.pivot.aggregations.avg_response.avg.field: "responsetime"
- match:
    transforms.0.sync.time.field: "time"
- match:
    transforms.0.sync.time.delay: "60s"
---
Test transform with invalid page parameter:
- do:
    catch: "/Param \\[size\\] has a max acceptable value of \\[1000\\]/"
    transform.get_transform:
      transform_id: "_all"
      from: 0
      size: 10000
    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 transform where dest is included in source:
- do:
    catch: "/Destination index \\[airline-data-by-airline\\] is included in source\
      \ expression \\[airline-data/"
    transform.put_transform:
      transform_id: "airline-transform"
      body: "{\n  \"source\": {\n    \"index\": [\"airline-data*\"]\n  },\n  \"dest\"\
        : { \"index\": \"airline-data-by-airline\" },\n  \"pivot\": {\n    \"group_by\"\
        : { \"airline\": {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"\
        avg_response\": {\"avg\": {\"field\": \"responsetime\"}}}\n  }\n}\n"
    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:
    transform.put_transform:
      transform_id: "airline-transform"
      defer_validation: true
      body: "{\n  \"source\": {\n    \"index\": [\"airline-data*\"]\n  },\n  \"dest\"\
        : { \"index\": \"airline-data-by-airline\" },\n  \"pivot\": {\n    \"group_by\"\
        : { \"airline\": {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"\
        avg_response\": {\"avg\": {\"field\": \"responsetime\"}}}\n  }\n}\n"
    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 transform where source query is invalid:
- do:
    catch: "/The mapper type \\[bad-type\\] declared on runtime field \\[rt-field\\\
      ]/"
    transform.put_transform:
      transform_id: "airline-transform"
      body: "{\n  \"source\": {\n    \"index\": [\"airline-data*\"],\n    \"runtime_mappings\"\
        : {\"rt-field\":{\"type\": \"bad-type\"}}\n  },\n  \"dest\": { \"index\":\
        \ \"dest-airline-data-by-airline\" },\n  \"pivot\": {\n    \"group_by\": {\
        \ \"airline\": {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"\
        avg_response\": {\"avg\": {\"field\": \"responsetime\"}}}\n  }\n}\n"
    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:
    transform.put_transform:
      transform_id: "airline-transform"
      defer_validation: true
      body: "{\n  \"source\": {\n    \"index\": [\"airline-data*\"],\n    \"runtime_mappings\"\
        : {\"rt-field\":{\"type\": \"bad-type\"}}\n  },\n  \"dest\": { \"index\":\
        \ \"dest-airline-data-by-airline\" },\n  \"pivot\": {\n    \"group_by\": {\
        \ \"airline\": {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"\
        avg_response\": {\"avg\": {\"field\": \"responsetime\"}}}\n  }\n}\n"
    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:
    acknowledged: true
---
Test alias scenarios:
- do:
    indices.create:
      index: "created-destination-index"
    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: "second-created-destination-index"
    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.put_alias:
      index: "airline-data"
      name: "source-index"
    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.put_alias:
      index: "created-destination-index"
      name: "dest-index"
    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:
    transform.put_transform:
      transform_id: "transform-from-aliases"
      body: "{\n  \"source\": {\n    \"index\": \"source-index\"\n  },\n  \"dest\"\
        : { \"index\": \"dest-index\" },\n  \"pivot\": {\n    \"group_by\": { \"airline\"\
        : {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"avg_response\"\
        : {\"avg\": {\"field\": \"responsetime\"}}}\n  }\n}\n"
    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:
    acknowledged: true
- do:
    indices.put_alias:
      index: "created-destination-index"
      name: "source-index"
    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: "/.*Validation Failed.* Destination index \\[created-destination-index\\\
      ] is included in source expression \\[airline-data,created-destination-index\\\
      ]/"
    transform.put_transform:
      transform_id: "transform-from-aliases-failures"
      body: "{\n  \"source\": {\n    \"index\": \"source-index\"\n  },\n  \"dest\"\
        : { \"index\": \"dest-index\" },\n  \"pivot\": {\n    \"group_by\": { \"airline\"\
        : {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"avg_response\"\
        : {\"avg\": {\"field\": \"responsetime\"}}}\n  }\n}\n"
    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.delete_alias:
      index: "created-destination-index"
      name: "source-index"
    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.put_alias:
      index: "second-created-destination-index"
      name: "dest-index"
    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: "/.*Validation Failed.* no write index is defined for alias [dest2-index].*/"
    transform.put_transform:
      transform_id: "airline-transform"
      body: "{\n  \"source\": {\n    \"index\": [\"source-index\"]\n  },\n  \"dest\"\
        : { \"index\": \"dest-index\" },\n  \"pivot\": {\n    \"group_by\": { \"airline\"\
        : {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"avg_response\"\
        : {\"avg\": {\"field\": \"responsetime\"}}}\n  }\n}\n"
    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 put config with invalid pivot size:
- do:
    catch: "/pivot\\.max_page_search_size \\[5\\] is out of range. The minimum value\
      \ is 10 and the maximum is 65536/"
    transform.put_transform:
      transform_id: "airline-transform"
      body: "{\n  \"source\": { \"index\": \"airline-data\" },\n  \"dest\": { \"index\"\
        : \"airline-dest-index\" },\n  \"pivot\": {\n    \"max_page_search_size\"\
        : 5,\n    \"group_by\": { \"airline\": {\"terms\": {\"field\": \"airline\"\
        }}},\n    \"aggs\": {\"avg_response\": {\"avg\": {\"field\": \"responsetime\"\
        }}}\n  }\n}\n"
    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: "/pivot\\.max_page_search_size \\[75000\\] is out of range. The minimum\
      \ value is 10 and the maximum is 65536/"
    transform.put_transform:
      transform_id: "airline-transform"
      body: "{\n  \"source\": { \"index\": \"airline-data\" },\n  \"dest\": { \"index\"\
        : \"airline-dest-index\" },\n  \"pivot\": {\n    \"max_page_search_size\"\
        : 75000,\n    \"group_by\": { \"airline\": {\"terms\": {\"field\": \"airline\"\
        }}},\n    \"aggs\": {\"avg_response\": {\"avg\": {\"field\": \"responsetime\"\
        }}}\n  }\n}\n"
    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 put config with invalid number of failure retries:
- do:
    catch: "/settings\\.num_failure_retries \\[-2\\] is out of range. The minimum\
      \ value is -1 \\(infinity\\) and the maximum is 100/"
    transform.put_transform:
      transform_id: "airline-transform"
      body: "{\n  \"source\": { \"index\": \"airline-data\" },\n  \"dest\": { \"index\"\
        : \"airline-dest-index\" },\n  \"pivot\": {\n    \"group_by\": { \"airline\"\
        : {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"avg_response\"\
        : {\"avg\": {\"field\": \"responsetime\"}}}\n  },\n  \"settings\": {\n   \
        \ \"num_failure_retries\": -2\n  }\n}\n"
    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: "/settings\\.num_failure_retries \\[101\\] is out of range. The minimum\
      \ value is -1 \\(infinity\\) and the maximum is 100/"
    transform.put_transform:
      transform_id: "airline-transform"
      body: "{\n  \"source\": { \"index\": \"airline-data\" },\n  \"dest\": { \"index\"\
        : \"airline-dest-index\" },\n  \"pivot\": {\n    \"group_by\": { \"airline\"\
        : {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"avg_response\"\
        : {\"avg\": {\"field\": \"responsetime\"}}}\n  },\n  \"settings\": {\n   \
        \ \"num_failure_retries\": 101\n  }\n}\n"
    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 creation failures due to duplicate and conflicting field names:
- do:
    catch: "/duplicate field \\[airline\\] detected/"
    transform.put_transform:
      transform_id: "duplicate-field-transform"
      body: "{\n  \"source\": {\n    \"index\": \"source-index\"\n  },\n  \"dest\"\
        : { \"index\": \"dest-index\" },\n  \"pivot\": {\n    \"group_by\": { \"airline\"\
        : {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"airline\": {\"\
        avg\": {\"field\": \"responsetime\"}}}\n  }\n}\n"
    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: "/field \\[airline\\] cannot be both an object and a field/"
    transform.put_transform:
      transform_id: "duplicate-field-transform"
      body: "{\n  \"source\": {\n    \"index\": \"source-index\"\n  },\n  \"dest\"\
        : { \"index\": \"dest-index\" },\n  \"pivot\": {\n    \"group_by\": { \"airline\"\
        : {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"airline.responsetime\"\
        : {\"avg\": {\"field\": \"responsetime\"}}}\n  }\n}\n"
    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 invalid transform id:
- do:
    catch: "/can contain lowercase alphanumeric \\(a-z and 0-9\\), hyphens or underscores;\
      \ must start and end with alphanumeric/"
    transform.put_transform:
      transform_id: "!@#$%^&*(duplicate-field-transform"
      body: "{\n  \"source\": {\n    \"index\": \"source-index\"\n  },\n  \"dest\"\
        : { \"index\": \"dest-index\" },\n  \"pivot\": {\n    \"group_by\": { \"airline.id\"\
        : {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"airline.response\"\
        : {\"avg\": {\"field\": \"responsetime\"}}}\n  }\n}\n"
    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: "/The id cannot contain more than 64 character/"
    transform.put_transform:
      transform_id: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
      body: "{\n  \"source\": {\n    \"index\": \"source-index\"\n  },\n  \"dest\"\
        : { \"index\": \"dest-index\" },\n  \"pivot\": {\n    \"group_by\": { \"airline.id\"\
        : {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"airline.response\"\
        : {\"avg\": {\"field\": \"responsetime\"}}}\n  }\n}\n"
    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 invalid destination index name:
- do:
    catch: "/.*Validation Failed.* Destination index \\[DeStInAtIoN\\] must be lowercase/"
    transform.put_transform:
      transform_id: "airline-transform"
      body: "{\n  \"source\": {\n    \"index\": \"airline-data\"\n  },\n  \"dest\"\
        : { \"index\": \"DeStInAtIoN\" },\n  \"pivot\": {\n    \"group_by\": { \"\
        airline\": {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"avg_response\"\
        : {\"avg\": {\"field\": \"responsetime\"}}}\n  }\n}\n"
    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: "/Invalid index name \\[destination#dest\\], must not contain \\'#\\'/"
    transform.put_transform:
      transform_id: "airline-transform"
      body: "{\n  \"source\": {\n    \"index\": \"airline-data\"\n  },\n  \"dest\"\
        : { \"index\": \"destination#dest\" },\n  \"pivot\": {\n    \"group_by\":\
        \ { \"airline\": {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"\
        avg_response\": {\"avg\": {\"field\": \"responsetime\"}}}\n  }\n}\n"
    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 put valid config with create_time in the body:
- do:
    catch: "/Found \\[create_time\\], not allowed for strict parsing/"
    transform.put_transform:
      transform_id: "airline-transform-with-create-time"
      body: "{\n  \"source\": { \"index\": \"airline-data\" },\n  \"dest\": { \"index\"\
        : \"airline-data-by-airline\" },\n  \"pivot\": {\n    \"group_by\": { \"airline\"\
        : {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"avg_response\"\
        : {\"avg\": {\"field\": \"responsetime\"}}}\n  },\n  \"description\": \"yaml\
        \ test transform on airline-data\",\n  \"create_time\": 123456789\n}\n"
    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 put valid config with version in the body:
- do:
    catch: "/Found \\[version\\], not allowed for strict parsing/"
    transform.put_transform:
      transform_id: "airline-transform-with-version"
      body: "{\n  \"source\": { \"index\": \"airline-data\" },\n  \"dest\": { \"index\"\
        : \"airline-data-by-airline\" },\n  \"pivot\": {\n    \"group_by\": { \"airline\"\
        : {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"avg_response\"\
        : {\"avg\": {\"field\": \"responsetime\"}}}\n  },\n  \"description\": \"yaml\
        \ test transform on airline-data\",\n  \"version\": \"7.3.0\"\n}\n"
    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 put transform with missing pipeline:
- do:
    catch: "/Pipeline with id \\[missing-transform-pipeline\\] could not be found/"
    transform.put_transform:
      transform_id: "airline-transform-with-missing-pipeline-crud"
      body: "{\n  \"source\": { \"index\": \"airline-data\" },\n  \"dest\": { \"index\"\
        : \"airline-data-by-airline-with-pipeline\", \"pipeline\": \"missing-transform-pipeline\"\
        \ },\n  \"pivot\": {\n    \"group_by\": { \"airline\": {\"terms\": {\"field\"\
        : \"airline\"}}},\n    \"aggs\": {\"avg_response\": {\"avg\": {\"field\":\
        \ \"responsetime\"}}}\n  },\n  \"description\": \"yaml test transform on airline-data\"\
        \n}\n"
    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 put transform with missing pipeline and defer validations:
- do:
    transform.put_transform:
      defer_validation: true
      transform_id: "airline-transform-with-missing-pipeline-crud-defer"
      body: "{\n  \"source\": { \"index\": \"airline-data\" },\n  \"dest\": { \"index\"\
        : \"airline-data-by-airline\", \"pipeline\": \"missing-transform-pipeline\"\
        \ },\n  \"pivot\": {\n    \"group_by\": { \"airline\": {\"terms\": {\"field\"\
        : \"airline\"}}},\n    \"aggs\": {\"avg_response\": {\"avg\": {\"field\":\
        \ \"responsetime\"}}}\n  },\n  \"description\": \"yaml test transform on airline-data\"\
        \n}\n"
    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:
    acknowledged: true
---
Test put transform with bad query due to script compilation:
- do:
    catch: "bad_request"
    transform.put_transform:
      transform_id: "airline-transform-with-bad-scripts"
      body: "{\n  \"source\": { \"index\": \"airline-data\" },\n  \"dest\": { \"index\"\
        : \"airline-data-by-airline-with-bad-scripts\" },\n  \"pivot\": {\n    \"\
        group_by\": { \"airline\": {\"terms\": {\"field\": \"airline\"}}},\n    \"\
        aggs\": {\n      \"sumState\": {\n        \"scripted_metric\": {\n       \
        \   \"combine_script\": {\n            \"source\": \"foobar boom\"\n     \
        \     },\n          \"init_script\": {\n            \"source\": \"state.state\
        \ = []\"\n          },\n          \"map_script\": {\n            \"source\"\
        : \"state.state.add(1)\"\n          },\n          \"reduce_script\": {\n \
        \           \"source\": \"long sum = 0; for (s in states) { sum += s } return\
        \ sum\"\n          }\n        }\n      }\n    }\n  },\n  \"description\":\
        \ \"yaml test transform on airline-data\"\n}\n"
    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 transform for export:
- do:
    transform.put_transform:
      transform_id: "airline-transform"
      body: "{\n  \"source\": { \"index\": \"airline-data\" },\n  \"dest\": { \"index\"\
        : \"airline-data-by-airline\" },\n  \"pivot\": {\n    \"group_by\": { \"airline\"\
        : {\"terms\": {\"field\": \"airline\"}}},\n    \"aggs\": {\"avg_response\"\
        : {\"avg\": {\"field\": \"responsetime\"}}}\n  },\n  \"description\": \"yaml\
        \ test transform on airline-data\"\n}\n"
    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:
    acknowledged: true
- do:
    transform.get_transform:
      transform_id: "airline-transform"
      exclude_generated: 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:
    transforms.0.source.index:
    - "airline-data"
- match:
    transforms.0.dest.index: "airline-data-by-airline"
- match:
    transforms.0.pivot.group_by.airline.terms.field: "airline"
- match:
    transforms.0.pivot.aggregations.avg_response.avg.field: "responsetime"
- match:
    transforms.0.description: "yaml test transform on airline-data"
- match:
    transforms.0.id: "airline-transform"
- is_false: "transforms.0.create_time"
- is_false: "transforms.0.version"
---
Test creation failures of latest function:
- do:
    catch: "/latest.unique_key must be non-empty/"
    transform.put_transform:
      transform_id: "duplicate-field-transform"
      body: "{\n  \"source\": {\n    \"index\": \"airline-data\"\n  },\n  \"dest\"\
        : { \"index\": \"dest-index\" },\n  \"latest\": {\n    \"unique_key\": [],\n\
        \    \"sort\": \"time\"\n  }\n}\n"
    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: "/latest.unique_key\\[1\\] element must be non-empty/"
    transform.put_transform:
      transform_id: "duplicate-field-transform"
      body: "{\n  \"source\": {\n    \"index\": \"airline-data\"\n  },\n  \"dest\"\
        : { \"index\": \"dest-index\" },\n  \"latest\": {\n    \"unique_key\": [ \"\
        airline\", \"\" ],\n    \"sort\": \"time\"\n  }\n}\n"
    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: "/latest.unique_key elements must be unique, found duplicate element \\\
      [airline\\]/"
    transform.put_transform:
      transform_id: "duplicate-field-transform"
      body: "{\n  \"source\": {\n    \"index\": \"airline-data\"\n  },\n  \"dest\"\
        : { \"index\": \"dest-index\" },\n  \"latest\": {\n    \"unique_key\": [ \"\
        airline\", \"airline\" ],\n    \"sort\": \"time\"\n  }\n}\n"
    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: "/latest.sort must be non-empty/"
    transform.put_transform:
      transform_id: "duplicate-field-transform"
      body: "{\n  \"source\": {\n    \"index\": \"airline-data\"\n  },\n  \"dest\"\
        : { \"index\": \"dest-index\" },\n  \"latest\": {\n    \"unique_key\": [ \"\
        airline\" ],\n    \"sort\": \"\"\n  }\n}\n"
    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 creation of latest function:
- do:
    transform.put_transform:
      transform_id: "latest-by-airline-transform"
      body: "{\n  \"source\": {\n    \"index\": \"airline-data\"\n  },\n  \"dest\"\
        : { \"index\": \"latest-by-airline\" },\n  \"latest\": {\n    \"unique_key\"\
        : [ \"airline\" ],\n    \"sort\": \"time\"\n  },\n  \"description\": \"yaml\
        \ test latest transform on airline-data\"\n}\n"
    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:
    acknowledged: true
- do:
    transform.get_transform:
      transform_id: "latest-by-airline-transform"
    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:
    transforms.0.id: "latest-by-airline-transform"
- match:
    transforms.0.source.index.0: "airline-data"
- match:
    transforms.0.dest.index: "latest-by-airline"
- is_true: "transforms.0.source.query.match_all"
- is_true: "transforms.0.create_time"
- is_true: "transforms.0.version"
- match:
    transforms.0.latest.unique_key.0: "airline"
- match:
    transforms.0.latest.sort: "time"
- match:
    transforms.0.description: "yaml test latest transform on airline-data"
