Some cleanups in ClusterClientSpec (#23095)
Mainly replacing within+awaitAssert with awaitAssert with a timeout - seems cleaner.
This commit is contained in:
parent
b80ee5e3d3
commit
41098a427f
1 changed files with 25 additions and 36 deletions
|
|
@ -285,17 +285,14 @@ class ClusterClientSpec extends MultiNodeSpec(ClusterClientSpec) with STMultiNod
|
|||
"report events" in within(15 seconds) {
|
||||
runOn(client) {
|
||||
implicit val timeout = Timeout(1.second.dilated)
|
||||
val c = Await.result(system.actorSelection("/user/client").resolveOne(), timeout.duration)
|
||||
val l = system.actorOf(Props(classOf[TestClientListener], c), "reporter-client-listener")
|
||||
val client = Await.result(system.actorSelection("/user/client").resolveOne(), timeout.duration)
|
||||
val listener = system.actorOf(Props(classOf[TestClientListener], client), "reporter-client-listener")
|
||||
|
||||
val expectedContacts = Set(first, second, third, fourth).map(node(_) / "system" / "receptionist")
|
||||
within(10.seconds) {
|
||||
awaitAssert {
|
||||
val probe = TestProbe()
|
||||
l.tell(TestClientListener.GetLatestContactPoints, probe.ref)
|
||||
probe.expectMsgType[LatestContactPoints].contactPoints should ===(expectedContacts)
|
||||
}
|
||||
}
|
||||
awaitAssert({
|
||||
listener ! TestClientListener.GetLatestContactPoints
|
||||
expectMsgType[LatestContactPoints].contactPoints should ===(expectedContacts)
|
||||
}, max = 10.seconds)
|
||||
}
|
||||
|
||||
enterBarrier("reporter-client-listener-tested")
|
||||
|
|
@ -313,13 +310,11 @@ class ClusterClientSpec extends MultiNodeSpec(ClusterClientSpec) with STMultiNod
|
|||
|
||||
val c = Await.result(system.actorSelection(node(client) / "user" / "client").resolveOne(), timeout.duration)
|
||||
val expectedClients = Set(c)
|
||||
within(10.seconds) {
|
||||
awaitAssert {
|
||||
val probe = TestProbe()
|
||||
l.tell(TestReceptionistListener.GetLatestClusterClients, probe.ref)
|
||||
probe.expectMsgType[LatestClusterClients].clusterClients should ===(expectedClients)
|
||||
}
|
||||
}
|
||||
awaitAssert({
|
||||
val probe = TestProbe()
|
||||
l.tell(TestReceptionistListener.GetLatestClusterClients, probe.ref)
|
||||
probe.expectMsgType[LatestClusterClients].clusterClients should ===(expectedClients)
|
||||
}, max = 10.seconds)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -349,10 +344,9 @@ class ClusterClientSpec extends MultiNodeSpec(ClusterClientSpec) with STMultiNod
|
|||
testConductor.passThrough(client, role, Direction.Both).await
|
||||
}
|
||||
|
||||
within(10.seconds) {
|
||||
awaitAssert {
|
||||
probe.expectMsgType[ContactPointRemoved].contactPoint should ===(unreachableContact)
|
||||
}
|
||||
probe.fishForMessage(10.seconds, "removal") {
|
||||
case ContactPointRemoved(`unreachableContact`) ⇒ true
|
||||
case _ ⇒ false
|
||||
}
|
||||
}
|
||||
enterBarrier("after-7")
|
||||
|
|
@ -367,10 +361,10 @@ class ClusterClientSpec extends MultiNodeSpec(ClusterClientSpec) with STMultiNod
|
|||
enterBarrier("service2-replicated")
|
||||
|
||||
runOn(client) {
|
||||
val c = system.actorOf(ClusterClient.props(
|
||||
val client = system.actorOf(ClusterClient.props(
|
||||
ClusterClientSettings(system).withInitialContacts(initialContacts)), "client2")
|
||||
|
||||
c ! ClusterClient.Send("/user/service2", "bonjour", localAffinity = true)
|
||||
client ! ClusterClient.Send("/user/service2", "bonjour", localAffinity = true)
|
||||
val reply = expectMsgType[Reply]
|
||||
reply.msg should be("bonjour-ack")
|
||||
val receptionistRoleName = roleName(reply.node) match {
|
||||
|
|
@ -379,12 +373,10 @@ class ClusterClientSpec extends MultiNodeSpec(ClusterClientSpec) with STMultiNod
|
|||
}
|
||||
testConductor.exit(receptionistRoleName, 0).await
|
||||
remainingServerRoleNames -= receptionistRoleName
|
||||
within(remaining - 3.seconds) {
|
||||
awaitAssert {
|
||||
c ! ClusterClient.Send("/user/service2", "hi again", localAffinity = true)
|
||||
expectMsgType[Reply](1 second).msg should be("hi again-ack")
|
||||
}
|
||||
}
|
||||
awaitAssert({
|
||||
c ! ClusterClient.Send("/user/service2", "hi again", localAffinity = true)
|
||||
expectMsgType[Reply](1 second).msg should be("hi again-ack")
|
||||
}, max = remaining - 3.seconds)
|
||||
system.stop(c)
|
||||
}
|
||||
enterBarrier("verifed-3")
|
||||
|
|
@ -396,15 +388,12 @@ class ClusterClientSpec extends MultiNodeSpec(ClusterClientSpec) with STMultiNod
|
|||
runOn(client) {
|
||||
// Locate the test listener from a previous test and see that it agrees
|
||||
// with what the client is telling it about what receptionists are alive
|
||||
val l = system.actorSelection("/user/reporter-client-listener")
|
||||
val listener = system.actorSelection("/user/reporter-client-listener")
|
||||
val expectedContacts = remainingServerRoleNames.map(node(_) / "system" / "receptionist")
|
||||
within(10.seconds) {
|
||||
awaitAssert {
|
||||
val probe = TestProbe()
|
||||
l.tell(TestClientListener.GetLatestContactPoints, probe.ref)
|
||||
probe.expectMsgType[LatestContactPoints].contactPoints should ===(expectedContacts)
|
||||
}
|
||||
}
|
||||
awaitAssert({
|
||||
listener ! TestClientListener.GetLatestContactPoints
|
||||
expectMsgType[LatestContactPoints].contactPoints should ===(expectedContacts)
|
||||
}, max = 10.seconds)
|
||||
}
|
||||
enterBarrier("after-6")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue