public virtual void TestDNWithInvalidStorageWithHA() { MiniDFSNNTopology top = new MiniDFSNNTopology().AddNameservice(new MiniDFSNNTopology.NSConf ("ns1").AddNN(new MiniDFSNNTopology.NNConf("nn0").SetClusterId("cluster-1")).AddNN (new MiniDFSNNTopology.NNConf("nn1").SetClusterId("cluster-1"))); top.SetFederation(true); MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).NnTopology(top).NumDataNodes (0).Build(); try { cluster.StartDataNodes(conf, 1, true, null, null); // let the initialization be complete Sharpen.Thread.Sleep(10000); DataNode dn = cluster.GetDataNodes()[0]; NUnit.Framework.Assert.IsTrue("Datanode should be running", dn.IsDatanodeUp()); NUnit.Framework.Assert.AreEqual("BPOfferService should be running", 1, dn.GetAllBpOs ().Length); MiniDFSCluster.DataNodeProperties dnProp = cluster.StopDataNode(0); cluster.GetNameNode(0).Stop(); cluster.GetNameNode(1).Stop(); Configuration nn1 = cluster.GetConfiguration(0); Configuration nn2 = cluster.GetConfiguration(1); // setting up invalid cluster HdfsServerConstants.StartupOption.Format.SetClusterId("cluster-2"); DFSTestUtil.FormatNameNode(nn1); MiniDFSCluster.CopyNameDirs(FSNamesystem.GetNamespaceDirs(nn1), FSNamesystem.GetNamespaceDirs (nn2), nn2); cluster.RestartNameNode(0, false); cluster.RestartNameNode(1, false); cluster.RestartDataNode(dnProp); // let the initialization be complete Sharpen.Thread.Sleep(10000); dn = cluster.GetDataNodes()[0]; NUnit.Framework.Assert.IsFalse("Datanode should have shutdown as only service failed" , dn.IsDatanodeUp()); } finally { cluster.Shutdown(); } }