kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject kudu git commit: [java] fix the regression test for KUDU-2267/KUDU-2319
Date Fri, 02 Mar 2018 23:40:12 GMT
Repository: kudu
Updated Branches:
  refs/heads/master 7e54a17ec -> 9bc0d9e3f


[java] fix the regression test for KUDU-2267/KUDU-2319

In the previous commit 0f0e42144, a regression test was added to ensure
a client with valid authn token but without valid Kerberos credentials
should be able to connect to all the masters. However, the test was not
correct. This patch fixes that.

Change-Id: I5e827586fe549f6a0c927ce8a4f8eca954bfe690
Reviewed-on: http://gerrit.cloudera.org:8080/9388
Tested-by: Kudu Jenkins
Reviewed-by: Alexey Serbin <aserbin@cloudera.com>


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

Branch: refs/heads/master
Commit: 9bc0d9e3f2d1483f7f51399500f8121fd39d12e1
Parents: 7e54a17
Author: hahao <hao.hao@cloudera.com>
Authored: Wed Feb 21 16:47:53 2018 -0800
Committer: Hao Hao <hao.hao@cloudera.com>
Committed: Fri Mar 2 23:18:59 2018 +0000

----------------------------------------------------------------------
 .../org/apache/kudu/client/ConnectToCluster.java  | 12 ++++++++----
 .../java/org/apache/kudu/client/TestSecurity.java | 18 ++++++++++++++----
 2 files changed, 22 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/9bc0d9e3/java/kudu-client/src/main/java/org/apache/kudu/client/ConnectToCluster.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/ConnectToCluster.java b/java/kudu-client/src/main/java/org/apache/kudu/client/ConnectToCluster.java
index f3341a7..3e925c5 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/ConnectToCluster.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/ConnectToCluster.java
@@ -159,13 +159,15 @@ final class ConnectToCluster {
   }
 
   @VisibleForTesting
-  void connectToMasters(KuduTable masterTable,
-                        KuduRpc<?> parentRpc,
-                        long defaultTimeoutMs,
-                        Connection.CredentialsPolicy credentialsPolicy) {
+  List<Deferred<ConnectToMasterResponsePB>> connectToMasters(
+      KuduTable masterTable,
+      KuduRpc<?> parentRpc,
+      long defaultTimeoutMs,
+      Connection.CredentialsPolicy credentialsPolicy) {
     // Try to connect to each master. The ConnectToCluster instance
     // waits until it gets a good response before firing the returned
     // deferred.
+    List<Deferred<ConnectToMasterResponsePB>> deferreds = new ArrayList<>();
     for (HostAndPort hostAndPort : masterAddrs) {
       Deferred<ConnectToMasterResponsePB> d;
       RpcProxy proxy = masterTable.getAsyncClient().newMasterRpcProxy(
@@ -179,7 +181,9 @@ final class ConnectToCluster {
         d = Deferred.fromError(new NonRecoverableException(statusIOE));
       }
       d.addCallbacks(callbackForNode(hostAndPort), errbackForNode(hostAndPort));
+      deferreds.add(d);
     }
+    return deferreds;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/kudu/blob/9bc0d9e3/java/kudu-client/src/test/java/org/apache/kudu/client/TestSecurity.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestSecurity.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestSecurity.java
index 863ed03..290526b 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestSecurity.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestSecurity.java
@@ -18,10 +18,14 @@ import static org.junit.Assert.assertNotNull;
 
 import java.util.List;
 
+import com.stumbleupon.async.Deferred;
+
+import org.apache.kudu.master.Master.ConnectToMasterResponsePB;
 import org.apache.kudu.util.AssertHelpers.BooleanExpression;
 import org.apache.kudu.util.SecurityUtil;
 import org.junit.Assert;
 import org.junit.BeforeClass;
+import org.junit.Ignore;
 import org.junit.Test;
 
 public class TestSecurity extends BaseKuduTest {
@@ -76,8 +80,10 @@ public class TestSecurity extends BaseKuduTest {
   }
 
   /**
-   * Regression test for KUDU-2267, client with valid token but without valid
-   * Kerberos credentials should be able to connect to all the masters.
+   * Regression test for KUDU-2267 and KUDU-2319.
+   *
+   * A client with valid token but without valid Kerberos credentials
+   * should be able to connect to all the masters.
    */
   @Test
   public void testKudu2267() throws Exception {
@@ -96,9 +102,13 @@ public class TestSecurity extends BaseKuduTest {
             @Override
             public boolean get() throws Exception {
               ConnectToCluster connector = new ConnectToCluster(masterHostPorts);
-              connector.connectToMasters(newClient.asyncClient.getMasterTable(), null,
+              List<Deferred<ConnectToMasterResponsePB>> deferreds =
+                      connector.connectToMasters(newClient.asyncClient.getMasterTable(),
null,
                       DEFAULT_SLEEP, Connection.CredentialsPolicy.ANY_CREDENTIALS);
-              connector.getDeferred().join();
+              // Wait for all Deferreds are called back.
+              for (Deferred<ConnectToMasterResponsePB> deferred : deferreds) {
+                deferred.join();
+              }
               List<Exception> s = connector.getExceptionsReceived();
               return s.size() == 0;
             }


Mime
View raw message