use of org.apache.hadoop.ozone.HddsDatanodeService in project ozone by apache.
the class TestDatanodeHddsVolumeFailureToleration method testDNCorrectlyHandlesVolumeFailureOnStartup.
@Test
public void testDNCorrectlyHandlesVolumeFailureOnStartup() throws Exception {
HddsDatanodeService dn = datanodes.get(0);
OzoneContainer oc = dn.getDatanodeStateMachine().getContainer();
MutableVolumeSet volSet = oc.getVolumeSet();
StorageVolume vol0 = volSet.getVolumesList().get(0);
StorageVolume vol1 = volSet.getVolumesList().get(1);
File volRootDir0 = vol0.getStorageDir();
File volRootDir1 = vol1.getStorageDir();
// simulate bad volumes <= tolerated
DatanodeTestUtils.simulateBadRootDir(volRootDir0);
// restart datanode to test
cluster.restartHddsDatanode(0, true);
// no exception is good
// fail a second volume
DatanodeTestUtils.simulateBadRootDir(volRootDir1);
// restart datanode to test
try {
cluster.restartHddsDatanode(0, true);
Assert.fail();
} catch (RuntimeException e) {
Assert.assertTrue(e.getMessage().contains("Can't start the HDDS datanode plugin"));
}
// restore bad volumes
DatanodeTestUtils.restoreBadRootDir(volRootDir0);
DatanodeTestUtils.restoreBadRootDir(volRootDir1);
}
Aggregations