Harden ClusterShardingSpec, #30667 (#30770)

This commit is contained in:
Patrik Nordwall 2021-10-08 13:50:27 +02:00 committed by GitHub
parent c034d20993
commit 5011b957db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -267,27 +267,27 @@ class ClusterShardingSpec
"EntityRef - ask" in { "EntityRef - ask" in {
val bobRef = sharding.entityRefFor(typeKeyWithEnvelopes, "bob") val bobRef = sharding.entityRefFor(typeKeyWithEnvelopes, "bob")
val charlieRef = sharding.entityRefFor(typeKeyWithEnvelopes, "charlie") val aliceRef = sharding.entityRefFor(typeKeyWithEnvelopes, "alice")
val reply1 = bobRef ? WhoAreYou // TODO document that WhoAreYou(_) would not work val reply1 = bobRef ? WhoAreYou
val response = reply1.futureValue val response = reply1.futureValue
response should startWith("I'm bob") response should startWith("I'm bob")
// typekey and entity id encoded in promise ref path // typekey and entity id encoded in promise ref path
response should include(s"${typeKeyWithEnvelopes.name}-bob") response should include(s"${typeKeyWithEnvelopes.name}-bob")
val reply2 = charlieRef.ask(WhoAreYou) val reply2 = aliceRef.ask(WhoAreYou)
reply2.futureValue should startWith("I'm charlie") reply2.futureValue should startWith("I'm alice")
bobRef ! StopPlz() bobRef ! StopPlz()
} }
"EntityRef - ActorContext.ask" in { "EntityRef - ActorContext.ask" in {
val aliceRef = sharding.entityRefFor(typeKeyWithEnvelopes, "alice") val peterRef = sharding.entityRefFor(typeKeyWithEnvelopes, "peter")
val p = TestProbe[TheReply]() val p = TestProbe[TheReply]()
spawn(Behaviors.setup[TheReply] { ctx => spawn(Behaviors.setup[TheReply] { ctx =>
ctx.ask(aliceRef, WhoAreYou) { ctx.ask(peterRef, WhoAreYou) {
case Success(name) => TheReply(name) case Success(name) => TheReply(name)
case Failure(ex) => TheReply(ex.getMessage) case Failure(ex) => TheReply(ex.getMessage)
} }
@ -299,11 +299,11 @@ class ClusterShardingSpec
}) })
val response = p.receiveMessage() val response = p.receiveMessage()
response.s should startWith("I'm alice") response.s should startWith("I'm peter")
// typekey and entity id encoded in promise ref path // typekey and entity id encoded in promise ref path
response.s should include(s"${typeKeyWithEnvelopes.name}-alice") response.s should include(s"${typeKeyWithEnvelopes.name}-peter")
aliceRef ! StopPlz() peterRef ! StopPlz()
// FIXME #26514: doesn't compile with Scala 2.13.0-M5 // FIXME #26514: doesn't compile with Scala 2.13.0-M5
/* /*