Permalink
Browse files

Merge pull request #993 from akka/wip-2846-stop-ReliableProxySpec-pat…

…riknw

Clean shutdown of ReliableProxySpec, see #2846
  • Loading branch information...
2 parents 88f40d3 + 48c6374 commit 27acfcf5e1000be3bc7b8c640e8c00034c9cbd22 @patriknw patriknw committed Jan 4, 2013
@@ -37,17 +37,18 @@ class ReliableProxySpec extends MultiNodeSpec(ReliableProxySpec) with STMultiNod
override def afterEach {
runOn(local) {
- testConductor.throttle(local, remote, Direction.Both, -1).await
+ testConductor.passThrough(local, remote, Direction.Both).await
}
+ enterBarrier("after-each")
}
@volatile var target: ActorRef = system.deadLetters
@volatile var proxy: ActorRef = system.deadLetters
def expectState(s: State) = expectMsg(FSM.CurrentState(proxy, s))
def expectTransition(s1: State, s2: State) = expectMsg(FSM.Transition(proxy, s1, s2))
-
- def sendN(n: Int) = (1 to n) foreach (proxy ! _)
+
+ def sendN(n: Int) = (1 to n) foreach (proxy ! _)
def expectN(n: Int) = (1 to n) foreach { n expectMsg(n); lastSender must be === target }
"A ReliableProxy" must {
@@ -82,6 +83,8 @@ class ReliableProxySpec extends MultiNodeSpec(ReliableProxySpec) with STMultiNod
runOn(remote) {
expectMsg("hello")
}
+
+ enterBarrier("initialize-done")
}
"forward messages in sequence" in {
@@ -95,9 +98,9 @@ class ReliableProxySpec extends MultiNodeSpec(ReliableProxySpec) with STMultiNod
expectN(100)
}
}
-
+
enterBarrier("test1a")
-
+
runOn(local) {
sendN(100)
expectTransition(Idle, Active)
@@ -108,7 +111,7 @@ class ReliableProxySpec extends MultiNodeSpec(ReliableProxySpec) with STMultiNod
expectN(100)
}
}
-
+
enterBarrier("test1b")
}
@@ -121,25 +124,25 @@ class ReliableProxySpec extends MultiNodeSpec(ReliableProxySpec) with STMultiNod
expectNoMsg
}
}
-
+
enterBarrier("test2a")
-
+
runOn(remote) {
expectNoMsg(0 seconds)
}
-
+
enterBarrier("test2b")
-
+
runOn(local) {
- testConductor.throttle(local, remote, Direction.Send, -1).await
+ testConductor.passThrough(local, remote, Direction.Send).await
within(5 seconds) { expectTransition(Active, Idle) }
}
runOn(remote) {
within(1 second) {
expectN(100)
}
}
-
+
enterBarrier("test2c")
}
@@ -157,14 +160,14 @@ class ReliableProxySpec extends MultiNodeSpec(ReliableProxySpec) with STMultiNod
expectN(100)
}
}
-
+
enterBarrier("test3a")
-
+
runOn(local) {
- testConductor.throttle(local, remote, Direction.Receive, -1).await
+ testConductor.passThrough(local, remote, Direction.Receive).await
within(5 seconds) { expectTransition(Active, Idle) }
}
-
+
enterBarrier("test3b")
}
@@ -182,11 +185,11 @@ class ReliableProxySpec extends MultiNodeSpec(ReliableProxySpec) with STMultiNod
expectN(50)
}
}
-
+
enterBarrier("test4a")
-
+
runOn(local) {
- testConductor.throttle(local, remote, Direction.Send, rateMBit = -1).await
+ testConductor.passThrough(local, remote, Direction.Send).await
testConductor.throttle(local, remote, Direction.Receive, rateMBit = 0.1).await
sendN(50)
within(5 seconds) {
@@ -199,8 +202,8 @@ class ReliableProxySpec extends MultiNodeSpec(ReliableProxySpec) with STMultiNod
expectN(50)
}
}
-
- enterBarrier("test4a")
+
+ enterBarrier("test4b")
}
}
@@ -207,8 +207,8 @@ surprising ways.
* Don't issue a shutdown of the first node. The first node is the controller and if it shuts down your test will break.
- * To be able to use ``blackhole``, ``passThrough``, and ``throttle`` you must activate the ``TestConductorTranport``
- by specifying ``testTransport(on = true)`` in your MultiNodeConfig.
+ * To be able to use ``blackhole``, ``passThrough``, and ``throttle`` you must activate the failure injector and
+ throttler transport adapters by specifying ``testTransport(on = true)`` in your MultiNodeConfig.
* Throttling, shutdown and other failure injections can only be done from the first node, which again is the controller.
@@ -94,8 +94,8 @@ trait Conductor { this: TestConductorExt ⇒
* increased latency.
*
* ====Note====
- * To use this feature you must activate the `TestConductorTranport`
- * by specifying `testTransport(on = true)` in your MultiNodeConfig.
+ * To use this feature you must activate the failure injector and throttler
+ * transport adapters by specifying `testTransport(on = true)` in your MultiNodeConfig.
*
* @param node is the symbolic name of the node which is to be affected
* @param target is the symbolic name of the other node to which connectivity shall be throttled
@@ -115,18 +115,15 @@ trait Conductor { this: TestConductorExt ⇒
* Socket.
*
* ====Note====
- * To use this feature you must activate the `TestConductorTranport`
- * by specifying `testTransport(on = true)` in your MultiNodeConfig.
+ * To use this feature you must activate the failure injector and throttler
+ * transport adapters by specifying `testTransport(on = true)` in your MultiNodeConfig.
*
* @param node is the symbolic name of the node which is to be affected
* @param target is the symbolic name of the other node to which connectivity shall be impeded
* @param direction can be either `Direction.Send`, `Direction.Receive` or `Direction.Both`
*/
- def blackhole(node: RoleName, target: RoleName, direction: Direction): Future[Done] = {
- import Settings.QueryTimeout
- requireTestConductorTranport()
- controller ? Throttle(node, target, direction, 0f) mapTo classTag[Done]
- }
+ def blackhole(node: RoleName, target: RoleName, direction: Direction): Future[Done] =
+ throttle(node, target, direction, 0f)
private def requireTestConductorTranport(): Unit = if (!transport.defaultAddress.protocol.contains(".gremlin.trttl."))
throw new ConfigurationException("To use this feature you must activate the failure injector adapters " +
@@ -137,18 +134,15 @@ trait Conductor { this: TestConductorExt ⇒
* sending and/or receiving.
*
* ====Note====
- * To use this feature you must activate the `TestConductorTranport`
- * by specifying `testTransport(on = true)` in your MultiNodeConfig.
+ * To use this feature you must activate the failure injector and throttler
+ * transport adapters by specifying `testTransport(on = true)` in your MultiNodeConfig.
*
* @param node is the symbolic name of the node which is to be affected
* @param target is the symbolic name of the other node to which connectivity shall be impeded
* @param direction can be either `Direction.Send`, `Direction.Receive` or `Direction.Both`
*/
- def passThrough(node: RoleName, target: RoleName, direction: Direction): Future[Done] = {
- import Settings.QueryTimeout
- requireTestConductorTranport()
- controller ? Throttle(node, target, direction, -1f) mapTo classTag[Done]
- }
+ def passThrough(node: RoleName, target: RoleName, direction: Direction): Future[Done] =
+ throttle(node, target, direction, -1f)
/**
* Tell the remote support to shutdown the connection to the given remote
@@ -36,8 +36,8 @@ object TestConductor extends ExtensionKey[TestConductorExt] {
* to be a [[akka.remote.RemoteActorRefProvider]].
*
* To use ``blackhole``, ``passThrough``, and ``throttle`` you must activate the
- * `TestConductorTranport` by specifying `testTransport(on = true)` in your
- * MultiNodeConfig.
+ * failure injector and throttler transport adapters by specifying `testTransport(on = true)`
+ * in your MultiNodeConfig.
*
*/
class TestConductorExt(val system: ExtendedActorSystem) extends Extension with Conductor with Player {
@@ -87,8 +87,8 @@ abstract class MultiNodeConfig {
/**
* To be able to use `blackhole`, `passThrough`, and `throttle` you must
- * activate the TestConductorTranport by specifying
- * `testTransport(on = true)` in your MultiNodeConfig.
+ * activate the failure injector and throttler transport adapters by
+ * specifying `testTransport(on = true)` in your MultiNodeConfig.
*/
def testTransport(on: Boolean): Unit = _testTransport = on
Oops, something went wrong.

0 comments on commit 27acfcf

Please sign in to comment.