Skip to content

Commit 0a15b6f

Browse files
authored
IGNITE-28584 Fix flaky TooManyOpenFilesTcpCommunicationSpiTest#testTooManyOpenFilesErr (#13054)
1 parent 890368f commit 0a15b6f

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TooManyOpenFilesTcpCommunicationSpiTest.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.ignite.spi.communication.tcp;
1919

2020
import java.net.SocketException;
21+
import java.util.UUID;
2122
import org.apache.ignite.IgniteCache;
2223
import org.apache.ignite.cluster.ClusterState;
2324
import org.apache.ignite.cluster.ClusterTopologyException;
@@ -102,7 +103,9 @@ public void testTooManyOpenFilesErr() throws Exception {
102103
nioSrvWrapper.socketChannelFactory(() -> {
103104
throw new SocketException("Too many open files");
104105
});
105-
connPool.forceCloseConnection(txNode.localNode().id());
106+
// Sometimes we can get `org.apache.ignite.IgniteCheckedException: Too many open files` due to parallel
107+
// connection creation, since the forceCloseConnection is for tests, then we can ignore the exception.
108+
forceCloseConnectionSafe(connPool, txNode.localNode().id());
106109

107110
cache.put(1, 2);
108111
cache.put(2, 3);
@@ -117,4 +120,20 @@ public void testTooManyOpenFilesErr() throws Exception {
117120

118121
assertTrue(waitForCondition(((IgniteKernal)stopNode)::isStopping, 60_000));
119122
}
123+
124+
/** */
125+
private static void forceCloseConnectionSafe(ConnectionClientPool connPool, UUID nodeId) throws Exception {
126+
assertTrue(waitForCondition(() -> {
127+
try {
128+
connPool.forceCloseConnection(nodeId);
129+
130+
return true;
131+
}
132+
catch (Throwable t) {
133+
log.error("Error occurred while attempting to force close connections for node: " + nodeId, t);
134+
135+
return false;
136+
}
137+
}, 10_000));
138+
}
120139
}

0 commit comments

Comments
 (0)