---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
---
Help:
- skip:
    awaits_fix: "sync_id is removed in 9.0"
- requires:
    cluster_features:
    - "gte_v8.18.0"
    reason: "indexing failed due to version conflict added in 8.18.0"
- do:
    cat.shards:
      help: true
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    $body: "/^   index                            .+   \\n\n     shard           \
      \                 .+   \\n\n     prirep                           .+   \\n\n\
      \     state                            .+   \\n\n     docs                 \
      \            .+   \\n\n     store                            .+   \\n\n    \
      \ dataset                          .+   \\n\n     ip                       \
      \        .+   \\n\n     id                               .+   \\n\n     node\
      \                             .+   \\n\n     sync_id                       \
      \   .+   \\n\n     unassigned.reason                .+   \\n\n     unassigned.at\
      \                    .+   \\n\n     unassigned.for                   .+   \\\
      n\n     unassigned.details               .+   \\n\n     recoverysource.type\
      \              .+   \\n\n     completion.size                  .+   \\n\n  \
      \   fielddata.memory_size            .+   \\n\n     fielddata.evictions    \
      \          .+   \\n\n     query_cache.memory_size          .+   \\n\n     query_cache.evictions\
      \            .+   \\n\n     flush.total                      .+   \\n\n    \
      \ flush.total_time                 .+   \\n\n     get.current              \
      \        .+   \\n\n     get.time                         .+   \\n\n     get.total\
      \                        .+   \\n\n     get.exists_time                  .+\
      \   \\n\n     get.exists_total                 .+   \\n\n     get.missing_time\
      \                 .+   \\n\n     get.missing_total                .+   \\n\n\
      \     indexing.delete_current          .+   \\n\n     indexing.delete_time \
      \            .+   \\n\n     indexing.delete_total            .+   \\n\n    \
      \ indexing.index_current           .+   \\n\n     indexing.index_time      \
      \        .+   \\n\n     indexing.index_total             .+   \\n\n     indexing.index_failed\
      \            .+   \\n\n     indexing.index_failed_due_to_version_conflict .+\
      \   \\n\n     merges.current                   .+   \\n\n     merges.current_docs\
      \              .+   \\n\n     merges.current_size              .+   \\n\n  \
      \   merges.total                     .+   \\n\n     merges.total_docs      \
      \          .+   \\n\n     merges.total_size                .+   \\n\n     merges.total_time\
      \                .+   \\n\n     refresh.total                    .+   \\n\n\
      \     refresh.time                     .+   \\n\n     refresh.external_total\
      \           .+   \\n\n     refresh.external_time            .+   \\n\n     refresh.listeners\
      \                .+   \\n\n     search.fetch_current             .+   \\n\n\
      \     search.fetch_time                .+   \\n\n     search.fetch_total   \
      \            .+   \\n\n     search.open_contexts             .+   \\n\n    \
      \ search.query_current             .+   \\n\n     search.query_time        \
      \        .+   \\n\n     search.query_total               .+   \\n\n     search.scroll_current\
      \            .+   \\n\n     search.scroll_time               .+   \\n\n    \
      \ search.scroll_total              .+   \\n\n     segments.count           \
      \        .+   \\n\n     segments.memory                  .+   \\n\n     segments.index_writer_memory\
      \     .+   \\n\n     segments.version_map_memory      .+   \\n\n     segments.fixed_bitset_memory\
      \     .+   \\n\n     seq_no.max                       .+   \\n\n     seq_no.local_checkpoint\
      \          .+   \\n\n     seq_no.global_checkpoint         .+   \\n\n     warmer.current\
      \                   .+   \\n\n     warmer.total                     .+   \\\
      n\n     warmer.total_time                .+   \\n\n     path.data          \
      \              .+   \\n\n     path.state                       .+   \\n\n  \
      \   bulk.total_operations            .+   \\n\n     bulk.total_time        \
      \          .+   \\n\n     bulk.total_size_in_bytes         .+   \\n\n     bulk.avg_time\
      \                    .+   \\n\n     bulk.avg_size_in_bytes           .+   \\\
      n\n     dense_vector.value_count         .+   \\n\n     sparse_vector.value_count\
      \        .+   \\n\n$/\n"
---
Test cat shards output:
- requires:
    cluster_features:
    - "gte_v8.11.0"
    reason: "dataset size was added in 8.11.0"
- do:
    cat.shards:
      index: "i*"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    $body: "/^$/\n"
- do:
    indices.create:
      index: "index1"
      body:
        settings:
          number_of_shards: "5"
          number_of_replicas: "1"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    cat.shards:
      index: "i*"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    $body: "/^(index1 \\s+ \\d \\s+ (p|r) \\s+ ((STARTED|INITIALIZING|RELOCATING)\
      \ \\s+ (\\d \\s+ (\\d+|\\d+[.]\\d+)(kb|b) \\s+ (\\d+|\\d+[.]\\d+)(kb|b) \\s+)?\
      \ [0-9a-f:.%]+ \\s+ .+|UNASSIGNED \\s+)  \\n?){10}$/\n"
- do:
    indices.create:
      index: "index2"
      body:
        settings:
          number_of_shards: "5"
          number_of_replicas: "0"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    cat.shards:
      index: "i*"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    $body: "/^(index(1|2) \\s+ \\d \\s+ (p|r) \\s+ ((STARTED|INITIALIZING|RELOCATING)\
      \ \\s+ (\\d \\s+ (\\d+|\\d+[.]\\d+)(kb|b) \\s+ (\\d+|\\d+[.]\\d+)(kb|b) \\s+)?\
      \ [0-9a-f:.%]+ \\s+ .+|UNASSIGNED \\s+) \\n?){15}$/\n"
- do:
    cat.shards:
      index: "index2"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    $body: "/^(index2 \\s+ \\d \\s+ (p|r) \\s+ ((STARTED|INITIALIZING|RELOCATING)\
      \ \\s+ (\\d \\s+ (\\d+|\\d+[.]\\d+)(kb|b) \\s+ (\\d+|\\d+[.]\\d+)(kb|b) \\s+)?\
      \ [0-9a-f:.%]+ \\s+ .+|UNASSIGNED \\s+) \\n?){5}$/\n"
---
Test cat shards using wildcards:
- do:
    indices.create:
      index: "foo"
      body:
        settings:
          number_of_shards: "1"
          number_of_replicas: "0"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    indices.create:
      index: "bar"
      body:
        settings:
          number_of_shards: "1"
          number_of_replicas: "0"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    indices.create:
      index: "baz"
      body:
        settings:
          number_of_shards: "1"
          number_of_replicas: "0"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    cat.shards:
      index: "f*"
      v: false
      h: "i"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    $body: "/^(foo \\n?)$/\n"
- do:
    cat.shards:
      index: "ba*"
      v: false
      h: "i"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    $body: "/^(ba(r|z) \\n?){2}$/\n"
---
Test cat shards sort:
- requires:
    cluster_features:
    - "gte_v8.11.0"
    reason: "dataset size was added in 8.11.0"
- do:
    indices.create:
      index: "foo"
      body:
        settings:
          number_of_shards: "1"
          number_of_replicas: "0"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    indices.create:
      index: "bar"
      body:
        settings:
          number_of_shards: "1"
          number_of_replicas: "0"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    index:
      index: "bar"
      body:
        test: "bar"
      refresh: true
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    cat.shards:
      h:
      - "index"
      - "docs"
      s:
      - "docs"
      index: "foo,bar"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    $body: "/^ foo \\s+ 0\\n\n   bar \\s+ 1\\n\n$/\n"
- do:
    cat.shards:
      h:
      - "index"
      - "dataset"
      s:
      - "docs"
      index: "foo,bar"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    $body: "/^ foo \\s+ (\\d+|\\d+[.]\\d+)(kb|b)\\n\n   bar \\s+ (\\d+|\\d+[.]\\d+)(kb|b)\\\
      n\n$/\n"
---
Test cat shards with hidden indices:
- requires:
    cluster_features:
    - "gte_v8.3.0"
    reason: "hidden indices were misreported in versions before 8.3.0"
- do:
    indices.create:
      index: "foo"
      body:
        settings:
          number_of_shards: "1"
          number_of_replicas: "0"
          hidden: "true"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    index:
      index: "foo"
      body:
        test: "foo"
      refresh: true
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    cat.shards:
      h:
      - "index"
      - "docs"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    $body: "/foo \\s+ 1\\n/"
