Skip to content

Commit

Permalink
fix: make chaosSplittingCheckData robust (#1110)
Browse files Browse the repository at this point in the history
* fix: make chaosSplittingCheckData robust

* fix: forget another node test

* Update jraft-extension/java-log-storage-impl/src/test/java/com/alipay/sofa/jraft/core/NodeTest.java

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update jraft-core/src/test/java/com/alipay/sofa/jraft/core/NodeTest.java

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
killme2008 and coderabbitai[bot] authored Jun 18, 2024
1 parent 8cdde76 commit b401b94
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.concurrent.Future;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

Expand Down Expand Up @@ -3518,9 +3519,13 @@ public void testChangePeersChaosApplyTasks() throws Exception {
for (final ChangeArg arg : args) {
arg.stop = true;
}
for (final Future<?> future : futures) {
future.get();
}
for (final Future<?> future : futures) {
try {
future.get(20, TimeUnit.SECONDS);
} catch (TimeoutException e) {
LOG.warn("Timeout while waiting for future completion in testChangePeersChaosApplyTasks", e);
}
}

cluster.waitLeader();
final SynchronizedClosure done = new SynchronizedClosure();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3407,13 +3407,13 @@ public void testChangePeersChaosApplyTasks() throws Exception {
for (final ChangeArg arg : args) {
arg.stop = true;
}
for (final Future<?> future : futures) {
try {
future.get(20, TimeUnit.SECONDS);
} catch (TimeoutException e) {
// ignore
for (final Future<?> future : futures) {
try {
future.get(20, TimeUnit.SECONDS);
} catch (TimeoutException e) {
LOG.warn("Future waiting exceeded the timeout limit.", e);
}
}
}

cluster.waitLeader();
final SynchronizedClosure done = new SynchronizedClosure();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,11 @@ private void chaosSplittingCheckData(final ChaosTestCluster cluster) {
// Randomly select a client to verify data consistency
for (int i = 0; i < LOOP_1; i++) {
for (int j = 0; j < LOOP_2; j++) {
Assert.assertArrayEquals(VALUE, cluster.getRandomStore().bGet(i + "_split_test_" + j));
try {
Assert.assertArrayEquals(VALUE, cluster.getRandomStore().bGet(i + "_split_test_" + j));
} catch (Exception e) {
Assert.assertTrue(e.getMessage().contains("region split or merge happened"));
}
}
}
}
Expand Down

0 comments on commit b401b94

Please sign in to comment.