This is an automated email from the ASF dual-hosted git repository.

awong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 7dff767a8ebd6ea4d61c78ea84ebaeb85e0f07d4
Author: Andrew Wong <[email protected]>
AuthorDate: Fri Mar 20 20:53:09 2020 -0700

    test: add some buffer in timing metrics
    
    We've seen some flakiness in TestEchoSubprocess where the time is off by
    1ms, with logs like:
    
    [ERROR - main] (RetryRule.java:219) 
org.apache.kudu.subprocess.echo.TestEchoSubprocess.testSlowWriterMetrics: 
failed attempt 1
    java.lang.AssertionError: Expected a higher outbound queue time: 399 ms
        at org.junit.Assert.fail(Assert.java:89) ~[junit-4.13.jar:4.13]
        at org.junit.Assert.assertTrue(Assert.java:42) ~[junit-4.13.jar:4.13]
        at 
org.apache.kudu.subprocess.echo.TestEchoSubprocess.testSlowWriterMetrics(TestEchoSubprocess.java:194)
 ~[test/:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
~[?:1.8.0_141]
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
~[?:1.8.0_141]
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 ~[?:1.8.0_141]
            ...
    
    This patch adds some buffer (5ms to be conservative) to allow for some
    small errors.
    
    Change-Id: I5a96dd3804cedece2faf16b28d5c48396d87bcb7
    Reviewed-on: http://gerrit.cloudera.org:8080/15518
    Reviewed-by: Adar Dembo <[email protected]>
    Tested-by: Kudu Jenkins
---
 .../java/org/apache/kudu/subprocess/echo/TestEchoSubprocess.java   | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git 
a/java/kudu-subprocess/src/test/java/org/apache/kudu/subprocess/echo/TestEchoSubprocess.java
 
b/java/kudu-subprocess/src/test/java/org/apache/kudu/subprocess/echo/TestEchoSubprocess.java
index 294e643..704d036 100644
--- 
a/java/kudu-subprocess/src/test/java/org/apache/kudu/subprocess/echo/TestEchoSubprocess.java
+++ 
b/java/kudu-subprocess/src/test/java/org/apache/kudu/subprocess/echo/TestEchoSubprocess.java
@@ -186,17 +186,20 @@ public class TestEchoSubprocess extends 
SubprocessTestUtil {
     SubprocessMetricsPB m = receiveResponse().getMetrics();
     Assert.assertEquals(2, m.getOutboundQueueLength());
 
+    // NOTE: timing on the exact slept time sometimes yields a small error, so
+    // leave some buffer in checking for correctness.
+    final int BUFFER_MS = 5;
     m = receiveResponse().getMetrics();
     Assert.assertEquals(1, m.getOutboundQueueLength());
     Assert.assertTrue(
         String.format("Expected a higher outbound queue time: %s ms", 
m.getOutboundQueueTimeMs()),
-        m.getOutboundQueueTimeMs() >= BLOCK_MS);
+        m.getOutboundQueueTimeMs() + BUFFER_MS >= BLOCK_MS);
 
     m = receiveResponse().getMetrics();
     Assert.assertEquals(0, m.getOutboundQueueLength());
     Assert.assertTrue(
         String.format("Expected a higher outbound queue time: %s ms", 
m.getOutboundQueueTimeMs()),
-        m.getOutboundQueueTimeMs() >= 2 * BLOCK_MS);
+        m.getOutboundQueueTimeMs() + BUFFER_MS >= 2 * BLOCK_MS);
   }
 
   /**

Reply via email to