You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by ad...@apache.org on 2020/03/14 09:23:40 UTC

[kudu] branch master updated (1394746 -> 6bf82d4)

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

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


    from 1394746  [util] Changes to allow serializing/de-serializing BlockBloomFilter to a custom format
     new af7595b  [java] use KuduTestHarness in TestConnectionCache
     new 6bf82d4  [java] use KuduTestHarness in TestNegotiation

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/kudu/client/TestConnectionCache.java    | 113 ++++++++++-----------
 .../org/apache/kudu/client/TestNegotiation.java    |  38 ++++---
 2 files changed, 71 insertions(+), 80 deletions(-)


[kudu] 02/02: [java] use KuduTestHarness in TestNegotiation

Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 6bf82d40f8799ddc110fc83f479b72a45c3a0c49
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Fri Mar 13 20:42:20 2020 -0700

    [java] use KuduTestHarness in TestNegotiation
    
    Change-Id: I44712ffe05bc0de21f8610abfad0c59549f91999
    Reviewed-on: http://gerrit.cloudera.org:8080/15434
    Tested-by: Alexey Serbin <as...@cloudera.com>
    Reviewed-by: Adar Dembo <ad...@cloudera.com>
---
 .../org/apache/kudu/client/TestNegotiation.java    | 38 ++++++++++------------
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestNegotiation.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestNegotiation.java
index 54c9d9a..f0b35c7 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestNegotiation.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestNegotiation.java
@@ -25,14 +25,20 @@ import org.junit.Rule;
 import org.junit.Test;
 
 import org.apache.kudu.test.CapturingLogAppender;
+import org.apache.kudu.test.KuduTestHarness;
+import org.apache.kudu.test.KuduTestHarness.MasterServerConfig;
 import org.apache.kudu.test.cluster.FakeDNS;
-import org.apache.kudu.test.cluster.MiniKuduCluster;
-import org.apache.kudu.test.junit.RetryRule;
+import org.apache.kudu.test.cluster.MiniKuduCluster.MiniKuduClusterBuilder;
 
 public class TestNegotiation {
+  private static final MiniKuduClusterBuilder clusterBuilder =
+      new MiniKuduClusterBuilder()
+          .numMasterServers(1)
+          .numTabletServers(0)
+          .enableKerberos();
 
   @Rule
-  public RetryRule retryRule = new RetryRule();
+  public KuduTestHarness harness = new KuduTestHarness(clusterBuilder);
 
   /**
    * Test that a non-Kerberized client will use SASL PLAIN to connect to a
@@ -40,29 +46,19 @@ public class TestNegotiation {
    * KUDU-2121.
    */
   @Test
+  @MasterServerConfig(flags = {
+      "--rpc-authentication=optional",
+      "--rpc-trace-negotiation",
+      "--user-acl=*" })
   public void testSaslPlainFallback() throws Exception {
     FakeDNS.getInstance().install();
-    MiniKuduCluster.MiniKuduClusterBuilder clusterBuilder =
-        new MiniKuduCluster.MiniKuduClusterBuilder();
-
-    clusterBuilder.numMasterServers(1)
-                  .numTabletServers(0)
-                  .enableKerberos()
-                  .addMasterServerFlag("--rpc-authentication=optional")
-                  .addMasterServerFlag("--rpc-trace-negotiation")
-                  .addMasterServerFlag("--user-acl=*");
 
     CapturingLogAppender cla = new CapturingLogAppender();
-    try (MiniKuduCluster cluster = clusterBuilder.build()) {
-      cluster.kdestroy();
-      try (Closeable c = cla.attach();
-           KuduClient client =
-               new KuduClient.KuduClientBuilder(cluster.getMasterAddressesAsString()).build()
-      ) {
-        assertTrue(client.getTablesList().getTablesList().isEmpty());
-      }
+    harness.kdestroy();
+    harness.resetClients();
+    try (Closeable c = cla.attach()) {
+      assertTrue(harness.getClient().getTablesList().getTablesList().isEmpty());
     }
-
     assertTrue(cla.getAppendedText(),
                cla.getAppendedText().contains("Client requested to use mechanism: PLAIN"));
   }


[kudu] 01/02: [java] use KuduTestHarness in TestConnectionCache

Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit af7595bbff5a1578fc1978a8ec00f9946458c43e
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Fri Mar 13 14:11:53 2020 -0700

    [java] use KuduTestHarness in TestConnectionCache
    
    Change-Id: I8ba343de81edafd6eb563fdd506271450487b432
    Reviewed-on: http://gerrit.cloudera.org:8080/15431
    Tested-by: Kudu Jenkins
    Reviewed-by: Adar Dembo <ad...@cloudera.com>
---
 .../apache/kudu/client/TestConnectionCache.java    | 113 ++++++++++-----------
 1 file changed, 54 insertions(+), 59 deletions(-)

diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestConnectionCache.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestConnectionCache.java
index 19ebfc3..3486cc3 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestConnectionCache.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestConnectionCache.java
@@ -27,75 +27,70 @@ import com.stumbleupon.async.Deferred;
 import org.junit.Rule;
 import org.junit.Test;
 
-import org.apache.kudu.test.cluster.MiniKuduCluster;
-import org.apache.kudu.test.junit.RetryRule;
+import org.apache.kudu.test.KuduTestHarness;
 import org.apache.kudu.util.NetUtil;
 
 public class TestConnectionCache {
 
   @Rule
-  public RetryRule retryRule = new RetryRule();
+  public KuduTestHarness harness = new KuduTestHarness();
 
   @Test(timeout = 50000)
   @SuppressWarnings("FutureReturnValueIgnored")
   public void test() throws Exception {
-    try (MiniKuduCluster cluster = new MiniKuduCluster.MiniKuduClusterBuilder()
-                                                      .numMasterServers(3)
-                                                      .build();
-         AsyncKuduClient client = new AsyncKuduClient.AsyncKuduClientBuilder(
-             cluster.getMasterAddressesAsString()).build()) {
-      // Below we ping the masters directly using RpcProxy, so if they aren't ready to process
-      // RPCs we'll get an error. Here by listing the tables we make sure this won't happen since
-      // it won't return until a master leader is found.
-      client.getTablesList().join();
-
-      HostAndPort masterHostPort = cluster.getMasterServers().get(0);
-      ServerInfo firstMaster = new ServerInfo("fake-uuid",
-                                              masterHostPort,
-                                              NetUtil.getInetAddress(masterHostPort.getHost()),
-                                              /*location=*/"");
-
-      // 3 masters in the cluster. Connections should have been cached since we forced
-      // a cluster connection above.
-      // No tservers have been connected to by the client since we haven't accessed
-      // any data.
-      assertEquals(3, client.getConnectionListCopy().size());
-      assertFalse(allConnectionsTerminated(client));
-
-      final RpcProxy proxy = client.newRpcProxy(firstMaster);
-
-      // Disconnect from the server.
-      proxy.getConnection().disconnect().awaitUninterruptibly();
-      waitForConnectionToTerminate(proxy.getConnection());
-      assertTrue(proxy.getConnection().isTerminated());
-
-      // Make sure not all the connections in the connection cache are disconnected yet. Actually,
-      // only the connection to server '0' should be disconnected.
-      assertFalse(allConnectionsTerminated(client));
-
-      // For a new RpcProxy instance, a new connection to the same destination is established.
-      final RpcProxy newHelper = client.newRpcProxy(firstMaster);
-      final Connection newConnection = newHelper.getConnection();
-      assertNotNull(newConnection);
-      assertNotSame(proxy.getConnection(), newConnection);
-
-      // The client-->server connection should not be established at this point yet. Wait a little
-      // before checking the state of the connection: this is to check for the status of the
-      // underlying connection _after_ the negotiation is run, if a regression happens. The
-      // negotiation on the underlying connection should be run upon submitting the very first
-      // RPC via the proxy object, not upon creating RpcProxy instance (see KUDU-1878).
-      Thread.sleep(500);
-      assertFalse(newConnection.isReady());
-      pingConnection(newHelper);
-      assertTrue(newConnection.isReady());
-
-      // Test disconnecting and make sure we cleaned up all the connections.
-      for (Connection c : client.getConnectionListCopy()) {
-        c.disconnect().awaitUninterruptibly();
-        waitForConnectionToTerminate(c);
-      }
-      assertTrue(allConnectionsTerminated(client));
+    AsyncKuduClient client = harness.getAsyncClient();
+
+    // Below we ping the masters directly using RpcProxy, so if they aren't ready to process
+    // RPCs we'll get an error. Here by listing the tables we make sure this won't happen since
+    // it won't return until a master leader is found.
+    client.getTablesList().join();
+
+    HostAndPort masterHostPort = harness.getMasterServers().get(0);
+    ServerInfo firstMaster = new ServerInfo("fake-uuid",
+                                            masterHostPort,
+                                            NetUtil.getInetAddress(masterHostPort.getHost()),
+                                            /*location=*/"");
+
+    // 3 masters in the cluster. Connections should have been cached since we forced
+    // a cluster connection above.
+    // No tservers have been connected to by the client since we haven't accessed
+    // any data.
+    assertEquals(3, client.getConnectionListCopy().size());
+    assertFalse(allConnectionsTerminated(client));
+
+    final RpcProxy proxy = client.newRpcProxy(firstMaster);
+
+    // Disconnect from the server.
+    proxy.getConnection().disconnect().awaitUninterruptibly();
+    waitForConnectionToTerminate(proxy.getConnection());
+    assertTrue(proxy.getConnection().isTerminated());
+
+    // Make sure not all the connections in the connection cache are disconnected yet. Actually,
+    // only the connection to server '0' should be disconnected.
+    assertFalse(allConnectionsTerminated(client));
+
+    // For a new RpcProxy instance, a new connection to the same destination is established.
+    final RpcProxy newHelper = client.newRpcProxy(firstMaster);
+    final Connection newConnection = newHelper.getConnection();
+    assertNotNull(newConnection);
+    assertNotSame(proxy.getConnection(), newConnection);
+
+    // The client-->server connection should not be established at this point yet. Wait a little
+    // before checking the state of the connection: this is to check for the status of the
+    // underlying connection _after_ the negotiation is run, if a regression happens. The
+    // negotiation on the underlying connection should be run upon submitting the very first
+    // RPC via the proxy object, not upon creating RpcProxy instance (see KUDU-1878).
+    Thread.sleep(500);
+    assertFalse(newConnection.isReady());
+    pingConnection(newHelper);
+    assertTrue(newConnection.isReady());
+
+    // Test disconnecting and make sure we cleaned up all the connections.
+    for (Connection c : client.getConnectionListCopy()) {
+      c.disconnect().awaitUninterruptibly();
+      waitForConnectionToTerminate(c);
     }
+    assertTrue(allConnectionsTerminated(client));
   }
 
   private boolean allConnectionsTerminated(AsyncKuduClient client) {