2525import org .apache .ignite .Ignition ;
2626import org .apache .ignite .client .ClientCache ;
2727import org .apache .ignite .client .IgniteClient ;
28+ import org .apache .ignite .client .IgniteClientFuture ;
2829import org .apache .ignite .client .events .ConnectionClosedEvent ;
2930import org .apache .ignite .client .events .ConnectionEventListener ;
3031import org .apache .ignite .configuration .ClientConfiguration ;
3132import org .apache .ignite .configuration .ClientConnectorConfiguration ;
3233import org .apache .ignite .configuration .IgniteConfiguration ;
3334import org .apache .ignite .internal .IgniteEx ;
34- import org .apache .ignite .internal .IgniteInternalFuture ;
3535import org .apache .ignite .internal .util .typedef .internal .U ;
36- import org .apache .ignite .testframework .GridTestUtils ;
3736import org .apache .ignite .testframework .junits .common .GridCommonAbstractTest ;
3837import 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