From d931a6e727ee70952136f42250132e28a8aa34b4 Mon Sep 17 00:00:00 2001 From: Roland Date: Thu, 10 May 2012 10:24:05 +0200 Subject: [PATCH] break out TestConductor stuff into akka-remote-tests project --- .../testconductor/TestConductorProtocol.java | 0 .../main/protocol/TestConductorProtocol.proto | 0 .../src/main/resources/reference.conf | 34 +++++++++++++++++++ .../akka/remote/testconductor/Conductor.scala | 12 +++---- .../akka/remote/testconductor/DataTypes.scala | 0 .../akka/remote/testconductor/Extension.scala | 0 .../akka/remote/testconductor/Features.scala | 0 .../NetworkFailureInjector.scala | 0 .../akka/remote/testconductor/Player.scala | 0 .../testconductor/RemoteConnection.scala | 0 .../TestConductorTransport.scala | 0 .../akka/remote/testconductor/package.scala | 0 .../testconductor/TestConductorSpec.scala | 0 akka-remote/src/main/resources/reference.conf | 26 -------------- project/AkkaBuild.scala | 20 ++++++++++- 15 files changed, 59 insertions(+), 33 deletions(-) rename {akka-remote => akka-remote-tests}/src/main/java/akka/remote/testconductor/TestConductorProtocol.java (100%) rename {akka-remote => akka-remote-tests}/src/main/protocol/TestConductorProtocol.proto (100%) create mode 100644 akka-remote-tests/src/main/resources/reference.conf rename {akka-remote => akka-remote-tests}/src/main/scala/akka/remote/testconductor/Conductor.scala (97%) rename {akka-remote => akka-remote-tests}/src/main/scala/akka/remote/testconductor/DataTypes.scala (100%) rename {akka-remote => akka-remote-tests}/src/main/scala/akka/remote/testconductor/Extension.scala (100%) rename {akka-remote => akka-remote-tests}/src/main/scala/akka/remote/testconductor/Features.scala (100%) rename {akka-remote => akka-remote-tests}/src/main/scala/akka/remote/testconductor/NetworkFailureInjector.scala (100%) rename {akka-remote => akka-remote-tests}/src/main/scala/akka/remote/testconductor/Player.scala (100%) rename {akka-remote => akka-remote-tests}/src/main/scala/akka/remote/testconductor/RemoteConnection.scala (100%) rename {akka-remote => akka-remote-tests}/src/main/scala/akka/remote/testconductor/TestConductorTransport.scala (100%) rename {akka-remote => akka-remote-tests}/src/main/scala/akka/remote/testconductor/package.scala (100%) rename {akka-remote => akka-remote-tests}/src/multi-jvm/scala/akka/remote/testconductor/TestConductorSpec.scala (100%) diff --git a/akka-remote/src/main/java/akka/remote/testconductor/TestConductorProtocol.java b/akka-remote-tests/src/main/java/akka/remote/testconductor/TestConductorProtocol.java similarity index 100% rename from akka-remote/src/main/java/akka/remote/testconductor/TestConductorProtocol.java rename to akka-remote-tests/src/main/java/akka/remote/testconductor/TestConductorProtocol.java diff --git a/akka-remote/src/main/protocol/TestConductorProtocol.proto b/akka-remote-tests/src/main/protocol/TestConductorProtocol.proto similarity index 100% rename from akka-remote/src/main/protocol/TestConductorProtocol.proto rename to akka-remote-tests/src/main/protocol/TestConductorProtocol.proto diff --git a/akka-remote-tests/src/main/resources/reference.conf b/akka-remote-tests/src/main/resources/reference.conf new file mode 100644 index 0000000000..f0d8a9d6ae --- /dev/null +++ b/akka-remote-tests/src/main/resources/reference.conf @@ -0,0 +1,34 @@ +############################################# +# Akka Remote Testing Reference Config File # +############################################# + +# This is the reference config file that contains all the default settings. +# Make your edits/overrides in your application.conf. + +akka { + testconductor { + + # Timeout for joining a barrier: this is the maximum time any participants + # waits for everybody else to join a named barrier. + barrier-timeout = 30s + + # Timeout for interrogation of TestConductor’s Controller actor + query-timeout = 5s + + # Threshold for packet size in time unit above which the failure injector will + # split the packet and deliver in smaller portions; do not give value smaller + # than HashedWheelTimer resolution (would not make sense) + packet-split-threshold = 100ms + + # Default port to start the conductor on; 0 means + port = 0 + + # Hostname of the TestConductor server, used by the server to bind to the IP + # and by the client to connect to it. + host = localhost + + # Name of the TestConductor client (for identification on the server e.g. for + # failure injection) + name = "noname" + } +} \ No newline at end of file diff --git a/akka-remote/src/main/scala/akka/remote/testconductor/Conductor.scala b/akka-remote-tests/src/main/scala/akka/remote/testconductor/Conductor.scala similarity index 97% rename from akka-remote/src/main/scala/akka/remote/testconductor/Conductor.scala rename to akka-remote-tests/src/main/scala/akka/remote/testconductor/Conductor.scala index 2bbae6d28b..b25bd1838c 100644 --- a/akka-remote/src/main/scala/akka/remote/testconductor/Conductor.scala +++ b/akka-remote-tests/src/main/scala/akka/remote/testconductor/Conductor.scala @@ -24,6 +24,7 @@ import java.net.InetSocketAddress import akka.dispatch.Future import akka.actor.OneForOneStrategy import akka.actor.SupervisorStrategy +import java.util.concurrent.ConcurrentHashMap trait Conductor extends RunControl with FailureInject { this: TestConductorExt ⇒ @@ -91,22 +92,21 @@ trait Conductor extends RunControl with FailureInject { this: TestConductorExt class ConductorHandler(system: ActorSystem, controller: ActorRef, log: LoggingAdapter) extends SimpleChannelUpstreamHandler { - @volatile - var clients = Map[Channel, ActorRef]() + val clients = new ConcurrentHashMap[Channel, ActorRef]() override def channelConnected(ctx: ChannelHandlerContext, event: ChannelStateEvent) = { val channel = event.getChannel log.debug("connection from {}", getAddrString(channel)) val fsm = system.actorOf(Props(new ServerFSM(controller, channel))) - clients += channel -> fsm + clients.put(channel, fsm) } override def channelDisconnected(ctx: ChannelHandlerContext, event: ChannelStateEvent) = { val channel = event.getChannel log.debug("disconnect from {}", getAddrString(channel)) - val fsm = clients(channel) + val fsm = clients.get(channel) fsm ! PoisonPill - clients -= channel + clients.remove(channel) } override def messageReceived(ctx: ChannelHandlerContext, event: MessageEvent) = { @@ -114,7 +114,7 @@ class ConductorHandler(system: ActorSystem, controller: ActorRef, log: LoggingAd log.debug("message from {}: {}", getAddrString(channel), event.getMessage) event.getMessage match { case msg: NetworkOp ⇒ - clients(channel) ! msg + clients.get(channel) ! msg case msg ⇒ log.info("client {} sent garbage '{}', disconnecting", getAddrString(channel), msg) channel.close() diff --git a/akka-remote/src/main/scala/akka/remote/testconductor/DataTypes.scala b/akka-remote-tests/src/main/scala/akka/remote/testconductor/DataTypes.scala similarity index 100% rename from akka-remote/src/main/scala/akka/remote/testconductor/DataTypes.scala rename to akka-remote-tests/src/main/scala/akka/remote/testconductor/DataTypes.scala diff --git a/akka-remote/src/main/scala/akka/remote/testconductor/Extension.scala b/akka-remote-tests/src/main/scala/akka/remote/testconductor/Extension.scala similarity index 100% rename from akka-remote/src/main/scala/akka/remote/testconductor/Extension.scala rename to akka-remote-tests/src/main/scala/akka/remote/testconductor/Extension.scala diff --git a/akka-remote/src/main/scala/akka/remote/testconductor/Features.scala b/akka-remote-tests/src/main/scala/akka/remote/testconductor/Features.scala similarity index 100% rename from akka-remote/src/main/scala/akka/remote/testconductor/Features.scala rename to akka-remote-tests/src/main/scala/akka/remote/testconductor/Features.scala diff --git a/akka-remote/src/main/scala/akka/remote/testconductor/NetworkFailureInjector.scala b/akka-remote-tests/src/main/scala/akka/remote/testconductor/NetworkFailureInjector.scala similarity index 100% rename from akka-remote/src/main/scala/akka/remote/testconductor/NetworkFailureInjector.scala rename to akka-remote-tests/src/main/scala/akka/remote/testconductor/NetworkFailureInjector.scala diff --git a/akka-remote/src/main/scala/akka/remote/testconductor/Player.scala b/akka-remote-tests/src/main/scala/akka/remote/testconductor/Player.scala similarity index 100% rename from akka-remote/src/main/scala/akka/remote/testconductor/Player.scala rename to akka-remote-tests/src/main/scala/akka/remote/testconductor/Player.scala diff --git a/akka-remote/src/main/scala/akka/remote/testconductor/RemoteConnection.scala b/akka-remote-tests/src/main/scala/akka/remote/testconductor/RemoteConnection.scala similarity index 100% rename from akka-remote/src/main/scala/akka/remote/testconductor/RemoteConnection.scala rename to akka-remote-tests/src/main/scala/akka/remote/testconductor/RemoteConnection.scala diff --git a/akka-remote/src/main/scala/akka/remote/testconductor/TestConductorTransport.scala b/akka-remote-tests/src/main/scala/akka/remote/testconductor/TestConductorTransport.scala similarity index 100% rename from akka-remote/src/main/scala/akka/remote/testconductor/TestConductorTransport.scala rename to akka-remote-tests/src/main/scala/akka/remote/testconductor/TestConductorTransport.scala diff --git a/akka-remote/src/main/scala/akka/remote/testconductor/package.scala b/akka-remote-tests/src/main/scala/akka/remote/testconductor/package.scala similarity index 100% rename from akka-remote/src/main/scala/akka/remote/testconductor/package.scala rename to akka-remote-tests/src/main/scala/akka/remote/testconductor/package.scala diff --git a/akka-remote/src/multi-jvm/scala/akka/remote/testconductor/TestConductorSpec.scala b/akka-remote-tests/src/multi-jvm/scala/akka/remote/testconductor/TestConductorSpec.scala similarity index 100% rename from akka-remote/src/multi-jvm/scala/akka/remote/testconductor/TestConductorSpec.scala rename to akka-remote-tests/src/multi-jvm/scala/akka/remote/testconductor/TestConductorSpec.scala diff --git a/akka-remote/src/main/resources/reference.conf b/akka-remote/src/main/resources/reference.conf index f14ee3d87c..1438904fe2 100644 --- a/akka-remote/src/main/resources/reference.conf +++ b/akka-remote/src/main/resources/reference.conf @@ -155,30 +155,4 @@ akka { type = PinnedDispatcher } } - - testconductor { - - # Timeout for joining a barrier: this is the maximum time any participants - # waits for everybody else to join a named barrier. - barrier-timeout = 30s - - # Timeout for interrogation of TestConductor’s Controller actor - query-timeout = 5s - - # Threshold for packet size in time unit above which the failure injector will - # split the packet and deliver in smaller portions; do not give value smaller - # than HashedWheelTimer resolution (would not make sense) - packet-split-threshold = 100ms - - # Default port to start the conductor on; 0 means - port = 0 - - # Hostname of the TestConductor server, used by the server to bind to the IP - # and by the client to connect to it. - host = localhost - - # Name of the TestConductor client (for identification on the server e.g. for - # failure injection) - name = "noname" - } } diff --git a/project/AkkaBuild.scala b/project/AkkaBuild.scala index f9fbfc6c4b..b899bdec45 100644 --- a/project/AkkaBuild.scala +++ b/project/AkkaBuild.scala @@ -87,6 +87,24 @@ object AkkaBuild extends Build { ) ) configs (MultiJvm) + lazy val remoteTests = Project( + id = "akka-remote-tests", + base = file("akka-remote-tests"), + dependencies = Seq(remote % "compile;test->test;multi-jvm->multi-jvm", actorTests % "test->test", testkit % "test->test"), + settings = defaultSettings ++ multiJvmSettings ++ schoirSettings ++ Seq( + // disable parallel tests + parallelExecution in Test := false, + extraOptions in MultiJvm <<= (sourceDirectory in MultiJvm) { src => + (name: String) => (src ** (name + ".conf")).get.headOption.map("-Dakka.config=" + _.absolutePath).toSeq + }, + scalatestOptions in MultiJvm := Seq("-r", "org.scalatest.akka.QuietReporter"), + jvmOptions in MultiJvm := { + if (getBoolean("sbt.log.noformat")) Seq("-Dakka.test.nocolor=true") else Nil + }, + test in Test <<= (test in Test) dependsOn (test in MultiJvm) + ) + ) configs (MultiJvm) + lazy val cluster = Project( id = "akka-cluster", base = file("akka-cluster"), @@ -438,7 +456,7 @@ object Dependencies { Test.zookeeper, Test.log4j // needed for ZkBarrier in multi-jvm tests ) - val cluster = Seq(Test.junit, Test.scalatest) + val cluster = Seq(Test.junit, Test.scalatest) val slf4j = Seq(slf4jApi, Test.logback)