From 54c7e0694d301cb751c355d9fc1b3f3ae590100d Mon Sep 17 00:00:00 2001 From: Harsh Garg Date: Tue, 28 May 2024 03:00:30 +0530 Subject: [PATCH] Asserting on delayed allocation Signed-off-by: Harsh Garg --- .../gateway/RecoveryFromGatewayIT.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java b/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java index 019ee3bebdea0..6d8412b969c4c 100644 --- a/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java @@ -56,6 +56,7 @@ import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.routing.ShardRouting; import org.opensearch.cluster.routing.ShardRoutingState; +import org.opensearch.cluster.routing.allocation.AllocationDecision; import org.opensearch.cluster.routing.allocation.ExistingShardsAllocator; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.settings.Settings; @@ -878,6 +879,21 @@ public void testBatchModeDisabledWithHighIndexNodeLeftDelayedTimeoutValue() thro assertFalse(health.isTimedOut()); assertEquals(YELLOW, health.getStatus()); assertEquals(2, health.getUnassignedShards()); + // shard should be unassigned because of Allocation_Delayed + assertEquals( + AllocationDecision.ALLOCATION_DELAYED, + client().admin() + .cluster() + .prepareAllocationExplain() + .setIndex("test") + .setShard(0) + .setPrimary(false) + .get() + .getExplanation() + .getShardAllocationDecision() + .getAllocateDecision() + .getAllocationDecision() + ); logger.info("--> restarting the stopped nodes"); internalCluster().startDataOnlyNode(