You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2018/10/22 15:16:59 UTC
[07/14] ignite git commit: IGNITE-9802 Fixed flaky
TcpCommunicationSpiFaultyClientTest.testNotAcceptedConnection - Fixes #4931.
IGNITE-9802 Fixed flaky TcpCommunicationSpiFaultyClientTest.testNotAcceptedConnection - Fixes #4931.
Signed-off-by: Alexey Goncharuk <al...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3a4167a6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3a4167a6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3a4167a6
Branch: refs/heads/ignite-9720
Commit: 3a4167a67e4fc318e2a7ef19500ca6da5910eaac
Parents: 5fa5c54
Author: NSAmelchev <ns...@gmail.com>
Authored: Mon Oct 22 14:45:38 2018 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Oct 22 14:45:38 2018 +0300
----------------------------------------------------------------------
.../TcpCommunicationSpiFaultyClientTest.java | 37 +++++++++++++++-----
1 file changed, 29 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3a4167a6/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiFaultyClientTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiFaultyClientTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiFaultyClientTest.java
index 00b1d90..505d7a5 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiFaultyClientTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiFaultyClientTest.java
@@ -23,6 +23,8 @@ import java.net.ServerSocket;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.apache.ignite.IgniteCheckedException;
@@ -38,6 +40,7 @@ import org.apache.ignite.internal.util.nio.GridCommunicationClient;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.spi.communication.CommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
@@ -79,7 +82,7 @@ public class TcpCommunicationSpiFaultyClientTest extends GridCommonAbstractTest
spi.setIdleConnectionTimeout(100);
spi.setSharedMemoryPort(-1);
- TcpDiscoverySpi discoSpi = (TcpDiscoverySpi) cfg.getDiscoverySpi();
+ TcpDiscoverySpi discoSpi = (TcpDiscoverySpi)cfg.getDiscoverySpi();
discoSpi.setIpFinder(IP_FINDER);
discoSpi.setClientReconnectDisabled(true);
@@ -94,11 +97,11 @@ public class TcpCommunicationSpiFaultyClientTest extends GridCommonAbstractTest
@Override protected void beforeTestsStarted() throws Exception {
super.beforeTestsStarted();
- System.setProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL,"true");
+ System.setProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL, "true");
}
/** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
+ @Override protected void afterTestsStopped() {
System.clearProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL);
}
@@ -150,12 +153,30 @@ public class TcpCommunicationSpiFaultyClientTest extends GridCommonAbstractTest
startGrid(2);
startGrid(3);
- U.sleep(1000); // Wait for write timeout and closing idle connections.
+ // Need to wait for PME to avoid opening new connections during closing idle connections.
+ awaitPartitionMapExchange();
+
+ CommunicationSpi commSpi = grid(0).configuration().getCommunicationSpi();
+
+ ConcurrentMap<UUID, GridCommunicationClient[]> clients = U.field(commSpi, "clients");
+
+ // Wait for write timeout and closing idle connections.
+ assertTrue("Failed to wait for closing idle connections.",
+ GridTestUtils.waitForCondition(() -> {
+ for (GridCommunicationClient[] clients0 : clients.values()) {
+ for (GridCommunicationClient client : clients0) {
+ if (client != null)
+ return false;
+ }
+ }
+
+ return true;
+ }, 1000));
final CountDownLatch latch = new CountDownLatch(1);
grid(0).events().localListen(new IgnitePredicate<Event>() {
- @Override public boolean apply(Event event) {
+ @Override public boolean apply(Event evt) {
latch.countDown();
return true;
@@ -171,7 +192,7 @@ public class TcpCommunicationSpiFaultyClientTest extends GridCommonAbstractTest
}
});
}
- catch (IgniteException e) {
+ catch (IgniteException ignored) {
// No-op.
}
@@ -218,7 +239,7 @@ public class TcpCommunicationSpiFaultyClientTest extends GridCommonAbstractTest
* Default constructor.
*/
FakeServer() throws IOException {
- this.srv = new ServerSocket(47200, 50, InetAddress.getByName("127.0.0.1"));
+ srv = new ServerSocket(47200, 50, InetAddress.getByName("127.0.0.1"));
}
/**
@@ -235,7 +256,7 @@ public class TcpCommunicationSpiFaultyClientTest extends GridCommonAbstractTest
try {
U.sleep(10);
}
- catch (IgniteInterruptedCheckedException e) {
+ catch (IgniteInterruptedCheckedException ignored) {
// No-op.
}
}