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

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

commit f9263e446ffb84604f12d782530050fc08245e72
Author: Will Berkeley <[email protected]>
AuthorDate: Tue Apr 30 16:01:24 2019 -0700

    Deflake TestTimeouts.testLowTimeouts
    
    It turns out that if a ConnectToCluster "RPC" results in an RPC to each
    master and each of those RPCs times out, the ConnectToCluster RPC ends
    up with a ServiceUnavailable status, not a TimedOut status. This updates
    the test to reflect this.
    
    Before this patch, I saw 58/200 failures; after it I saw zero. The
    58/200 seems big compared to the frequency of this in precommits, etc,
    but anyway this fix ought to help regardless of how frequent the
    problem is.
    
    Change-Id: I7d1a429fe5749c31495e0d10f74a0cfb1e623310
    Reviewed-on: http://gerrit.cloudera.org:8080/13202
    Tested-by: Kudu Jenkins
    Reviewed-by: Adar Dembo <[email protected]>
    Reviewed-by: Alexey Serbin <[email protected]>
---
 .../src/main/java/org/apache/kudu/client/KuduRpc.java        |  2 +-
 .../src/test/java/org/apache/kudu/client/TestTimeouts.java   | 12 +++++++++---
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/KuduRpc.java 
b/java/kudu-client/src/main/java/org/apache/kudu/client/KuduRpc.java
index 6abacd3..d9a223a 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/KuduRpc.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/KuduRpc.java
@@ -451,7 +451,7 @@ public abstract class KuduRpc<R> {
   final class RpcTimeoutTask implements TimerTask {
     @Override
     public void run(final Timeout timeout) {
-      Status statusTimedOut = Status.TimedOut("can not complete before 
timeout: " + KuduRpc.this);
+      Status statusTimedOut = Status.TimedOut("cannot complete before timeout: 
" + KuduRpc.this);
       KuduRpc.this.errback(new NonRecoverableException(statusTimedOut));
     }
   }
diff --git 
a/java/kudu-client/src/test/java/org/apache/kudu/client/TestTimeouts.java 
b/java/kudu-client/src/test/java/org/apache/kudu/client/TestTimeouts.java
index 9b09fde..4af6ef6 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestTimeouts.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestTimeouts.java
@@ -39,7 +39,7 @@ public class TestTimeouts {
   public KuduTestHarness harness = new KuduTestHarness();
 
   /**
-   * This test case tries different methods that should all timeout, while 
relying on the client to
+   * This test case tries different methods that should all time out, while 
relying on the client to
    * pass down the timeouts to the session and scanner.
    * TODO(aserbin) this test is flaky; add delays on the server side to make 
it stable
    */
@@ -54,7 +54,11 @@ public class TestTimeouts {
         lowTimeoutsClient.listTabletServers();
         fail("Should have timed out");
       } catch (KuduException ex) {
-        // Expected.
+        // The operation can time out directly, leading to a TimedOut status, 
or it can time out
+        // while trying to contact each of the masters (e.g. while trying to 
find the leader master
+        // in the case where there is a master election).
+        Status failureStatus = ex.getStatus();
+        assertTrue(failureStatus.isTimedOut() || 
failureStatus.isServiceUnavailable());
       }
 
       harness.getClient().createTable(TABLE_NAME, getBasicSchema(), 
getBasicCreateTableOptions());
@@ -73,7 +77,9 @@ public class TestTimeouts {
         lowTimeoutScanner.nextRows();
         fail("Should have timed out");
       } catch (KuduException ex) {
-        assertTrue(ex.getStatus().isTimedOut());
+        // See the previous catch block.
+        Status failureStatus = ex.getStatus();
+        assertTrue(failureStatus.isTimedOut() || 
failureStatus.isServiceUnavailable());
       }
     }
   }

Reply via email to