Skip to content

Commit

Permalink
IGNITE-24334 Fixed flaky ClientSessionOutboundQueueLimitTest (#11835)
Browse files Browse the repository at this point in the history
  • Loading branch information
petrov-mg authored Feb 6, 2025
1 parent ce59c37 commit 32650bf
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@
import org.apache.ignite.Ignition;
import org.apache.ignite.client.ClientCache;
import org.apache.ignite.client.IgniteClient;
import org.apache.ignite.client.IgniteClientFuture;
import org.apache.ignite.client.events.ConnectionClosedEvent;
import org.apache.ignite.client.events.ConnectionEventListener;
import org.apache.ignite.configuration.ClientConfiguration;
import org.apache.ignite.configuration.ClientConnectorConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;

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

skipClientWrite(grid(0), true);

Collection<IgniteInternalFuture<byte[]>> futs = new ArrayList<>();
Collection<IgniteClientFuture<byte[]>> futs = new ArrayList<>();

try {
while (!isCliDisconnected.get())
futs.add(GridTestUtils.runAsync(() -> cache.get(0)));
while (!isCliDisconnected.get()) {
futs.add(cache.getAsync(0));

// Slow and steady. This delay will give us a chance to stop spamming requests
// as soon as server disconnects the client.
U.sleep(10);
}
}
finally {
skipClientWrite(grid(0), false);
Expand All @@ -102,8 +108,6 @@ public void testClientSessionOutboundQueueLimit() throws Exception {
fut.get();
}
catch (Exception e) {
assertTrue(e.getMessage().contains("Channel is closed"));

failedReqsCntr.incrementAndGet();
}
});
Expand Down

0 comments on commit 32650bf

Please sign in to comment.