---
 teardown:

  - do:
      cluster.put_settings:
        body:
          transient:
            search.max_keep_alive: null

---
"Max keep alive":
  - skip:
      version: " - 7.0.0"
      reason: search.max_keep_alive was added in 7.0.0

  - do:
      index:
        index:  test_scroll
        type:   test
        id:     1
        body:   { foo: 1 }

  - do:
      index:
        index:  test_scroll
        type:   test
        id:     2
        body:   { foo: 1 }

  - do:
      indices.refresh: {}

  - do:
      cluster.put_settings:
        body:
          transient:
            search.default_keep_alive: "1m"
            search.max_keep_alive: "1m"

  - do:
      catch: /.*Keep alive for scroll.*is too large.*/
      search:
        index: test_scroll
        size: 1
        scroll: 2m
        sort: foo
        body:
          query:
            match_all: {}

  - do:
      search:
        index: test_scroll
        size: 1
        scroll: 1m
        sort: foo
        body:
          query:
            match_all: {}

  - set: {_scroll_id: scroll_id}
  - match: {hits.total:      2    }
  - length: {hits.hits:      1    }

  - do:
      catch: /.*Keep alive for scroll.*is too large.*/
      scroll:
        scroll_id: $scroll_id
        scroll: 3m

---
 teardown:

  - do:
      cluster.put_settings:
        body:
          transient:
            search.max_keep_alive: null

---
"Max keep alive":
  - skip:
      version: " - 6.0.99"
      reason: search.max_keep_alive was added in 6.1.0

  - do:
      index:
        index:  test_scroll
        type:   test
        id:     1
        body:   { foo: 1 }

  - do:
      index:
        index:  test_scroll
        type:   test
        id:     2
        body:   { foo: 1 }

  - do:
      indices.refresh: {}

  - do:
      cluster.put_settings:
        body:
          transient:
            search.default_keep_alive: "1m"
            search.max_keep_alive: "1m"

  - do:
      catch: /.*Keep alive for scroll.*is too large.*/
      search:
        index: test_scroll
        size: 1
        scroll: 2m
        sort: foo
        body:
          query:
            match_all: {}

  - do:
      search:
        index: test_scroll
        size: 1
        scroll: 1m
        sort: foo
        body:
          query:
            match_all: {}

  - set: {_scroll_id: scroll_id}
  - match: {hits.total:      2    }
  - length: {hits.hits:      1    }

  - do:
      catch: /.*Keep alive for scroll.*is too large.*/
      scroll:
        scroll_id: $scroll_id
        scroll: 3m

Set bwc skip version after backport
Set bwc skip version after backport
