Change the package name of all classes in remote module to 'akka.remote'.
Signed-off-by: Jonas Bonér <jonas@jonasboner.com>
This commit is contained in:
parent
7bc698f864
commit
978cbe4437
22 changed files with 1024 additions and 1012 deletions
102
akka-remote/src/test/scala/akka/remote/NetworkFailureSpec.scala
Normal file
102
akka-remote/src/test/scala/akka/remote/NetworkFailureSpec.scala
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2011 Typesafe Inc. <http://www.typesafe.com>
|
||||
*/
|
||||
|
||||
package akka.remote
|
||||
|
||||
import org.scalatest.{ Spec, WordSpec, BeforeAndAfterAll, BeforeAndAfterEach }
|
||||
import org.scalatest.matchers.MustMatchers
|
||||
import org.scalatest.junit.JUnitRunner
|
||||
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import akka.remote.netty.NettyRemoteSupport
|
||||
import akka.actor.{ Actor, ActorRegistry }
|
||||
|
||||
import java.util.concurrent.{ TimeUnit, CountDownLatch }
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
trait NetworkFailureSpec { self: WordSpec ⇒
|
||||
import Actor._
|
||||
import akka.util.Duration
|
||||
|
||||
val BytesPerSecond = "60KByte/s"
|
||||
val DelayMillis = "350ms"
|
||||
val PortRang = "1024-65535"
|
||||
|
||||
def replyWithTcpResetFor(duration: Duration, dead: AtomicBoolean) = {
|
||||
spawn {
|
||||
try {
|
||||
enableTcpReset()
|
||||
println("===>>> Reply with [TCP RST] for [" + duration + "]")
|
||||
Thread.sleep(duration.toMillis)
|
||||
restoreIP
|
||||
} catch {
|
||||
case e ⇒
|
||||
dead.set(true)
|
||||
e.printStackTrace
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def throttleNetworkFor(duration: Duration, dead: AtomicBoolean) = {
|
||||
spawn {
|
||||
try {
|
||||
enableNetworkThrottling()
|
||||
println("===>>> Throttling network with [" + BytesPerSecond + ", " + DelayMillis + "] for [" + duration + "]")
|
||||
Thread.sleep(duration.toMillis)
|
||||
restoreIP
|
||||
} catch {
|
||||
case e ⇒
|
||||
dead.set(true)
|
||||
e.printStackTrace
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def dropNetworkFor(duration: Duration, dead: AtomicBoolean) = {
|
||||
spawn {
|
||||
try {
|
||||
enableNetworkDrop()
|
||||
println("===>>> Blocking network [TCP DENY] for [" + duration + "]")
|
||||
Thread.sleep(duration.toMillis)
|
||||
restoreIP
|
||||
} catch {
|
||||
case e ⇒
|
||||
dead.set(true)
|
||||
e.printStackTrace
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def sleepFor(duration: Duration) = {
|
||||
println("===>>> Sleeping for [" + duration + "]")
|
||||
Thread sleep (duration.toMillis)
|
||||
}
|
||||
|
||||
def enableNetworkThrottling() = {
|
||||
restoreIP()
|
||||
assert(new ProcessBuilder("ipfw", "add", "pipe", "1", "ip", "from", "any", "to", "any").start.waitFor == 0)
|
||||
assert(new ProcessBuilder("ipfw", "add", "pipe", "2", "ip", "from", "any", "to", "any").start.waitFor == 0)
|
||||
assert(new ProcessBuilder("ipfw", "pipe", "1", "config", "bw", BytesPerSecond, "delay", DelayMillis).start.waitFor == 0)
|
||||
assert(new ProcessBuilder("ipfw", "pipe", "2", "config", "bw", BytesPerSecond, "delay", DelayMillis).start.waitFor == 0)
|
||||
}
|
||||
|
||||
def enableNetworkDrop() = {
|
||||
restoreIP()
|
||||
assert(new ProcessBuilder("ipfw", "add", "1", "deny", "tcp", "from", "any", "to", "any", PortRang).start.waitFor == 0)
|
||||
}
|
||||
|
||||
def enableTcpReset() = {
|
||||
restoreIP()
|
||||
assert(new ProcessBuilder("ipfw", "add", "1", "reset", "tcp", "from", "any", "to", "any", PortRang).start.waitFor == 0)
|
||||
}
|
||||
|
||||
def restoreIP() = {
|
||||
println("===>>> Restoring network")
|
||||
assert(new ProcessBuilder("ipfw", "del", "pipe", "1").start.waitFor == 0)
|
||||
assert(new ProcessBuilder("ipfw", "del", "pipe", "2").start.waitFor == 0)
|
||||
assert(new ProcessBuilder("ipfw", "flush").start.waitFor == 0)
|
||||
assert(new ProcessBuilder("ipfw", "pipe", "flush").start.waitFor == 0)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue