You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2021/11/22 18:46:38 UTC

[ignite-3] branch ignite-15307 updated (90a2792 -> ab3331e)

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

ptupitsyn pushed a change to branch ignite-15307
in repository https://gitbox.apache.org/repos/asf/ignite-3.git.


    from 90a2792  Fixing NettyServerTest
     new 4c90e1c  Fixing NettyServerTest
     new ab3331e  Fix NettyServerTest

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:
 .../internal/network/netty/NettyServerTest.java    | 59 ++++++----------------
 1 file changed, 16 insertions(+), 43 deletions(-)

[ignite-3] 01/02: Fixing NettyServerTest

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

ptupitsyn pushed a commit to branch ignite-15307
in repository https://gitbox.apache.org/repos/asf/ignite-3.git

commit 4c90e1c60b19b8e1a96c004f708d20b7b327c2a3
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Mon Nov 22 21:44:49 2021 +0300

    Fixing NettyServerTest
---
 .../ignite/internal/network/netty/NettyServerTest.java    | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/modules/network/src/test/java/org/apache/ignite/internal/network/netty/NettyServerTest.java b/modules/network/src/test/java/org/apache/ignite/internal/network/netty/NettyServerTest.java
index 2c93f49..b76199a 100644
--- a/modules/network/src/test/java/org/apache/ignite/internal/network/netty/NettyServerTest.java
+++ b/modules/network/src/test/java/org/apache/ignite/internal/network/netty/NettyServerTest.java
@@ -40,7 +40,6 @@ import java.nio.channels.ClosedChannelException;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.TimeUnit;
 import org.apache.ignite.configuration.schemas.network.NetworkConfiguration;
-import org.apache.ignite.configuration.schemas.network.NetworkView;
 import org.apache.ignite.internal.configuration.testframework.ConfigurationExtension;
 import org.apache.ignite.internal.configuration.testframework.InjectConfiguration;
 import org.apache.ignite.internal.network.handshake.HandshakeAction;
@@ -64,6 +63,9 @@ import org.mockito.verification.VerificationMode;
  */
 @ExtendWith(ConfigurationExtension.class)
 public class NettyServerTest {
+    /** Bootstrap factory. */
+    private NettyBootstrapFactory bootstrapFactory;
+    
     /** Server. */
     private NettyServer server;
     
@@ -75,8 +77,9 @@ public class NettyServerTest {
      * After each.
      */
     @AfterEach
-    final void tearDown() {
+    final void tearDown() throws Exception {
         server.stop().join();
+        bootstrapFactory.stop();
     }
     
     /**
@@ -201,6 +204,9 @@ public class NettyServerTest {
                         return mock(NetworkMessage.class);
                     }
                 });
+    
+        bootstrapFactory = new NettyBootstrapFactory(serverCfg.value(), "");
+        bootstrapFactory.start();
         
         server = new NettyServer(
                 "test",
@@ -211,7 +217,7 @@ public class NettyServerTest {
                 (socketAddress, message) -> {
                 },
                 registry,
-                new NettyBootstrapFactory(serverCfg.value(), "")
+                bootstrapFactory
         );
         
         server.start().get(3, TimeUnit.SECONDS);
@@ -268,7 +274,8 @@ public class NettyServerTest {
      * @return NettyServer.
      */
     private NettyServer getServer(ChannelFuture future, boolean shouldStart) {
-        var bootstrapFactory = Mockito.spy(new NettyBootstrapFactory(Mockito.mock(NetworkView.class), ""));
+        bootstrapFactory = new NettyBootstrapFactory(serverCfg.value(), "");
+        bootstrapFactory.start();
         
         var server = new NettyServer(
                 "test",

[ignite-3] 02/02: Fix NettyServerTest

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

ptupitsyn pushed a commit to branch ignite-15307
in repository https://gitbox.apache.org/repos/asf/ignite-3.git

commit ab3331e8d37b50e7cab15750aeb4c4a3e1f9c0d9
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Mon Nov 22 21:46:29 2021 +0300

    Fix NettyServerTest
---
 .../internal/network/netty/NettyServerTest.java    | 44 +++-------------------
 1 file changed, 5 insertions(+), 39 deletions(-)

diff --git a/modules/network/src/test/java/org/apache/ignite/internal/network/netty/NettyServerTest.java b/modules/network/src/test/java/org/apache/ignite/internal/network/netty/NettyServerTest.java
index b76199a..d4bea83 100644
--- a/modules/network/src/test/java/org/apache/ignite/internal/network/netty/NettyServerTest.java
+++ b/modules/network/src/test/java/org/apache/ignite/internal/network/netty/NettyServerTest.java
@@ -36,7 +36,6 @@ import io.netty.channel.ServerChannel;
 import io.netty.channel.embedded.EmbeddedChannel;
 import io.netty.channel.nio.NioEventLoopGroup;
 import io.netty.channel.socket.nio.NioSocketChannel;
-import java.nio.channels.ClosedChannelException;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.TimeUnit;
 import org.apache.ignite.configuration.schemas.network.NetworkConfiguration;
@@ -89,9 +88,7 @@ public class NettyServerTest {
      */
     @Test
     public void testSuccessfulServerStart() throws Exception {
-        var channel = new EmbeddedServerChannel();
-        
-        server = getServer(channel.newSucceededFuture(), true);
+        server = getServer(true);
         
         assertTrue(server.isRunning());
     }
@@ -103,40 +100,12 @@ public class NettyServerTest {
      */
     @Test
     public void testServerGracefulShutdown() throws Exception {
-        var channel = new EmbeddedServerChannel();
-        
-        server = getServer(channel.newSucceededFuture(), true);
+        server = getServer(true);
         
         server.stop().join();
     }
     
     /**
-     * Tests an unsuccessful server start scenario.
-     *
-     * @throws Exception If failed.
-     */
-    @Test
-    public void testServerFailedToStart() throws Exception {
-        var channel = new EmbeddedServerChannel();
-        
-        server = getServer(channel.newFailedFuture(new ClosedChannelException()), false);
-    }
-    
-    /**
-     * Tests a non-graceful server shutdown scenario.
-     *
-     * @throws Exception If failed.
-     */
-    @Test
-    public void testServerChannelClosedAbruptly() throws Exception {
-        var channel = new EmbeddedServerChannel();
-        
-        server = getServer(channel.newSucceededFuture(), true);
-        
-        channel.close();
-    }
-    
-    /**
      * Tests a scenario where a server is stopped before a server socket is successfully bound.
      *
      * @throws Exception If failed.
@@ -147,7 +116,7 @@ public class NettyServerTest {
         
         ChannelPromise future = channel.newPromise();
         
-        server = getServer(future, false);
+        server = getServer(false);
         
         CompletableFuture<Void> stop = server.stop();
         
@@ -161,9 +130,7 @@ public class NettyServerTest {
      */
     @Test
     public void testStartTwice() {
-        var channel = new EmbeddedServerChannel();
-        
-        server = getServer(channel.newSucceededFuture(), true);
+        server = getServer(true);
         
         assertThrows(IgniteInternalException.class, server::start);
     }
@@ -269,11 +236,10 @@ public class NettyServerTest {
     /**
      * Creates a server from a backing {@link ChannelFuture}.
      *
-     * @param future      Server channel future.
      * @param shouldStart {@code true} if a server should start successfully
      * @return NettyServer.
      */
-    private NettyServer getServer(ChannelFuture future, boolean shouldStart) {
+    private NettyServer getServer(boolean shouldStart) {
         bootstrapFactory = new NettyBootstrapFactory(serverCfg.value(), "");
         bootstrapFactory.start();