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


##########
hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/fs/TestCachingSpaceUsageSource.java:
##########
@@ -142,6 +143,28 @@ 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
+    assertTrue(subject.getUsedSpace() >= 0,
+        "Cached used space should not be negative");
+
+    // Check that it has retained the previous value
+    assertEquals(50, subject.getUsedSpace(),
+        "Cached used space should remain at the initial value");

Review Comment:
   Looks like this assertion needs to be updated:
   
   ```
   Error:  TestCachingSpaceUsageSource.testDecrementDoesNotGoNegative  Time 
elapsed: 0.028 s  <<< FAILURE!
   AssertionFailedError: Cached used space should remain at the initial value 
==> expected: <50> but was: <0>
   ```



-- 
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