From e3107715c1f8a75bcc6320ca8188e1e40a2f91bc Mon Sep 17 00:00:00 2001 From: Peter Veentjer Date: Mon, 8 Aug 2011 18:43:30 +0300 Subject: [PATCH] Fix of failing ClusterActorRefCleanupMultiJvmSpec --- .../ClusterActorRefCleanupMultiJvmSpec.scala | 131 ++++++++++-------- 1 file changed, 70 insertions(+), 61 deletions(-) diff --git a/akka-cluster/src/multi-jvm/scala/akka/cluster/reflogic/ClusterActorRefCleanupMultiJvmSpec.scala b/akka-cluster/src/multi-jvm/scala/akka/cluster/reflogic/ClusterActorRefCleanupMultiJvmSpec.scala index fc4b2b3f5e..ea1095439e 100644 --- a/akka-cluster/src/multi-jvm/scala/akka/cluster/reflogic/ClusterActorRefCleanupMultiJvmSpec.scala +++ b/akka-cluster/src/multi-jvm/scala/akka/cluster/reflogic/ClusterActorRefCleanupMultiJvmSpec.scala @@ -41,71 +41,80 @@ class ClusterActorRefCleanupMultiJvmNode1 extends MasterClusterTestNode { "ClusterActorRef" must { "cleanup itself" in { - node.start - barrier("awaitStarted", NrOfNodes).await() - - val ref = Actor.actorOf[ClusterActorRefCleanupMultiJvmSpec.TestActor]("service-test") - - ref.isInstanceOf[ClusterActorRef] must be(true) - - val clusteredRef = ref.asInstanceOf[ClusterActorRef] - - //verify that all remote actors are there. - clusteredRef.connections.size must be(2) - - // ignore exceptions from killing nodes - val ignoreExceptions = Seq( - EventFilter[ClosedChannelException], - EventFilter[NotYetConnectedException], - EventFilter[RoutingException], - EventFilter[ConnectException]) - - EventHandler.notify(TestEvent.Mute(ignoreExceptions)) - - //let one of the actors die. - clusteredRef ! "Die" - - //just some waiting to make sure that the node has died. - Thread.sleep(5000) - - //send some request, this should trigger the cleanup try { + + node.start + barrier("awaitStarted", NrOfNodes).await() + + val ref = Actor.actorOf[ClusterActorRefCleanupMultiJvmSpec.TestActor]("service-test") + + ref.isInstanceOf[ClusterActorRef] must be(true) + + val clusteredRef = ref.asInstanceOf[ClusterActorRef] + + //verify that all remote actors are there. + clusteredRef.connections.size must be(2) + + // ignore exceptions from killing nodes + val ignoreExceptions = Seq( + EventFilter[ClosedChannelException], + EventFilter[NotYetConnectedException], + EventFilter[RoutingException], + EventFilter[ConnectException]) + + EventHandler.notify(TestEvent.Mute(ignoreExceptions)) + + //let one of the actors die. + clusteredRef ! "Die" + + //just some waiting to make sure that the node has died. + Thread.sleep(5000) + + //send some request, this should trigger the cleanup + try { + clusteredRef ! "hello" + clusteredRef ! "hello" + } catch { + case e: ClosedChannelException ⇒ + case e: NotYetConnectedException ⇒ + case e: RoutingException ⇒ + } + + //since the call to the node failed, the node must have been removed from the list. + clusteredRef.connections.size must be(1) + + //send a message to this node, clusteredRef ! "hello" - clusteredRef ! "hello" + + //now kill another node + clusteredRef ! "Die" + + //just some waiting to make sure that the node has died. + Thread.sleep(5000) + + //trigger the cleanup. + try { + clusteredRef ! "hello" + } catch { + case e: ClosedChannelException ⇒ + case e: NotYetConnectedException ⇒ + case e: RoutingException ⇒ + } + + //now there must not be any remaining connections after the dead of the last actor. + clusteredRef.connections.size must be(0) + + //and lets make sure we now get the correct exception if we try to use the ref. + intercept[RoutingException] { + clusteredRef ! "Hello" + } + + node.shutdown() } catch { - case e: NotYetConnectedException ⇒ + case e: Throwable ⇒ + e.printStackTrace(); + throw e } - - //since the call to the node failed, the node must have been removed from the list. - clusteredRef.connections.size must be(1) - - //send a message to this node, - clusteredRef ! "hello" - - //now kill another node - clusteredRef ! "Die" - - //just some waiting to make sure that the node has died. - Thread.sleep(5000) - - //trigger the cleanup. - try { - clusteredRef ! "hello" - } catch { - case e: ClosedChannelException ⇒ - case e: NotYetConnectedException ⇒ - case e: RoutingException ⇒ - } - - //now there must not be any remaining connections after the dead of the last actor. - clusteredRef.connections.size must be(0) - - //and lets make sure we now get the correct exception if we try to use the ref. - intercept[RoutingException] { - clusteredRef ! "Hello" - } - - node.shutdown() } } }