---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
- requires:
    test_runner_features:
    - "capabilities"
    capabilities:
    - method: "POST"
      path: "/_cluster/voting_config_exclusions"
      capabilities:
      - "plain_text_empty_response"
    - method: "DELETE"
      path: "/_cluster/voting_config_exclusions"
      capabilities:
      - "plain_text_empty_response"
    reason: "needs these capabilities"
---
teardown:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
- do:
    cluster.delete_voting_config_exclusions: {}
    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"
---
Get cluster state without voting config exclusions:
- do:
    cluster.state: {}
    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"
- length:
    metadata.cluster_coordination.voting_config_exclusions: 0
---
Add voting config exclusion by unknown node Id:
- do:
    cluster.post_voting_config_exclusions:
      node_ids: "nodeId"
    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:
    cluster.state: {}
    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"
- length:
    metadata.cluster_coordination.voting_config_exclusions: 1
- match:
    metadata.cluster_coordination.voting_config_exclusions.0.node_id: "nodeId"
- match:
    metadata.cluster_coordination.voting_config_exclusions.0.node_name: "_absent_"
---
Add voting config exclusion by unknown node Ids:
- skip:
    reason: "contains is a newly added assertion"
    features: "contains"
- do:
    cluster.post_voting_config_exclusions:
      node_ids: "nodeId1,nodeId2"
    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:
    cluster.state: {}
    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"
- length:
    metadata.cluster_coordination.voting_config_exclusions: 2
- contains:
    metadata.cluster_coordination.voting_config_exclusions:
      node_id: "nodeId1"
      node_name: "_absent_"
- contains:
    metadata.cluster_coordination.voting_config_exclusions:
      node_id: "nodeId2"
      node_name: "_absent_"
---
Add voting config exclusion by unknown node name:
- do:
    cluster.post_voting_config_exclusions:
      node_names: "nodeName"
    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:
    cluster.state: {}
    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"
- length:
    metadata.cluster_coordination.voting_config_exclusions: 1
- match:
    metadata.cluster_coordination.voting_config_exclusions.0.node_id: "_absent_"
- match:
    metadata.cluster_coordination.voting_config_exclusions.0.node_name: "nodeName"
---
Add voting config exclusion by unknown node names:
- skip:
    reason: "contains is a newly added assertion"
    features: "contains"
- do:
    cluster.post_voting_config_exclusions:
      node_names: "nodeName1,nodeName2"
    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:
    cluster.state: {}
    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"
- length:
    metadata.cluster_coordination.voting_config_exclusions: 2
- contains:
    metadata.cluster_coordination.voting_config_exclusions:
      node_id: "_absent_"
      node_name: "nodeName1"
- contains:
    metadata.cluster_coordination.voting_config_exclusions:
      node_id: "_absent_"
      node_name: "nodeName2"
---
Throw exception when adding voting config exclusion without specifying nodes:
- do:
    catch: "/(You must set \\[node_names\\] or \\[node_ids\\] but not both|Please\
      \ set node identifiers correctly. One and only one of \\[node_name\\], \\[node_names\\\
      ] and \\[node_ids\\] has to be set)/"
    cluster.post_voting_config_exclusions: {}
    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"
---
Throw exception when adding voting config exclusion and specifying both node_ids and node_names:
- do:
    catch: "/(You must set \\[node_names\\] or \\[node_ids\\] but not both|Please\
      \ set node identifiers correctly. One and only one of \\[node_name\\], \\[node_names\\\
      ] and \\[node_ids\\] has to be set)/"
    cluster.post_voting_config_exclusions:
      node_ids: "nodeId"
      node_names: "nodeName"
    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"
