42
42
import java .util .Locale ;
43
43
44
44
import static org .elasticsearch .action .support .WriteRequest .RefreshPolicy .IMMEDIATE ;
45
+ import static org .elasticsearch .gateway .DanglingIndicesState .AUTO_IMPORT_DANGLING_INDICES_SETTING ;
45
46
import static org .elasticsearch .index .query .QueryBuilders .matchAllQuery ;
46
47
import static org .elasticsearch .indices .recovery .RecoverySettings .INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING ;
47
48
import static org .elasticsearch .test .NodeRoles .nonMasterNode ;
@@ -314,11 +315,15 @@ public void test3MasterNodes2Failed() throws Exception {
314
315
public void testAllMasterEligibleNodesFailedDanglingIndexImport () throws Exception {
315
316
internalCluster ().setBootstrapMasterNodeIndex (0 );
316
317
318
+ Settings settings = Settings .builder ()
319
+ .put (AUTO_IMPORT_DANGLING_INDICES_SETTING .getKey (), true )
320
+ .build ();
321
+
317
322
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
319
324
320
325
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
322
327
ensureStableCluster (2 );
323
328
324
329
logger .info ("--> index 1 doc and ensure index is green" );
@@ -332,11 +337,18 @@ public void testAllMasterEligibleNodesFailedDanglingIndexImport() throws Excepti
332
337
assertThat (client ().prepareGet ("test" , "1" ).execute ().actionGet ().isExists (), equalTo (true ));
333
338
334
339
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 ();
336
344
assertBusy (() -> internalCluster ().getInstance (GatewayMetaState .class , dataNode ).allPendingAsyncStatesWritten ());
337
345
internalCluster ().stopRandomNode (InternalTestCluster .nameFilter (dataNode ));
338
346
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 ());
340
352
detachCluster (environment , false );
341
353
342
354
logger .info ("--> stop master-eligible node, clear its data and start it again - new cluster should form" );
0 commit comments