@@ -539,18 +539,7 @@ private void assertNodesRemovedAfterZoneDecommission(boolean originalClusterMana
539
539
assertEquals (originalClusterManager , currentClusterManager );
540
540
}
541
541
542
- // Will wait for all events to complete
543
- client (activeNode ).admin ().cluster ().prepareHealth ().setWaitForEvents (Priority .LANGUID ).get ();
544
-
545
- // Recommissioning the zone back to gracefully succeed the test once above tests succeeds
546
- DeleteDecommissionStateResponse deleteDecommissionStateResponse = client (currentClusterManager ).execute (
547
- DeleteDecommissionStateAction .INSTANCE ,
548
- new DeleteDecommissionStateRequest ()
549
- ).get ();
550
- assertTrue (deleteDecommissionStateResponse .isAcknowledged ());
551
-
552
- // will wait for cluster to stabilise with a timeout of 2 min as by then all nodes should have joined the cluster
553
- ensureStableCluster (15 , TimeValue .timeValueMinutes (2 ));
542
+ deleteDecommissionStateAndWaitForStableCluster (currentClusterManager , 15 );
554
543
}
555
544
556
545
public void testDecommissionFailedWhenDifferentAttributeAlreadyDecommissioned () throws Exception {
@@ -617,18 +606,7 @@ public void testDecommissionFailedWhenDifferentAttributeAlreadyDecommissioned()
617
606
)
618
607
);
619
608
620
- // Will wait for all events to complete
621
- client (node_in_c ).admin ().cluster ().prepareHealth ().setWaitForEvents (Priority .LANGUID ).get ();
622
-
623
- // Recommissioning the zone back to gracefully succeed the test once above tests succeeds
624
- DeleteDecommissionStateResponse deleteDecommissionStateResponse = client (node_in_c ).execute (
625
- DeleteDecommissionStateAction .INSTANCE ,
626
- new DeleteDecommissionStateRequest ()
627
- ).get ();
628
- assertTrue (deleteDecommissionStateResponse .isAcknowledged ());
629
-
630
- // will wait for cluster to stabilise with a timeout of 2 min as by then all nodes should have joined the cluster
631
- ensureStableCluster (6 , TimeValue .timeValueMinutes (2 ));
609
+ deleteDecommissionStateAndWaitForStableCluster (node_in_c , 6 );
632
610
}
633
611
634
612
public void testDecommissionStatusUpdatePublishedToAllNodes () throws ExecutionException , InterruptedException {
@@ -748,20 +726,7 @@ public void testDecommissionStatusUpdatePublishedToAllNodes() throws ExecutionEx
748
726
);
749
727
logger .info ("--> Verified the decommissioned node has in_progress state." );
750
728
751
- // Will wait for all events to complete
752
- client (activeNode ).admin ().cluster ().prepareHealth ().setWaitForEvents (Priority .LANGUID ).get ();
753
- logger .info ("--> Got LANGUID event" );
754
- // Recommissioning the zone back to gracefully succeed the test once above tests succeeds
755
- DeleteDecommissionStateResponse deleteDecommissionStateResponse = client (activeNode ).execute (
756
- DeleteDecommissionStateAction .INSTANCE ,
757
- new DeleteDecommissionStateRequest ()
758
- ).get ();
759
- assertTrue (deleteDecommissionStateResponse .isAcknowledged ());
760
- logger .info ("--> Deleting decommission done." );
761
-
762
- // will wait for cluster to stabilise with a timeout of 2 min (findPeerInterval for decommissioned nodes)
763
- // as by then all nodes should have joined the cluster
764
- ensureStableCluster (6 , TimeValue .timeValueSeconds (121 ));
729
+ deleteDecommissionStateAndWaitForStableCluster (activeNode , 6 );
765
730
}
766
731
767
732
public void testDecommissionFailedWhenAttributeNotWeighedAway () throws Exception {
@@ -983,15 +948,7 @@ public void testDecommissionAcknowledgedIfWeightsNotSetForNonRoutingNode() throw
983
948
assertEquals (clusterState .nodes ().getDataNodes ().size (), 3 );
984
949
assertEquals (clusterState .nodes ().getClusterManagerNodes ().size (), 2 );
985
950
986
- // Recommissioning the zone back to gracefully succeed the test once above tests succeeds
987
- DeleteDecommissionStateResponse deleteDecommissionStateResponse = client (dataNodes .get (0 )).execute (
988
- DeleteDecommissionStateAction .INSTANCE ,
989
- new DeleteDecommissionStateRequest ()
990
- ).get ();
991
- assertTrue (deleteDecommissionStateResponse .isAcknowledged ());
992
-
993
- // will wait for cluster to stabilise with a timeout of 2 min as by then all nodes should have joined the cluster
994
- ensureStableCluster (6 , TimeValue .timeValueMinutes (2 ));
951
+ deleteDecommissionStateAndWaitForStableCluster (dataNodes .get (0 ), 6 );
995
952
}
996
953
997
954
public void testConcurrentDecommissionAction () throws Exception {
@@ -1019,7 +976,7 @@ public void testConcurrentDecommissionAction() throws Exception {
1019
976
.build ()
1020
977
);
1021
978
logger .info ("--> start 3 data nodes on zones 'a' & 'b' & 'c'" );
1022
- internalCluster ().startNodes (
979
+ final String bZoneDataNode = internalCluster ().startNodes (
1023
980
Settings .builder ()
1024
981
.put (commonSettings )
1025
982
.put ("node.attr.zone" , "a" )
@@ -1035,7 +992,7 @@ public void testConcurrentDecommissionAction() throws Exception {
1035
992
.put ("node.attr.zone" , "c" )
1036
993
.put (onlyRole (commonSettings , DiscoveryNodeRole .DATA_ROLE ))
1037
994
.build ()
1038
- );
995
+ ). get ( 1 ) ;
1039
996
1040
997
ensureStableCluster (6 );
1041
998
ClusterHealthResponse health = client ().admin ()
@@ -1100,6 +1057,25 @@ public void testConcurrentDecommissionAction() throws Exception {
1100
1057
assertEquals (concurrentRuns , numRequestAcknowledged .get () + numRequestUnAcknowledged .get () + numRequestFailed .get ());
1101
1058
assertEquals (concurrentRuns - 1 , numRequestFailed .get ());
1102
1059
assertEquals (1 , numRequestAcknowledged .get () + numRequestUnAcknowledged .get ());
1060
+
1061
+ deleteDecommissionStateAndWaitForStableCluster (bZoneDataNode , 6 );
1062
+ }
1063
+
1064
+ private void deleteDecommissionStateAndWaitForStableCluster (String activeNodeName , int expectedClusterSize ) throws ExecutionException ,
1065
+ InterruptedException {
1066
+ client (activeNodeName ).admin ().cluster ().prepareHealth ().setWaitForEvents (Priority .LANGUID ).get ();
1067
+
1068
+ // Recommissioning the zone back to gracefully succeed the test once above tests succeeds
1069
+ DeleteDecommissionStateResponse deleteDecommissionStateResponse = client (activeNodeName ).execute (
1070
+ DeleteDecommissionStateAction .INSTANCE ,
1071
+ new DeleteDecommissionStateRequest ()
1072
+ ).get ();
1073
+ assertTrue (deleteDecommissionStateResponse .isAcknowledged ());
1074
+ logger .info ("--> Deleting decommission done." );
1075
+
1076
+ // will wait for cluster to stabilise with a timeout of 2 min (findPeerInterval for decommissioned nodes)
1077
+ // as by then all nodes should have joined the cluster
1078
+ ensureStableCluster (expectedClusterSize , TimeValue .timeValueSeconds (121 ));
1103
1079
}
1104
1080
1105
1081
private static class WaitForFailedDecommissionState implements ClusterStateObserver .Listener {
0 commit comments