@@ -1038,6 +1038,7 @@ public void testCannotAllocateStaleReplicaExplanation() throws Exception {
10381038 assertBusy (() -> {
10391039 ClusterAllocationExplanation explanation = client ().admin ().cluster ().prepareAllocationExplain ()
10401040 .setIndex ("idx" ).setShard (0 ).setPrimary (true ).get ().getExplanation ();
1041+ assertTrue (explanation .getShardAllocationDecision ().getAllocateDecision ().isDecisionTaken ());
10411042 assertEquals (AllocationDecision .NO_VALID_SHARD_COPY ,
10421043 explanation .getShardAllocationDecision ().getAllocateDecision ().getAllocationDecision ());
10431044 });
@@ -1069,18 +1070,19 @@ public void testCannotAllocateStaleReplicaExplanation() throws Exception {
10691070 assertFalse (moveDecision .isDecisionTaken ());
10701071 assertEquals (AllocationDecision .NO_VALID_SHARD_COPY , allocateDecision .getAllocationDecision ());
10711072 assertEquals (2 , allocateDecision .getNodeDecisions ().size ());
1072- NodeAllocationResult nodeAllocationResult = allocateDecision .getNodeDecisions ().get (0 );
1073- assertEquals (restartedNode , nodeAllocationResult .getNode ().getName ());
1074- assertNotNull (nodeAllocationResult .getShardStoreInfo ());
1075- assertNotNull (nodeAllocationResult .getShardStoreInfo ().getAllocationId ());
1076- assertFalse (nodeAllocationResult .getShardStoreInfo ().isInSync ());
1077- assertNull (nodeAllocationResult .getShardStoreInfo ().getStoreException ());
1078- nodeAllocationResult = allocateDecision .getNodeDecisions ().get (1 );
1079- assertEquals (masterNode , nodeAllocationResult .getNode ().getName ());
1080- assertNotNull (nodeAllocationResult .getShardStoreInfo ());
1081- assertNull (nodeAllocationResult .getShardStoreInfo ().getAllocationId ());
1082- assertFalse (nodeAllocationResult .getShardStoreInfo ().isInSync ());
1083- assertNull (nodeAllocationResult .getShardStoreInfo ().getStoreException ());
1073+ for (NodeAllocationResult nodeAllocationResult : allocateDecision .getNodeDecisions ()) {
1074+ if (nodeAllocationResult .getNode ().getName ().equals (restartedNode )) {
1075+ assertNotNull (nodeAllocationResult .getShardStoreInfo ());
1076+ assertNotNull (nodeAllocationResult .getShardStoreInfo ().getAllocationId ());
1077+ assertFalse (nodeAllocationResult .getShardStoreInfo ().isInSync ());
1078+ assertNull (nodeAllocationResult .getShardStoreInfo ().getStoreException ());
1079+ } else {
1080+ assertNotNull (nodeAllocationResult .getShardStoreInfo ());
1081+ assertNull (nodeAllocationResult .getShardStoreInfo ().getAllocationId ());
1082+ assertFalse (nodeAllocationResult .getShardStoreInfo ().isInSync ());
1083+ assertNull (nodeAllocationResult .getShardStoreInfo ().getStoreException ());
1084+ }
1085+ }
10841086
10851087 // verify JSON output
10861088 try (XContentParser parser = getParser (explanation )) {
0 commit comments