2424import org .elasticsearch .test .ESIntegTestCase ;
2525import org .hamcrest .Matcher ;
2626
27- import java .util .List ;
28-
2927import static org .hamcrest .Matchers .allOf ;
3028import static org .hamcrest .Matchers .containsString ;
3129import static org .hamcrest .Matchers .not ;
@@ -38,12 +36,13 @@ public void testRepurpose() throws Exception {
3836 final String indexName = "test-repurpose" ;
3937
4038 logger .info ("--> starting two nodes" );
41- final List <String > nodes = internalCluster ().startNodes (2 );
39+ internalCluster ().startMasterOnlyNode ();
40+ internalCluster ().startDataOnlyNode ();
4241
4342 logger .info ("--> creating index" );
4443 prepareCreate (indexName , Settings .builder ()
4544 .put ("index.number_of_shards" , 1 )
46- .put ("index.number_of_replicas" , 1 )
45+ .put ("index.number_of_replicas" , 0 )
4746 ).get ();
4847 final String indexUUID = resolveIndex (indexName ).getUUID ();
4948
@@ -65,40 +64,40 @@ public void testRepurpose() throws Exception {
6564 logger .info ("--> restarting node with node.data=false and node.master=false" );
6665 IllegalStateException ex = expectThrows (IllegalStateException .class ,
6766 "Node started with node.data=false and node.master=false while having existing index metadata must fail" ,
68- () -> internalCluster ().startNode ( noMasterNoDataSettings )
67+ () -> internalCluster ().startCoordinatingOnlyNode ( Settings . EMPTY )
6968 );
7069
71- int runningOrdinal = nodes .indexOf (internalCluster ().getNodeNames ()[0 ]);
72- int stoppedOrdinal = 1 -runningOrdinal ;
73-
74- logger .info ("--> Repurposing node" );
75- executeRepurposeCommandForOrdinal (noMasterNoDataSettings , indexUUID , stoppedOrdinal );
70+ logger .info ("--> Repurposing node 1" );
71+ executeRepurposeCommandForOrdinal (noMasterNoDataSettings , indexUUID , 1 );
7672
7773 ElasticsearchException lockedException = expectThrows (ElasticsearchException .class ,
78- () -> executeRepurposeCommandForOrdinal (noMasterNoDataSettings , indexUUID , runningOrdinal )
74+ () -> executeRepurposeCommandForOrdinal (noMasterNoDataSettings , indexUUID , 0 )
7975 );
8076
8177 assertThat (lockedException .getMessage (), containsString (NodeRepurposeCommand .FAILED_TO_OBTAIN_NODE_LOCK_MSG ));
8278
8379 logger .info ("--> Starting node after repurpose" );
84- nodes . set ( stoppedOrdinal , internalCluster ().startNode ( noMasterNoDataSettings ) );
80+ internalCluster ().startCoordinatingOnlyNode ( Settings . EMPTY );
8581
86- ensureYellow ();
82+ ensureGreen ();
8783
88- assertTrue (client ().prepareGet (indexName , "type1" , "1" ).get ().isExists ());
84+ // docs gone
85+ assertFalse (client ().prepareGet (indexName , "type1" , "1" ).get ().isExists ());
8986 assertTrue (indexExists (indexName ));
9087
9188 logger .info ("--> Restarting and repurposing other node" );
9289
9390 internalCluster ().stopRandomNode (s -> true );
9491 internalCluster ().stopRandomNode (s -> true );
9592
96- executeRepurposeCommandForOrdinal (noMasterNoDataSettings , indexUUID , runningOrdinal );
93+ executeRepurposeCommandForOrdinal (noMasterNoDataSettings , indexUUID , 0 );
94+
95+ internalCluster ().startMasterOnlyNode ();
96+ internalCluster ().startDataOnlyNode ();
9797
98- internalCluster ().startNodes (2 );
9998 ensureGreen ();
10099
101- // indexes and docs gone.
100+ // indexes gone.
102101 assertFalse (indexExists (indexName ));
103102 }
104103
0 commit comments