Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,17 @@ public void setup() throws Exception {
volume1 = baseDir.resolve("disk1").toString();
volume2 = baseDir.resolve("disk2").toString();

String dataDirKey = volume1 + "," + volume2;
String dataDirValue = volume1 + "," + volume2;
volumes.add(volume1);
volumes.add(volume2);
conf.set(HDDS_DATANODE_DIR_KEY, dataDirKey);
conf.set(HDDS_DATANODE_DIR_KEY, dataDirValue);
conf.set(OzoneConfigKeys.HDDS_CONTAINER_RATIS_DATANODE_STORAGE_DIR,
dataDirKey);
dataDirValue);
initializeVolumeSet();
}

@AfterEach
public void shutdown() throws IOException {
// Delete the volume root dir
List<StorageVolume> vols = new ArrayList<>();
vols.addAll(volumeSet.getVolumesList());
vols.addAll(volumeSet.getFailedVolumesList());
Expand Down Expand Up @@ -116,13 +115,10 @@ public void testVolumeSetInitialization() throws Exception {

List<StorageVolume> volumesList = volumeSet.getVolumesList();

// VolumeSet initialization should add volume1 and volume2 to VolumeSet
assertEquals(volumesList.size(), volumes.size(),
"VolumeSet initialization is incorrect");
assertTrue(checkVolumeExistsInVolumeSet(volume1),
"VolumeSet not initialized correctly");
assertTrue(checkVolumeExistsInVolumeSet(volume2),
"VolumeSet not initialized correctly");
// VolumeSet initialization should load volume1 and volume2.
assertEquals(volumesList.size(), volumes.size());
assertTrue(checkVolumeExistsInVolumeSet(volume1));
assertTrue(checkVolumeExistsInVolumeSet(volume2));

assertNumVolumes(volumeSet, 2, 0);
}
Expand All @@ -131,20 +127,14 @@ public void testVolumeSetInitialization() throws Exception {
public void testFailVolume() throws Exception {
assertNumVolumes(volumeSet, 2, 0);

//Fail a volume
volumeSet.failVolume(HddsVolumeUtil.getHddsRoot(volume1));

// Failed volume should not show up in the volumeList
assertEquals(1, volumeSet.getVolumesList().size());

// Failed volume should be added to FailedVolumeList
assertEquals(1, volumeSet.getFailedVolumesList().size(),
"Failed volume not present in FailedVolumeMap");
assertEquals(1, volumeSet.getFailedVolumesList().size());
assertEquals(HddsVolumeUtil.getHddsRoot(volume1),
volumeSet.getFailedVolumesList().get(0).getStorageDir().getPath(),
"Failed Volume list did not match");
volumeSet.getFailedVolumesList().get(0).getStorageDir().getPath());

// Failed volume should not exist in VolumeMap
assertThat(volumeSet.getVolumeMap()).doesNotContainKey(volume1);

assertNumVolumes(volumeSet, 1, 1);
Expand All @@ -155,33 +145,23 @@ public void testVolumeInInconsistentState() throws Exception {
assertNumVolumes(volumeSet, 2, 0);
assertEquals(2, volumeSet.getVolumesList().size());

// Add a volume to VolumeSet
String volume3 = baseDir + "disk3";
String volume3 = baseDir.resolve("disk3").toString();

// Create the root volume dir and create a sub-directory within it.
File newVolume = new File(volume3, HDDS_VOLUME_DIR);
System.out.println("new volume root: " + newVolume);
assertTrue(newVolume.mkdirs());
assertTrue(newVolume.exists(), "Failed to create new volume root");
File dataDir = new File(newVolume, "chunks");
assertTrue(dataDir.mkdirs());
assertTrue(dataDir.exists());

// The new volume is in an inconsistent state as the root dir is
// non-empty but the version file does not exist. Add Volume should
// return false.
// Root dir is non-empty but version file is missing, so the volume should not be loaded.
conf.set(ScmConfigKeys.HDDS_DATANODE_DIR_KEY, conf.get(ScmConfigKeys.HDDS_DATANODE_DIR_KEY) + "," + volume3);
volumeSet.shutdown();
initializeVolumeSet();

assertEquals(2, volumeSet.getVolumesList().size());
assertFalse(checkVolumeExistsInVolumeSet(volume3), "AddVolume should fail" +
" for an inconsistent volume");
assertFalse(checkVolumeExistsInVolumeSet(volume3));

assertNumVolumes(volumeSet, 2, 1);
// Delete volume3
File volume = new File(volume3);
FileUtils.deleteDirectory(volume);
FileUtils.deleteDirectory(new File(volume3));
}

@Test
Expand All @@ -191,7 +171,6 @@ public void testShutdown() throws Exception {

volumeSet.shutdown();

// Verify that volume usage can be queried during shutdown.
for (StorageVolume volume : volumesList) {
assertThat(volume.getVolumeUsage()).isNotNull();
volume.getCurrentUsage();
Expand All @@ -200,7 +179,6 @@ public void testShutdown() throws Exception {

@Test
void testFailVolumes(@TempDir File readOnlyVolumePath, @TempDir File volumePath) throws Exception {
//Set to readonly, so that this volume will be failed
assumeThat(readOnlyVolumePath.setReadOnly()).isTrue();
OzoneConfiguration ozoneConfig = new OzoneConfiguration();
ozoneConfig.set(HDDS_DATANODE_DIR_KEY, readOnlyVolumePath.getAbsolutePath()
Expand Down