Implicit conversion from RoleName to Address

* Improved readability in tests if role name can be used
* Will change other tests also if you like it, otherwise revert
This commit is contained in:
Patrik Nordwall 2012-06-15 14:37:51 +02:00
parent 1e0d6670d5
commit 404fa4dfa3
2 changed files with 11 additions and 11 deletions

View file

@ -29,19 +29,15 @@ abstract class GossipingAccrualFailureDetectorSpec
import GossipingAccrualFailureDetectorMultiJvmSpec._
lazy val firstAddress = node(first).address
lazy val secondAddress = node(second).address
lazy val thirdAddress = node(third).address
"A Gossip-driven Failure Detector" must {
"receive gossip heartbeats so that all member nodes in the cluster are marked 'available'" taggedAs LongRunningTest in {
awaitClusterUp(first, second, third)
5.seconds.dilated.sleep // let them gossip
cluster.failureDetector.isAvailable(firstAddress) must be(true)
cluster.failureDetector.isAvailable(secondAddress) must be(true)
cluster.failureDetector.isAvailable(thirdAddress) must be(true)
cluster.failureDetector.isAvailable(first) must be(true)
cluster.failureDetector.isAvailable(second) must be(true)
cluster.failureDetector.isAvailable(third) must be(true)
testConductor.enter("after-1")
}
@ -53,10 +49,10 @@ abstract class GossipingAccrualFailureDetectorSpec
runOn(first, second) {
// remaning nodes should detect failure...
awaitCond(!cluster.failureDetector.isAvailable(thirdAddress), 10.seconds)
awaitCond(!cluster.failureDetector.isAvailable(third), 10.seconds)
// other connections still ok
cluster.failureDetector.isAvailable(firstAddress) must be(true)
cluster.failureDetector.isAvailable(secondAddress) must be(true)
cluster.failureDetector.isAvailable(first) must be(true)
cluster.failureDetector.isAvailable(second) must be(true)
}
testConductor.enter("after-2")

View file

@ -153,4 +153,8 @@ trait MultiNodeClusterSpec extends FailureDetectorStrategy { self: MultiNodeSpec
def roleName(address: Address): Option[RoleName] = {
testConductor.getNodes.await.find(node(_).address == address)
}
// implicit conversion from RoleName to Address
implicit def role2Address(role: RoleName): Address = node(role).address
}