Skip to content

Commit e73d371

Browse files
authored
Merge pull request #141 from lerna-stack/MultiSnapshotSyncSpec-verifies-snapshot-synchronization
🚨test: Verify snapshot synchronization in MultiSnapshotSyncSpec
2 parents f392fd6 + 632c24f commit e73d371

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/multi-jvm/scala/lerna/akka/entityreplication/typed/MultiSnapshotSyncSpec.scala

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ class MultiSnapshotSyncSpec extends MultiNodeSpec(MultiSnapshotSyncSpecConfig) w
154154
/** RaftActor should compact it's log within this timeout */
155155
private val compactionTimeout: FiniteDuration = 10.seconds
156156

157+
/** Delayed Followers should synchronize snapshot within this timeout */
158+
private val snapshotSynchronizationTimeout: FiniteDuration = 10.seconds
159+
157160
/** None if this node doesn't shut it down. */
158161
private var maybeNewSystem: Option[classic.ActorSystem] = None
159162
private var runningNodes: Seq[RoleName] = roles
@@ -241,6 +244,14 @@ class MultiSnapshotSyncSpec extends MultiNodeSpec(MultiSnapshotSyncSpecConfig) w
241244
Thread.sleep(compactionTimeout.toMillis)
242245
}
243246

247+
/** Verifies snapshot synchronization completed by inspecting logging
248+
*/
249+
private def expectSnapshotSynchronizationCompleted(): Unit = {
250+
LoggingTestKit.info("Snapshot synchronization completed").expect {
251+
Thread.sleep(snapshotSynchronizationTimeout.toMillis)
252+
}
253+
}
254+
244255
private def setValue(id: String, value: Int)(implicit timeout: Timeout): Int = {
245256
// NOTE:
246257
// Too short retryInterval (e.g.200ms) will cause premature compaction and make this test unstable
@@ -286,6 +297,13 @@ class MultiSnapshotSyncSpec extends MultiNodeSpec(MultiSnapshotSyncSpecConfig) w
286297
enterBarrier("The cluster has nodes: [4,_,5].")
287298
}
288299

300+
"The leader (which is on node4) installs snapshots to the delayed follower (node5)" in {
301+
runOn(node5) {
302+
expectSnapshotSynchronizationCompleted()
303+
}
304+
enterBarrier("The snapshots were installed")
305+
}
306+
289307
"The leader (which is on node4) replicates some log entries. Nodes ([4,5]) compacts their log entries" in {
290308
object BarrierNames {
291309
val ExpectingCompactionCompleted = "Expecting compaction completed"
@@ -325,6 +343,13 @@ class MultiSnapshotSyncSpec extends MultiNodeSpec(MultiSnapshotSyncSpecConfig) w
325343
enterBarrier("The cluster has nodes: [6,7,8].")
326344
}
327345

346+
"The leader (which is on node8) installs snapshots to the delayed follower (node7)" in {
347+
runOn(node7) {
348+
expectSnapshotSynchronizationCompleted()
349+
}
350+
enterBarrier("The snapshots were installed")
351+
}
352+
328353
"The leader (which is on node8) replicates some log entries" in {
329354
object BarrierNames {
330355
val ExpectingCompactionCompleted = "Expecting compaction completed"

0 commit comments

Comments
 (0)