From 55e85cd99119a240cccf4b409a4218756b2e2163 Mon Sep 17 00:00:00 2001 From: dblock Date: Fri, 30 Aug 2024 08:52:01 -0400 Subject: [PATCH] Added tests for /_cluster/reroute. Signed-off-by: dblock --- .../cluster/decommission/awareness.yaml | 9 --- .../routing/cluster/decommission/status.yaml | 9 --- tests/routing/cluster/reroute.yaml | 55 +++++++++++++++++++ .../cluster/routing/awareness/weights.yaml | 9 --- tests/routing/docker-compose.yml | 4 ++ 5 files changed, 59 insertions(+), 27 deletions(-) create mode 100644 tests/routing/cluster/reroute.yaml diff --git a/tests/routing/cluster/decommission/awareness.yaml b/tests/routing/cluster/decommission/awareness.yaml index 569a93709..75052a519 100644 --- a/tests/routing/cluster/decommission/awareness.yaml +++ b/tests/routing/cluster/decommission/awareness.yaml @@ -3,15 +3,6 @@ $schema: ../../../../json_schemas/test_story.schema.yaml description: Test cluster routing settings. version: '>= 2.16' prologues: - - path: /_cluster/settings - method: PUT - request: - payload: - transient: - cluster.routing.allocation.awareness.attributes: zone - cluster.routing.allocation.awareness.force.zone.values: - - zoneA - - zoneB - id: weights path: /_cluster/routing/awareness/zone/weights method: GET diff --git a/tests/routing/cluster/decommission/status.yaml b/tests/routing/cluster/decommission/status.yaml index c4ac9a3c1..f62c67ce5 100644 --- a/tests/routing/cluster/decommission/status.yaml +++ b/tests/routing/cluster/decommission/status.yaml @@ -3,15 +3,6 @@ $schema: ../../../../json_schemas/test_story.schema.yaml description: Test cluster routing settings. version: '>= 2.16' prologues: - - path: /_cluster/settings - method: PUT - request: - payload: - transient: - cluster.routing.allocation.awareness.attributes: zone - cluster.routing.allocation.awareness.force.zone.values: - - zoneA - - zoneB - id: weights path: /_cluster/routing/awareness/zone/weights method: GET diff --git a/tests/routing/cluster/reroute.yaml b/tests/routing/cluster/reroute.yaml new file mode 100644 index 000000000..a9b669a71 --- /dev/null +++ b/tests/routing/cluster/reroute.yaml @@ -0,0 +1,55 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test changes to allocation of shards in a cluster. +prologues: + - path: /movies + method: PUT + request: + payload: + settings: + index.number_of_shards: 1 + index.number_of_replicas: 0 + - path: /_bulk + method: POST + parameters: + refresh: 'true' + request: + content_type: application/x-ndjson + payload: + - {create: {_index: movies}} + - {director: Bennett Miller, title: Moneyball, year: 2011} + - {create: {_index: movies}} + - {director: Nicolas Winding Refn, title: Drive, year: 1960} +epilogues: + - path: /movies + method: DELETE + status: [200, 404] +chapters: + - synopsis: Shows the allocation of shards in a cluster. + path: /_cluster/reroute + method: POST + response: + status: 200 + - synopsis: Shows the allocation of shards in a cluster with parameters. + path: /_cluster/reroute + method: POST + parameters: + dry_run: true + explain: true + metric: nodes + retry_failed: false + response: + status: 200 + - synopsis: Reroute an index shard between nodes. + path: /_cluster/reroute + method: POST + request: + payload: + commands: + - move: + index: movies + shard: 0 + from_node: opensearch-node1 + to_node: opensearch-node2 + response: + status: 200 \ No newline at end of file diff --git a/tests/routing/cluster/routing/awareness/weights.yaml b/tests/routing/cluster/routing/awareness/weights.yaml index 059647b91..29bac7e24 100644 --- a/tests/routing/cluster/routing/awareness/weights.yaml +++ b/tests/routing/cluster/routing/awareness/weights.yaml @@ -2,15 +2,6 @@ $schema: ../../../../../json_schemas/test_story.schema.yaml description: Test cluster routing settings. version: '>= 2.16' -prologues: - - path: /_cluster/settings - method: PUT - request: - payload: - transient: - cluster.routing.allocation.awareness.attributes: zone - cluster.routing.allocation.awareness.force.zone.values: - - zoneA epilogues: - id: epilogue_weights path: /_cluster/routing/awareness/zone/weights diff --git a/tests/routing/docker-compose.yml b/tests/routing/docker-compose.yml index fd5e0078c..8ddcf665c 100644 --- a/tests/routing/docker-compose.yml +++ b/tests/routing/docker-compose.yml @@ -12,6 +12,8 @@ services: - OPENSEARCH_JAVA_OPTS=${OPENSEARCH_JAVA_OPTS} - cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2 - cluster.name=opensearch-cluster + - cluster.routing.allocation.awareness.attributes=zone + - cluster.routing.allocation.awareness.force.zone.values=zoneA,zoneB - discovery.seed_hosts=opensearch-node1,opensearch-node2 - node.attr.zone=zoneA - node.name=opensearch-node1 @@ -27,6 +29,8 @@ services: - OPENSEARCH_JAVA_OPTS=${OPENSEARCH_JAVA_OPTS} - cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2 - cluster.name=opensearch-cluster + - cluster.routing.allocation.awareness.attributes=zone + - cluster.routing.allocation.awareness.force.zone.values=zoneA,zoneB - discovery.seed_hosts=opensearch-node1,opensearch-node2 - node.attr.zone=zoneB - node.name=opensearch-node2