You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by sz...@apache.org on 2021/03/19 09:45:33 UTC

[ratis-thirdparty] branch master updated: RATIS-1348. Intermittent failure in GrpcSslTest (#16)

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

szetszwo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ratis-thirdparty.git


The following commit(s) were added to refs/heads/master by this push:
     new 5b8b01b  RATIS-1348. Intermittent failure in GrpcSslTest (#16)
5b8b01b is described below

commit 5b8b01bc1e71faeb494f40486767a880c5661c7a
Author: Doroszlai, Attila <64...@users.noreply.github.com>
AuthorDate: Fri Mar 19 10:45:28 2021 +0100

    RATIS-1348. Intermittent failure in GrpcSslTest (#16)
---
 .../apache/ratis/thirdparty/demo/GrpcSslTest.java  | 25 +++++++++++-----------
 .../org/apache/ratis/thirdparty/demo/GrpcTest.java | 13 +++++------
 2 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/test/src/test/java/org/apache/ratis/thirdparty/demo/GrpcSslTest.java b/test/src/test/java/org/apache/ratis/thirdparty/demo/GrpcSslTest.java
index dea7209..56dca10 100644
--- a/test/src/test/java/org/apache/ratis/thirdparty/demo/GrpcSslTest.java
+++ b/test/src/test/java/org/apache/ratis/thirdparty/demo/GrpcSslTest.java
@@ -40,20 +40,21 @@ public class GrpcSslTest {
 
   @Test
   public void testSslClientServer() throws InterruptedException, IOException {
+    GrpcSslServerConfig sslServerConf =
+        new GrpcSslServerConfig(
+            getResource("ssl/server.pem"),
+            getResource("ssl/server.crt"),
+            getResource("ssl/client.crt"),
+            true,
+            false);
+    GrpcSslServer server = new GrpcSslServer(port, sslServerConf);
+    server.start();
+
     Thread serverThread = new Thread(() -> {
-      GrpcSslServerConfig sslServerConf =
-          new GrpcSslServerConfig(
-              getResource("ssl/server.pem"),
-              getResource("ssl/server.crt"),
-              getResource("ssl/client.crt"),
-              true,
-              false);
-      GrpcSslServer server = new GrpcSslServer(port, sslServerConf);
       try {
-        server.start();
         server.blockUntilShutdown();
-      } catch (InterruptedException | IOException e) {
-        e.printStackTrace();
+      } catch (InterruptedException e) {
+        Thread.currentThread().interrupt();
       }
     });
     serverThread.start();
@@ -72,7 +73,7 @@ public class GrpcSslTest {
       String user = "testuser";
       String response = client.greet(user);
       LOG.info("Greet result: {}", response);
-      Assert.assertTrue(response.equals("Hello " + user));
+      Assert.assertEquals("Hello " + user, response);
     } finally {
       client.shutdown();
     }
diff --git a/test/src/test/java/org/apache/ratis/thirdparty/demo/GrpcTest.java b/test/src/test/java/org/apache/ratis/thirdparty/demo/GrpcTest.java
index ca609d0..98c7420 100644
--- a/test/src/test/java/org/apache/ratis/thirdparty/demo/GrpcTest.java
+++ b/test/src/test/java/org/apache/ratis/thirdparty/demo/GrpcTest.java
@@ -34,14 +34,15 @@ public class GrpcTest {
 
   private final static Logger LOG = LoggerFactory.getLogger(GrpcTest.class);
   @Test
-  public void testClientServer() throws InterruptedException {
+  public void testClientServer() throws IOException, InterruptedException {
+    GrpcServer server = new GrpcServer(50001);
+    server.start();
+
     Thread serverThread = new Thread(() -> {
-      GrpcServer server = new GrpcServer(50001);
       try {
-        server.start();
         server.blockUntilShutdown();
-      } catch (InterruptedException | IOException e) {
-        e.printStackTrace();
+      } catch (InterruptedException e) {
+        Thread.currentThread().interrupt();
       }
     });
     serverThread.start();
@@ -52,7 +53,7 @@ public class GrpcTest {
       String user = "testuser";
       String response = client.greet(user);
       LOG.info("Greet result: {}", response);
-      Assert.assertTrue(response.equals("Hello " + user));
+      Assert.assertEquals("Hello " + user, response);
     } finally {
       client.shutdown();
     }