Skip to content

Commit 5a4756b

Browse files
committed
IGNITE-26965 Fixed flaky ReliabilityTest#testFailover test.
1 parent 4484d80 commit 5a4756b

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

modules/core/src/test/java/org/apache/ignite/client/LocalIgniteCluster.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class LocalIgniteCluster implements AutoCloseable {
4141
private static final Random rnd = new Random();
4242

4343
/** Servers. */
44-
private final List<Ignite> srvs = new ArrayList<>();
44+
public final List<Ignite> srvs = new ArrayList<>();
4545

4646
/** Configurations of the failed servers. */
4747
private final List<NodeConfiguration> failedCfgs = new ArrayList<>();

modules/core/src/test/java/org/apache/ignite/client/ReliabilityTest.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import java.util.Arrays;
2121
import java.util.Collection;
22+
import java.util.HashMap;
2223
import java.util.Iterator;
2324
import java.util.List;
2425
import java.util.Map;
@@ -161,10 +162,19 @@ public void testFailover() throws Exception {
161162
try (QueryCursor<Cache.Entry<Integer, String>> cur = cache.query(qry)) {
162163
List<Cache.Entry<Integer, String>> res = cur.getAll();
163164

164-
assertEquals("Unexpected number of entries", data.size(), res.size());
165-
166165
Map<Integer, String> act = res.stream()
167-
.collect(Collectors.toMap(Cache.Entry::getKey, Cache.Entry::getValue));
166+
.collect(Collectors.toMap(Cache.Entry::getKey, Cache.Entry::getValue));
167+
168+
Map<Integer, Object> failover = null;
169+
170+
if (data.size() != res.size()) {
171+
failover = new HashMap<>();
172+
173+
for (int i : data.keySet())
174+
failover.put(i, cluster.srvs.get(0).cache("testFailover").get(i));
175+
}
176+
177+
assertEquals("Unexpected number of entries " + act + " " + failover, data.size(), res.size());
168178

169179
assertEquals("Unexpected entries", data, act);
170180
}
@@ -770,8 +780,6 @@ private void waitRebalanceFinished() throws IgniteInterruptedCheckedException, I
770780
));
771781
}
772782
}
773-
774-
U.sleep(5000);
775783
}
776784

777785
/** {@inheritDoc} */

0 commit comments

Comments
 (0)