fvaleri commented on code in PR #13784:
URL: https://github.com/apache/kafka/pull/13784#discussion_r1211224639


##########
tools/src/test/java/org/apache/kafka/tools/MetadataQuorumCommandErrorTest.java:
##########
@@ -53,12 +53,12 @@ public void testDescribeOptions() {
 
     @Test
     public void testRelativeTimeMs() {
-        long nowMs = Instant.now().toEpochMilli();
-        assertTrue(MetadataQuorumCommand.relativeTimeMs(nowMs, "test") >= 0);
-        long invalidEpochMs = Instant.EPOCH.minus(1, 
ChronoUnit.DAYS).toEpochMilli();
+        long validEpochMs = Instant.now().minusSeconds(5).toEpochMilli();
+        assertTrue(MetadataQuorumCommand.relativeTimeMs(validEpochMs, "test") 
>= 0);
+        long invalidEpochMs = Instant.EPOCH.minusSeconds(86400).toEpochMilli();
         assertThrows(KafkaException.class, () -> 
MetadataQuorumCommand.relativeTimeMs(invalidEpochMs, "test"));
-        long futureTimestampMs = Instant.now().plus(1, 
ChronoUnit.DAYS).toEpochMilli();
-        assertThrows(KafkaException.class, () -> 
MetadataQuorumCommand.relativeTimeMs(futureTimestampMs, "test"));
+        long futureEpochMs = Instant.now().plus(1, 
ChronoUnit.DAYS).toEpochMilli();
+        assertThrows(KafkaException.class, () -> 
MetadataQuorumCommand.relativeTimeMs(futureEpochMs, "test"));

Review Comment:
   Yeah, I was thinking the same. The check now is `epoch < timestamp < now`, 
but it should be `epoch < timestamp <= now`. In the last commit I fixed 
`relativeTimeMs` and added back the `nowMs` check. Thanks for the review.



##########
tools/src/test/java/org/apache/kafka/tools/MetadataQuorumCommandErrorTest.java:
##########
@@ -53,12 +53,12 @@ public void testDescribeOptions() {
 
     @Test
     public void testRelativeTimeMs() {
-        long nowMs = Instant.now().toEpochMilli();
-        assertTrue(MetadataQuorumCommand.relativeTimeMs(nowMs, "test") >= 0);
-        long invalidEpochMs = Instant.EPOCH.minus(1, 
ChronoUnit.DAYS).toEpochMilli();
+        long validEpochMs = Instant.now().minusSeconds(5).toEpochMilli();
+        assertTrue(MetadataQuorumCommand.relativeTimeMs(validEpochMs, "test") 
>= 0);
+        long invalidEpochMs = Instant.EPOCH.minusSeconds(86400).toEpochMilli();
         assertThrows(KafkaException.class, () -> 
MetadataQuorumCommand.relativeTimeMs(invalidEpochMs, "test"));
-        long futureTimestampMs = Instant.now().plus(1, 
ChronoUnit.DAYS).toEpochMilli();
-        assertThrows(KafkaException.class, () -> 
MetadataQuorumCommand.relativeTimeMs(futureTimestampMs, "test"));
+        long futureEpochMs = Instant.now().plus(1, 
ChronoUnit.DAYS).toEpochMilli();
+        assertThrows(KafkaException.class, () -> 
MetadataQuorumCommand.relativeTimeMs(futureEpochMs, "test"));

Review Comment:
   Yeah, I was thinking the same. The check now is `epoch < timestamp < now`, 
but it should be `epoch < timestamp <= now`. In the last commit I fixed 
`relativeTimeMs` and added back the `nowMs` check.
   
   Thanks 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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to