adoroszlai commented on code in PR #6508:
URL: https://github.com/apache/ozone/pull/6508#discussion_r1568763825


##########
hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/fs/TestCachingSpaceUsageSource.java:
##########
@@ -142,6 +143,24 @@ public void savesValueOnShutdown() {
     verify(executor).shutdown();
   }
 
+  @Test
+  public void testDecrementDoesNotGoNegative() {
+    CachingSpaceUsageSource subject;
+    SpaceUsageCheckParams params;
+    AtomicLong cachedValue;
+    cachedValue = new AtomicLong(50);
+    params = paramsBuilder(cachedValue)
+        .withRefresh(Duration.ZERO)
+        .build();
+    subject = new CachingSpaceUsageSource(params);
+    // Try to decrement more than the current value
+    subject.decrementUsedSpace(100);
+
+    // Check that the value has not gone negative and has been reset to 0
+    assertTrue(subject.getUsedSpace() >= 0,

Review Comment:
   > Check ... has been reset to 0
   
   We expect exactly 0, so please use `assertEquals(0, subject.getUsedSpace())`.



##########
hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/fs/TestCachingSpaceUsageSource.java:
##########
@@ -142,6 +143,24 @@ public void savesValueOnShutdown() {
     verify(executor).shutdown();
   }
 
+  @Test
+  public void testDecrementDoesNotGoNegative() {
+    CachingSpaceUsageSource subject;
+    SpaceUsageCheckParams params;
+    AtomicLong cachedValue;

Review Comment:
   nit: please join declaration with assignment.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to