You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Russole (via GitHub)" <gi...@apache.org> on 2026/02/15 09:26:12 UTC
[PR] HDDS-14627. Code cleanup in TestVolumeSet [ozone]
Russole opened a new pull request, #9769:
URL: https://github.com/apache/ozone/pull/9769
## What changes were proposed in this pull request?
* Rename dataDirKey, since it's a config value, not key
* Remove useless messages from assertions
* Remove comments that repeat code in other words
* Remove reference to "Add Volume", which no longer exists
## What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-14627
## How was this patch tested?
- All tests passed except those currently pending fixes
- https://github.com/Russole/ozone/actions/runs/22027708631
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14627. Code cleanup in TestVolumeSet [ozone]
Posted by "sarvekshayr (via GitHub)" <gi...@apache.org>.
sarvekshayr commented on code in PR #9769:
URL: https://github.com/apache/ozone/pull/9769#discussion_r2813323730
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/volume/TestVolumeSet.java:
##########
@@ -155,33 +145,24 @@ 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());
Review Comment:
Let's remove the redundant check here as well.
```suggestion
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14627. Code cleanup in TestVolumeSet [ozone]
Posted by "sreejasahithi (via GitHub)" <gi...@apache.org>.
sreejasahithi commented on code in PR #9769:
URL: https://github.com/apache/ozone/pull/9769#discussion_r2812843843
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/volume/TestVolumeSet.java:
##########
@@ -155,31 +145,24 @@ 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");
+ assertTrue(newVolume.exists());
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);
Review Comment:
nit: Since this variable is only used when calling deleteDirectory, we can avoid creating a separate variable
```suggestion
FileUtils.deleteDirectory(new File(volume3));
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14627. Code cleanup in TestVolumeSet [ozone]
Posted by "sarvekshayr (via GitHub)" <gi...@apache.org>.
sarvekshayr merged PR #9769:
URL: https://github.com/apache/ozone/pull/9769
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14627. Code cleanup in TestVolumeSet [ozone]
Posted by "Russole (via GitHub)" <gi...@apache.org>.
Russole commented on PR #9769:
URL: https://github.com/apache/ozone/pull/9769#issuecomment-3906161375
Thanks @Gargi-jais11 for the review.
I've updated it based on the comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14627. Code cleanup in TestVolumeSet [ozone]
Posted by "sreejasahithi (via GitHub)" <gi...@apache.org>.
sreejasahithi commented on code in PR #9769:
URL: https://github.com/apache/ozone/pull/9769#discussion_r2812930835
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/volume/TestVolumeSet.java:
##########
@@ -155,31 +145,24 @@ 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");
+ assertTrue(newVolume.exists());
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);
Review Comment:
Thanks @sarvekshayr , done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14627. Code cleanup in TestVolumeSet [ozone]
Posted by "sarvekshayr (via GitHub)" <gi...@apache.org>.
sarvekshayr commented on PR #9769:
URL: https://github.com/apache/ozone/pull/9769#issuecomment-3913955714
Thanks @Russole for the patch, @Gargi-jais11 and @sreejasahithi for the review.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14627. Code cleanup in TestVolumeSet [ozone]
Posted by "sreejasahithi (via GitHub)" <gi...@apache.org>.
sreejasahithi commented on code in PR #9769:
URL: https://github.com/apache/ozone/pull/9769#discussion_r2812843843
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/volume/TestVolumeSet.java:
##########
@@ -155,31 +145,24 @@ 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");
+ assertTrue(newVolume.exists());
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);
Review Comment:
nit: Since this variable is only used when calling deleteDirectory, we can avoid creating a separate variable
```suggestion
FileUtils.deleteDirectory(new File(volume3));
```
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/volume/TestVolumeSet.java:
##########
@@ -155,31 +145,24 @@ 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");
+ assertTrue(newVolume.exists());
Review Comment:
mkdirs() returns true on success, so the exists() check immediately after is redundant
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14627. Code cleanup in TestVolumeSet [ozone]
Posted by "Gargi-jais11 (via GitHub)" <gi...@apache.org>.
Gargi-jais11 commented on code in PR #9769:
URL: https://github.com/apache/ozone/pull/9769#discussion_r2809797817
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/volume/TestVolumeSet.java:
##########
@@ -155,31 +145,24 @@ public void testVolumeInInconsistentState() throws Exception {
assertNumVolumes(volumeSet, 2, 0);
assertEquals(2, volumeSet.getVolumesList().size());
- // Add a volume to VolumeSet
String volume3 = baseDir + "disk3";
Review Comment:
Nit: Let's make this consistent with how other volumes are added.
```suggestion
String volume3 = baseDir.resolve("disk3").toString();
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14627. Code cleanup in TestVolumeSet [ozone]
Posted by "sreejasahithi (via GitHub)" <gi...@apache.org>.
sreejasahithi commented on code in PR #9769:
URL: https://github.com/apache/ozone/pull/9769#discussion_r2812930835
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/volume/TestVolumeSet.java:
##########
@@ -155,31 +145,24 @@ 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");
+ assertTrue(newVolume.exists());
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);
Review Comment:
Thanks , done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14627. Code cleanup in TestVolumeSet [ozone]
Posted by "sarvekshayr (via GitHub)" <gi...@apache.org>.
sarvekshayr commented on code in PR #9769:
URL: https://github.com/apache/ozone/pull/9769#discussion_r2812924099
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/volume/TestVolumeSet.java:
##########
@@ -155,31 +145,24 @@ 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");
+ assertTrue(newVolume.exists());
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);
Review Comment:
@sreejasahithi Please ensure the suggested changes follow the correct indentation, as applying them directly may introduce formatting issues.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14627. Code cleanup in TestVolumeSet [ozone]
Posted by "Russole (via GitHub)" <gi...@apache.org>.
Russole commented on PR #9769:
URL: https://github.com/apache/ozone/pull/9769#issuecomment-3909468153
Thanks @sarvekshayr, @sreejasahithi for the review.
I’ve updated the patch based on the comments.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org