Add Cluster Allocation Explain API Tests (#130381)

Add Cluster Allocation Explain API Tests

Adds tests for the `cluster/allocation/explain` API for when non-integer values are passed as the integer expected shard parameter. This change does not modify the `cluster/allocation/explain` API itself.
This commit is contained in:
Joshua Adams 2025-07-01 14:01:08 +01:00 committed by GitHub
parent 19708c1e9c
commit 5c8c001c58
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 94 additions and 22 deletions

View File

@ -4,28 +4,6 @@
catch: /illegal_argument_exception/
cluster.allocation_explain: {}
---
"cluster shard allocation explanation test":
- do:
indices.create:
index: test
- match: { acknowledged: true }
- do:
cluster.allocation_explain:
body: { "index": "test", "shard": 0, "primary": true }
- match: { current_state: "started" }
- is_true: current_node.id
- match: { index: "test" }
- match: { shard: 0 }
- match: { primary: true }
- is_true: can_remain_on_current_node
- is_true: can_rebalance_cluster
- is_true: can_rebalance_to_other_node
- is_true: rebalance_explanation
---
"cluster shard allocation explanation test with empty request":
- do:
@ -46,6 +24,100 @@
- is_true: cluster_info
- is_true: can_allocate
---
# This test has a valid integer input, but it's above the shard limit, so the index cannot be located
"cluster shard allocation explanation test with max integer shard value":
- do:
indices.create:
index: test
- match: { acknowledged: true }
- do:
catch: /shard_not_found_exception/
cluster.allocation_explain:
body: { "index": "test", "shard": 2147483647, "primary": true }
---
"cluster shard allocation explanation test with long shard value":
- do:
indices.create:
index: test
- match: { acknowledged: true }
- do:
catch: /x_content_parse_exception/
cluster.allocation_explain:
body: { "index": "test", "shard": 214748364777, "primary": true }
---
"cluster shard allocation explanation test with float shard value":
- do:
indices.create:
index: test
body: { "settings": { "index.number_of_shards": 2, "index.number_of_replicas": 0 } }
- match: { acknowledged: true }
- do:
cluster.allocation_explain:
body: { "index": "test", "shard": 1.0, "primary": true }
- match: { current_state: "started" }
- is_true: current_node.id
- match: { index: "test" }
- match: { shard: 1 }
- match: { primary: true }
- is_true: can_remain_on_current_node
- is_true: can_rebalance_cluster
- is_true: can_rebalance_to_other_node
- is_true: rebalance_explanation
---
"cluster shard allocation explanation test with double shard value":
- do:
indices.create:
index: test
body: { "settings": { "index.number_of_shards": 2, "index.number_of_replicas": 0 } }
- match: { acknowledged: true }
- do:
cluster.allocation_explain:
body: { "index": "test", "shard": 1.1234567891234567, "primary": true }
- match: { current_state: "started" }
- is_true: current_node.id
- match: { index: "test" }
- match: { shard: 1 }
- match: { primary: true }
- is_true: can_remain_on_current_node
- is_true: can_rebalance_cluster
- is_true: can_rebalance_to_other_node
- is_true: rebalance_explanation
---
"cluster shard allocation explanation test with three valid body parameters":
- do:
indices.create:
index: test
- match: { acknowledged: true }
- do:
cluster.allocation_explain:
body: { "index": "test", "shard": 0, "primary": true }
- match: { current_state: "started" }
- is_true: current_node.id
- match: { index: "test" }
- match: { shard: 0 }
- match: { primary: true }
- is_true: can_remain_on_current_node
- is_true: can_rebalance_cluster
- is_true: can_rebalance_to_other_node
- is_true: rebalance_explanation
---
"Cluster shard allocation explanation test with a closed index":