Harden ClusterClientHandoverSpec #24959
The test failed timing out waiting for a cluster to remove a member. It was nearly done. This change uses the common configuration used for cluster tests to speed up membership changes rather than increasing the timeout.
This commit is contained in:
parent
59ed3b353f
commit
161d2de44a
2 changed files with 14 additions and 33 deletions
|
|
@ -3,8 +3,8 @@
|
|||
*/
|
||||
package akka.cluster.client
|
||||
|
||||
import akka.actor.ActorRef
|
||||
import akka.cluster.{ Cluster, ClusterReadView, MemberStatus }
|
||||
import akka.actor.{ ActorPath, ActorRef }
|
||||
import akka.cluster.{ Cluster, MultiNodeClusterSpec }
|
||||
import akka.remote.testconductor.RoleName
|
||||
import akka.remote.testkit.{ MultiNodeConfig, MultiNodeSpec, STMultiNodeSpec }
|
||||
import akka.testkit.{ ImplicitSender, TestActors }
|
||||
|
|
@ -28,16 +28,14 @@ object ClusterClientHandoverSpec extends MultiNodeConfig {
|
|||
|
||||
}
|
||||
akka.test.filter-leeway = 10s
|
||||
"""))
|
||||
""").withFallback(MultiNodeClusterSpec.clusterConfig))
|
||||
}
|
||||
|
||||
class ClusterClientHandoverMultiJvmNode1 extends ClusterClientHandoverSpec
|
||||
class ClusterClientHandoverSpecMultiJvmNode1 extends ClusterClientHandoverSpec
|
||||
class ClusterClientHandoverSpecMultiJvmNode2 extends ClusterClientHandoverSpec
|
||||
class ClusterClientHandoverSpecMultiJvmNode3 extends ClusterClientHandoverSpec
|
||||
|
||||
class ClusterClientHandoverMultiJvmNode2 extends ClusterClientHandoverSpec
|
||||
|
||||
class ClusterClientHandoverMultiJvmNode3 extends ClusterClientHandoverSpec
|
||||
|
||||
class ClusterClientHandoverSpec extends MultiNodeSpec(ClusterClientHandoverSpec) with STMultiNodeSpec with ImplicitSender {
|
||||
class ClusterClientHandoverSpec extends MultiNodeSpec(ClusterClientHandoverSpec) with STMultiNodeSpec with ImplicitSender with MultiNodeClusterSpec {
|
||||
|
||||
import ClusterClientHandoverSpec._
|
||||
|
||||
|
|
@ -51,29 +49,19 @@ class ClusterClientHandoverSpec extends MultiNodeSpec(ClusterClientHandoverSpec)
|
|||
enterBarrier(from.name + "-joined")
|
||||
}
|
||||
|
||||
def clusterView: ClusterReadView = Cluster(system).readView
|
||||
|
||||
def awaitUp(expected: Int): Unit = {
|
||||
awaitAssert {
|
||||
awaitAssert(clusterView.members.size should ===(expected))
|
||||
awaitAssert(clusterView.members.map(_.status) should ===(Set(MemberStatus.Up)))
|
||||
}
|
||||
}
|
||||
|
||||
def initialContacts = Set(first, second).map { r ⇒
|
||||
def initialContacts: Set[ActorPath] = Set(first, second).map { r ⇒
|
||||
node(r) / "system" / "receptionist"
|
||||
}
|
||||
|
||||
"A Cluster Client" should {
|
||||
"A Cluster Client" must {
|
||||
|
||||
"startup cluster with a single node" in within(30.seconds) {
|
||||
join(first, first)
|
||||
runOn(first) {
|
||||
val service = system.actorOf(TestActors.echoActorProps, "testService")
|
||||
ClusterClientReceptionist(system).registerService(service)
|
||||
awaitUp(1)
|
||||
awaitMembersUp(1)
|
||||
}
|
||||
|
||||
enterBarrier("cluster-started")
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +74,6 @@ class ClusterClientHandoverSpec extends MultiNodeSpec(ClusterClientHandoverSpec)
|
|||
clusterClient ! ClusterClient.Send("/user/testService", "hello", localAffinity = true)
|
||||
expectMsgType[String](3.seconds) should be("hello")
|
||||
}
|
||||
|
||||
enterBarrier("established")
|
||||
}
|
||||
|
||||
|
|
@ -95,9 +82,8 @@ class ClusterClientHandoverSpec extends MultiNodeSpec(ClusterClientHandoverSpec)
|
|||
runOn(second) {
|
||||
val service = system.actorOf(TestActors.echoActorProps, "testService")
|
||||
ClusterClientReceptionist(system).registerService(service)
|
||||
awaitUp(2)
|
||||
awaitMembersUp(2)
|
||||
}
|
||||
|
||||
enterBarrier("second-up")
|
||||
}
|
||||
|
||||
|
|
@ -107,9 +93,8 @@ class ClusterClientHandoverSpec extends MultiNodeSpec(ClusterClientHandoverSpec)
|
|||
}
|
||||
|
||||
runOn(second) {
|
||||
awaitUp(1)
|
||||
awaitMembersUp(1)
|
||||
}
|
||||
|
||||
enterBarrier("handover-done")
|
||||
}
|
||||
|
||||
|
|
@ -118,10 +103,7 @@ class ClusterClientHandoverSpec extends MultiNodeSpec(ClusterClientHandoverSpec)
|
|||
clusterClient ! ClusterClient.Send("/user/testService", "hello", localAffinity = true)
|
||||
expectMsgType[String](3.seconds) should be("hello")
|
||||
}
|
||||
|
||||
enterBarrier("handover-successful")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ package akka.testkit.typed.scaladsl
|
|||
|
||||
//#manual-scheduling-simple
|
||||
import akka.actor.typed.scaladsl.Behaviors
|
||||
import org.scalatest.WordSpecLike
|
||||
|
||||
import scala.concurrent.duration._
|
||||
|
||||
|
|
@ -14,7 +13,7 @@ class ManualTimerExampleSpec extends AbstractActorSpec {
|
|||
|
||||
override def config = ManualTime.config
|
||||
|
||||
val manualTime = ManualTime()
|
||||
val manualTime: ManualTime = ManualTime()
|
||||
|
||||
"A timer" must {
|
||||
"schedule non-repeated ticks" in {
|
||||
|
|
@ -24,7 +23,7 @@ class ManualTimerExampleSpec extends AbstractActorSpec {
|
|||
val probe = TestProbe[Tock.type]()
|
||||
val behavior = Behaviors.withTimers[Tick.type] { timer ⇒
|
||||
timer.startSingleTimer("T", Tick, 10.millis)
|
||||
Behaviors.receive { (ctx, Tick) ⇒
|
||||
Behaviors.receiveMessage { _ ⇒
|
||||
probe.ref ! Tock
|
||||
Behaviors.same
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue