Skip to content

Commit 32650bf

Browse files
authored
IGNITE-24334 Fixed flaky ClientSessionOutboundQueueLimitTest (#11835)
1 parent ce59c37 commit 32650bf

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/ClientSessionOutboundQueueLimitTest.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@
2525
import org.apache.ignite.Ignition;
2626
import org.apache.ignite.client.ClientCache;
2727
import org.apache.ignite.client.IgniteClient;
28+
import org.apache.ignite.client.IgniteClientFuture;
2829
import org.apache.ignite.client.events.ConnectionClosedEvent;
2930
import org.apache.ignite.client.events.ConnectionEventListener;
3031
import org.apache.ignite.configuration.ClientConfiguration;
3132
import org.apache.ignite.configuration.ClientConnectorConfiguration;
3233
import org.apache.ignite.configuration.IgniteConfiguration;
3334
import org.apache.ignite.internal.IgniteEx;
34-
import org.apache.ignite.internal.IgniteInternalFuture;
3535
import org.apache.ignite.internal.util.typedef.internal.U;
36-
import org.apache.ignite.testframework.GridTestUtils;
3736
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
3837
import org.junit.Test;
3938

@@ -69,6 +68,8 @@ public void testClientSessionOutboundQueueLimit() throws Exception {
6968
try (
7069
IgniteClient cli = Ignition.startClient(new ClientConfiguration()
7170
.setAddresses("127.0.0.1:10800")
71+
.setTimeout(5000) // Server will drop packets intended for the client. So client can hang on handshake during reconnect.
72+
.setRetryLimit(1) // Let's not retry operations if the channel was closed while waiting for a response.
7273
.setEventListeners(new ConnectionEventListener() {
7374
@Override public void onConnectionClosed(ConnectionClosedEvent event) {
7475
isCliDisconnected.set(true);
@@ -85,11 +86,16 @@ public void testClientSessionOutboundQueueLimit() throws Exception {
8586

8687
skipClientWrite(grid(0), true);
8788

88-
Collection<IgniteInternalFuture<byte[]>> futs = new ArrayList<>();
89+
Collection<IgniteClientFuture<byte[]>> futs = new ArrayList<>();
8990

9091
try {
91-
while (!isCliDisconnected.get())
92-
futs.add(GridTestUtils.runAsync(() -> cache.get(0)));
92+
while (!isCliDisconnected.get()) {
93+
futs.add(cache.getAsync(0));
94+
95+
// Slow and steady. This delay will give us a chance to stop spamming requests
96+
// as soon as server disconnects the client.
97+
U.sleep(10);
98+
}
9399
}
94100
finally {
95101
skipClientWrite(grid(0), false);
@@ -102,8 +108,6 @@ public void testClientSessionOutboundQueueLimit() throws Exception {
102108
fut.get();
103109
}
104110
catch (Exception e) {
105-
assertTrue(e.getMessage().contains("Channel is closed"));
106-
107111
failedReqsCntr.incrementAndGet();
108112
}
109113
});

0 commit comments

Comments
 (0)