You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by sh...@apache.org on 2020/05/03 05:12:08 UTC
[incubator-ratis] branch master updated: RATIS-889. Fix
TestRaftSnapshotWithGrpc and TestRaftSnapshotWithSimulatedRpc (#81)
This is an automated email from the ASF dual-hosted git repository.
shashikant pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ratis.git
The following commit(s) were added to refs/heads/master by this push:
new 8cf9ff4 RATIS-889. Fix TestRaftSnapshotWithGrpc and TestRaftSnapshotWithSimulatedRpc (#81)
8cf9ff4 is described below
commit 8cf9ff4d34391ef99ccf14210d95161d3cb35a8d
Author: Doroszlai, Attila <64...@users.noreply.github.com>
AuthorDate: Sun May 3 07:12:01 2020 +0200
RATIS-889. Fix TestRaftSnapshotWithGrpc and TestRaftSnapshotWithSimulatedRpc (#81)
---
.../apache/ratis/statemachine/RaftSnapshotBaseTest.java | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/ratis-server/src/test/java/org/apache/ratis/statemachine/RaftSnapshotBaseTest.java b/ratis-server/src/test/java/org/apache/ratis/statemachine/RaftSnapshotBaseTest.java
index 712b8b3..3e2c752 100644
--- a/ratis-server/src/test/java/org/apache/ratis/statemachine/RaftSnapshotBaseTest.java
+++ b/ratis-server/src/test/java/org/apache/ratis/statemachine/RaftSnapshotBaseTest.java
@@ -203,6 +203,7 @@ public abstract class RaftSnapshotBaseTest extends BaseTest {
Assert.assertTrue(snapshotFiles.stream().anyMatch(RaftSnapshotBaseTest::exists));
return null;
}, 10, ONE_SECOND, "snapshotFile.exist", LOG);
+ verifyTakeSnapshotMetric(cluster.getLeader());
logs = storageDirectory.getLogSegmentFiles();
} finally {
cluster.shutdown();
@@ -234,10 +235,15 @@ public abstract class RaftSnapshotBaseTest extends BaseTest {
verifyInstallSnapshotMetric(cluster.getLeader());
RaftServerTestUtil.waitAndCheckNewConf(cluster, change.allPeersInNewConf, 0, null);
+ Timer timer = getTakeSnapshotTimer(cluster.getLeader());
+ long count = timer.getCount();
+
// restart the peer and check if it can correctly handle conf change
cluster.restartServer(cluster.getLeader().getId(), false);
assertLeaderContent(cluster);
- verifyTakeSnapshotMetric(cluster.getLeader());
+
+ // verify that snapshot was taken when stopping the server
+ Assert.assertTrue(count < timer.getCount());
} finally {
cluster.shutdown();
}
@@ -250,6 +256,11 @@ public abstract class RaftSnapshotBaseTest extends BaseTest {
}
private static void verifyTakeSnapshotMetric(RaftServerImpl leader) {
+ Timer timer = getTakeSnapshotTimer(leader);
+ Assert.assertTrue(timer.getCount() > 0);
+ }
+
+ private static Timer getTakeSnapshotTimer(RaftServerImpl leader) {
MetricRegistryInfo info = new MetricRegistryInfo(leader.getMemberId().toString(),
RATIS_APPLICATION_NAME_METRICS,
RATIS_STATEMACHINE_METRICS, RATIS_STATEMACHINE_METRICS_DESC);
@@ -257,7 +268,6 @@ public abstract class RaftSnapshotBaseTest extends BaseTest {
Assert.assertTrue(opt.isPresent());
RatisMetricRegistry metricRegistry = opt.get();
Assert.assertNotNull(metricRegistry);
- Timer timer = metricRegistry.timer(STATEMACHINE_TAKE_SNAPSHOT_TIMER);
- Assert.assertTrue(timer.getCount() > 0);
+ return metricRegistry.timer(STATEMACHINE_TAKE_SNAPSHOT_TIMER);
}
}