@@ -72,18 +72,17 @@ public void setup() throws Exception {
7272 volume1 = baseDir .resolve ("disk1" ).toString ();
7373 volume2 = baseDir .resolve ("disk2" ).toString ();
7474
75- String dataDirKey = volume1 + "," + volume2 ;
75+ String dataDirValue = volume1 + "," + volume2 ;
7676 volumes .add (volume1 );
7777 volumes .add (volume2 );
78- conf .set (HDDS_DATANODE_DIR_KEY , dataDirKey );
78+ conf .set (HDDS_DATANODE_DIR_KEY , dataDirValue );
7979 conf .set (OzoneConfigKeys .HDDS_CONTAINER_RATIS_DATANODE_STORAGE_DIR ,
80- dataDirKey );
80+ dataDirValue );
8181 initializeVolumeSet ();
8282 }
8383
8484 @ AfterEach
8585 public void shutdown () throws IOException {
86- // Delete the volume root dir
8786 List <StorageVolume > vols = new ArrayList <>();
8887 vols .addAll (volumeSet .getVolumesList ());
8988 vols .addAll (volumeSet .getFailedVolumesList ());
@@ -116,13 +115,10 @@ public void testVolumeSetInitialization() throws Exception {
116115
117116 List <StorageVolume > volumesList = volumeSet .getVolumesList ();
118117
119- // VolumeSet initialization should add volume1 and volume2 to VolumeSet
120- assertEquals (volumesList .size (), volumes .size (),
121- "VolumeSet initialization is incorrect" );
122- assertTrue (checkVolumeExistsInVolumeSet (volume1 ),
123- "VolumeSet not initialized correctly" );
124- assertTrue (checkVolumeExistsInVolumeSet (volume2 ),
125- "VolumeSet not initialized correctly" );
118+ // VolumeSet initialization should load volume1 and volume2.
119+ assertEquals (volumesList .size (), volumes .size ());
120+ assertTrue (checkVolumeExistsInVolumeSet (volume1 ));
121+ assertTrue (checkVolumeExistsInVolumeSet (volume2 ));
126122
127123 assertNumVolumes (volumeSet , 2 , 0 );
128124 }
@@ -131,20 +127,14 @@ public void testVolumeSetInitialization() throws Exception {
131127 public void testFailVolume () throws Exception {
132128 assertNumVolumes (volumeSet , 2 , 0 );
133129
134- //Fail a volume
135130 volumeSet .failVolume (HddsVolumeUtil .getHddsRoot (volume1 ));
136131
137- // Failed volume should not show up in the volumeList
138132 assertEquals (1 , volumeSet .getVolumesList ().size ());
139133
140- // Failed volume should be added to FailedVolumeList
141- assertEquals (1 , volumeSet .getFailedVolumesList ().size (),
142- "Failed volume not present in FailedVolumeMap" );
134+ assertEquals (1 , volumeSet .getFailedVolumesList ().size ());
143135 assertEquals (HddsVolumeUtil .getHddsRoot (volume1 ),
144- volumeSet .getFailedVolumesList ().get (0 ).getStorageDir ().getPath (),
145- "Failed Volume list did not match" );
136+ volumeSet .getFailedVolumesList ().get (0 ).getStorageDir ().getPath ());
146137
147- // Failed volume should not exist in VolumeMap
148138 assertThat (volumeSet .getVolumeMap ()).doesNotContainKey (volume1 );
149139
150140 assertNumVolumes (volumeSet , 1 , 1 );
@@ -155,33 +145,23 @@ public void testVolumeInInconsistentState() throws Exception {
155145 assertNumVolumes (volumeSet , 2 , 0 );
156146 assertEquals (2 , volumeSet .getVolumesList ().size ());
157147
158- // Add a volume to VolumeSet
159- String volume3 = baseDir + "disk3" ;
148+ String volume3 = baseDir .resolve ("disk3" ).toString ();
160149
161- // Create the root volume dir and create a sub-directory within it.
162150 File newVolume = new File (volume3 , HDDS_VOLUME_DIR );
163- System .out .println ("new volume root: " + newVolume );
164151 assertTrue (newVolume .mkdirs ());
165- assertTrue (newVolume .exists (), "Failed to create new volume root" );
166152 File dataDir = new File (newVolume , "chunks" );
167153 assertTrue (dataDir .mkdirs ());
168- assertTrue (dataDir .exists ());
169154
170- // The new volume is in an inconsistent state as the root dir is
171- // non-empty but the version file does not exist. Add Volume should
172- // return false.
155+ // Root dir is non-empty but version file is missing, so the volume should not be loaded.
173156 conf .set (ScmConfigKeys .HDDS_DATANODE_DIR_KEY , conf .get (ScmConfigKeys .HDDS_DATANODE_DIR_KEY ) + "," + volume3 );
174157 volumeSet .shutdown ();
175158 initializeVolumeSet ();
176159
177160 assertEquals (2 , volumeSet .getVolumesList ().size ());
178- assertFalse (checkVolumeExistsInVolumeSet (volume3 ), "AddVolume should fail" +
179- " for an inconsistent volume" );
161+ assertFalse (checkVolumeExistsInVolumeSet (volume3 ));
180162
181163 assertNumVolumes (volumeSet , 2 , 1 );
182- // Delete volume3
183- File volume = new File (volume3 );
184- FileUtils .deleteDirectory (volume );
164+ FileUtils .deleteDirectory (new File (volume3 ));
185165 }
186166
187167 @ Test
@@ -191,7 +171,6 @@ public void testShutdown() throws Exception {
191171
192172 volumeSet .shutdown ();
193173
194- // Verify that volume usage can be queried during shutdown.
195174 for (StorageVolume volume : volumesList ) {
196175 assertThat (volume .getVolumeUsage ()).isNotNull ();
197176 volume .getCurrentUsage ();
@@ -200,7 +179,6 @@ public void testShutdown() throws Exception {
200179
201180 @ Test
202181 void testFailVolumes (@ TempDir File readOnlyVolumePath , @ TempDir File volumePath ) throws Exception {
203- //Set to readonly, so that this volume will be failed
204182 assumeThat (readOnlyVolumePath .setReadOnly ()).isTrue ();
205183 OzoneConfiguration ozoneConfig = new OzoneConfiguration ();
206184 ozoneConfig .set (HDDS_DATANODE_DIR_KEY , readOnlyVolumePath .getAbsolutePath ()
0 commit comments