4242import java .util .Locale ;
4343
4444import static org .elasticsearch .action .support .WriteRequest .RefreshPolicy .IMMEDIATE ;
45+ import static org .elasticsearch .gateway .DanglingIndicesState .AUTO_IMPORT_DANGLING_INDICES_SETTING ;
4546import static org .elasticsearch .index .query .QueryBuilders .matchAllQuery ;
4647import static org .elasticsearch .indices .recovery .RecoverySettings .INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING ;
4748import static org .elasticsearch .test .NodeRoles .nonMasterNode ;
@@ -314,11 +315,15 @@ public void test3MasterNodes2Failed() throws Exception {
314315 public void testAllMasterEligibleNodesFailedDanglingIndexImport () throws Exception {
315316 internalCluster ().setBootstrapMasterNodeIndex (0 );
316317
318+ Settings settings = Settings .builder ()
319+ .put (AUTO_IMPORT_DANGLING_INDICES_SETTING .getKey (), true )
320+ .build ();
321+
317322 logger .info ("--> start mixed data and master-eligible node and bootstrap cluster" );
318- String masterNode = internalCluster ().startNode (); // node ordinal 0
323+ String masterNode = internalCluster ().startNode (settings ); // node ordinal 0
319324
320325 logger .info ("--> start data-only node and ensure 2 nodes stable cluster" );
321- String dataNode = internalCluster ().startDataOnlyNode (); // node ordinal 1
326+ String dataNode = internalCluster ().startDataOnlyNode (settings ); // node ordinal 1
322327 ensureStableCluster (2 );
323328
324329 logger .info ("--> index 1 doc and ensure index is green" );
@@ -332,11 +337,18 @@ public void testAllMasterEligibleNodesFailedDanglingIndexImport() throws Excepti
332337 assertThat (client ().prepareGet ("test" , "1" ).execute ().actionGet ().isExists (), equalTo (true ));
333338
334339 logger .info ("--> stop data-only node and detach it from the old cluster" );
335- Settings dataNodeDataPathSettings = internalCluster ().dataPathSettings (dataNode );
340+ Settings dataNodeDataPathSettings = Settings .builder ()
341+ .put (internalCluster ().dataPathSettings (dataNode ), true )
342+ .put (AUTO_IMPORT_DANGLING_INDICES_SETTING .getKey (), true )
343+ .build ();
336344 assertBusy (() -> internalCluster ().getInstance (GatewayMetaState .class , dataNode ).allPendingAsyncStatesWritten ());
337345 internalCluster ().stopRandomNode (InternalTestCluster .nameFilter (dataNode ));
338346 final Environment environment = TestEnvironment .newEnvironment (
339- Settings .builder ().put (internalCluster ().getDefaultSettings ()).put (dataNodeDataPathSettings ).build ());
347+ Settings .builder ()
348+ .put (internalCluster ().getDefaultSettings ())
349+ .put (dataNodeDataPathSettings )
350+ .put (AUTO_IMPORT_DANGLING_INDICES_SETTING .getKey (), true )
351+ .build ());
340352 detachCluster (environment , false );
341353
342354 logger .info ("--> stop master-eligible node, clear its data and start it again - new cluster should form" );
0 commit comments