kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danburk...@apache.org
Subject kudu git commit: java-client: fix TestScannerMultiTablet
Date Tue, 28 Nov 2017 00:21:49 GMT
Repository: kudu
Updated Branches:
  refs/heads/master f2d1dad67 -> 0aa4af56c


java-client: fix TestScannerMultiTablet

TestScannerMultiTablet could fail when the test cases were run in a
certain order, due to state left between test runs.

Change-Id: Iae3e1c7a6a48714f59379c06aca413e3d7cde7a5
Reviewed-on: http://gerrit.cloudera.org:8080/8655
Reviewed-by: Andrew Wong <awong@cloudera.com>
Tested-by: Kudu Jenkins


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/0aa4af56
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/0aa4af56
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/0aa4af56

Branch: refs/heads/master
Commit: 0aa4af56c6a7e9d33e7dda3a64412aadf6c4c300
Parents: f2d1dad
Author: Dan Burkert <danburkert@apache.org>
Authored: Mon Nov 27 15:03:18 2017 -0800
Committer: Dan Burkert <danburkert@apache.org>
Committed: Tue Nov 28 00:21:37 2017 +0000

----------------------------------------------------------------------
 .../org/apache/kudu/client/BaseKuduTest.java    | 20 +++++++++++++++-----
 .../kudu/client/TestScannerMultiTablet.java     |  3 +++
 2 files changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/0aa4af56/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java b/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java
index fc6f303..c1f8564 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java
@@ -83,10 +83,8 @@ public class BaseKuduTest {
   public static void tearDownAfterClass() throws Exception {
     try {
       if (client != null) {
-        Deferred<ArrayList<Void>> d = client.shutdown();
-        d.addErrback(defaultErrorCB);
-        d.join(DEFAULT_SLEEP);
-        // No need to explicitly shutdown the sync client,
+        syncClient.shutdown();
+        // No need to explicitly shutdown the async client,
         // shutting down the async client effectively does that.
       }
     } finally {
@@ -120,7 +118,7 @@ public class BaseKuduTest {
     client = new AsyncKuduClient.AsyncKuduClientBuilder(masterAddresses)
         .defaultAdminOperationTimeoutMs(DEFAULT_SLEEP)
         .build();
-    syncClient = new KuduClient(client);
+    syncClient = client.syncClient();
   }
 
   protected static KuduTable createTable(String tableName, Schema schema,
@@ -495,4 +493,16 @@ public class BaseKuduTest {
   protected void restartTabletServers() throws IOException {
     miniCluster.restartDeadTservers();
   }
+
+  /**
+   * Resets the clients so that their state is completely fresh, including meta
+   * cache, connections, open tables, sessions and scanners, and propagated timestamp.
+   */
+  protected void resetClients() throws IOException {
+    syncClient.shutdown();
+    client = new AsyncKuduClient.AsyncKuduClientBuilder(masterAddresses)
+                                .defaultAdminOperationTimeoutMs(DEFAULT_SLEEP)
+                                .build();
+    syncClient = client.syncClient();
+  }
 }

http://git-wip-us.apache.org/repos/asf/kudu/blob/0aa4af56/java/kudu-client/src/test/java/org/apache/kudu/client/TestScannerMultiTablet.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestScannerMultiTablet.java
b/java/kudu-client/src/test/java/org/apache/kudu/client/TestScannerMultiTablet.java
index 1bef824..036f857 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestScannerMultiTablet.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestScannerMultiTablet.java
@@ -242,6 +242,9 @@ public class TestScannerMultiTablet extends BaseKuduTest {
 
   @Test(timeout = 100000)
   public void testScanPropagatesLatestTimestamp() throws Exception {
+    // Reset the clients in order to clear the propagated timestamp, which may
+    // have been set if other test cases ran before this one.
+    resetClients();
     AsyncKuduScanner scanner = client.newScannerBuilder(table).build();
 
     // Initially, the client does not have the timestamp set.


Mime
View raw message