Fix time sensitivity in NodeLeavingAndExitingSpec, see #2289
This commit is contained in:
parent
f970c87ea4
commit
aa88818f71
1 changed files with 32 additions and 22 deletions
|
|
@ -18,11 +18,8 @@ object NodeLeavingAndExitingMultiJvmSpec extends MultiNodeConfig {
|
||||||
commonConfig(
|
commonConfig(
|
||||||
debugConfig(on = false)
|
debugConfig(on = false)
|
||||||
.withFallback(ConfigFactory.parseString("""
|
.withFallback(ConfigFactory.parseString("""
|
||||||
akka.cluster {
|
# turn off unreachable reaper
|
||||||
leader-actions-interval = 5 s # increase the leader action task frequency to make sure we get a chance to test the LEAVING state
|
akka.cluster.unreachable-nodes-reaper-interval = 300 s""")
|
||||||
unreachable-nodes-reaper-interval = 300 s # turn "off"
|
|
||||||
}
|
|
||||||
""")
|
|
||||||
.withFallback(MultiNodeClusterSpec.clusterConfig)))
|
.withFallback(MultiNodeClusterSpec.clusterConfig)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,26 +39,39 @@ abstract class NodeLeavingAndExitingSpec
|
||||||
|
|
||||||
awaitClusterUp(first, second, third)
|
awaitClusterUp(first, second, third)
|
||||||
|
|
||||||
runOn(first) {
|
|
||||||
cluster.leave(second)
|
|
||||||
}
|
|
||||||
enterBarrier("second-left")
|
|
||||||
|
|
||||||
runOn(first, third) {
|
runOn(first, third) {
|
||||||
|
val secondAddess = address(second)
|
||||||
|
val leavingLatch = TestLatch()
|
||||||
|
val exitingLatch = TestLatch()
|
||||||
|
val expectedAddresses = roles.toSet map address
|
||||||
|
cluster.registerListener(new MembershipChangeListener {
|
||||||
|
def notify(members: SortedSet[Member]) {
|
||||||
|
def check(status: MemberStatus): Boolean =
|
||||||
|
(members.map(_.address) == expectedAddresses &&
|
||||||
|
members.exists(m ⇒ m.address == secondAddess && m.status == status))
|
||||||
|
if (check(MemberStatus.Leaving)) leavingLatch.countDown()
|
||||||
|
if (check(MemberStatus.Exiting)) exitingLatch.countDown()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
enterBarrier("registered-listener")
|
||||||
|
|
||||||
// 1. Verify that 'second' node is set to LEAVING
|
runOn(third) {
|
||||||
// We have set the 'leader-actions-interval' to 5 seconds to make sure that we get a
|
cluster.leave(second)
|
||||||
// chance to test the LEAVING state before the leader moves the node to EXITING
|
}
|
||||||
awaitCond(cluster.latestGossip.members.exists(_.status == MemberStatus.Leaving)) // wait on LEAVING
|
enterBarrier("second-left")
|
||||||
val hasLeft = cluster.latestGossip.members.find(_.status == MemberStatus.Leaving) // verify node that left
|
|
||||||
hasLeft must be('defined)
|
|
||||||
hasLeft.get.address must be(address(second))
|
|
||||||
|
|
||||||
// 2. Verify that 'second' node is set to EXITING
|
// Verify that 'second' node is set to LEAVING
|
||||||
awaitCond(cluster.latestGossip.members.exists(_.status == MemberStatus.Exiting)) // wait on EXITING
|
leavingLatch.await
|
||||||
val hasExited = cluster.latestGossip.members.find(_.status == MemberStatus.Exiting) // verify node that exited
|
|
||||||
hasExited must be('defined)
|
// Verify that 'second' node is set to EXITING
|
||||||
hasExited.get.address must be(address(second))
|
exitingLatch.await
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// node that is leaving
|
||||||
|
runOn(second) {
|
||||||
|
enterBarrier("registered-listener")
|
||||||
|
enterBarrier("second-left")
|
||||||
}
|
}
|
||||||
|
|
||||||
enterBarrier("finished")
|
enterBarrier("finished")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue