From f970c87ea449d764dd3540300860b0730cebd1f9 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Fri, 29 Jun 2012 09:38:06 +0200 Subject: [PATCH 01/11] Fix time sensitivity in LeaderLeavingSpec, see #2287 --- .../akka/cluster/LeaderLeavingSpec.scala | 73 ++++++++++++------- 1 file changed, 45 insertions(+), 28 deletions(-) diff --git a/akka-cluster/src/multi-jvm/scala/akka/cluster/LeaderLeavingSpec.scala b/akka-cluster/src/multi-jvm/scala/akka/cluster/LeaderLeavingSpec.scala index 54154b6973..e232802eeb 100644 --- a/akka-cluster/src/multi-jvm/scala/akka/cluster/LeaderLeavingSpec.scala +++ b/akka-cluster/src/multi-jvm/scala/akka/cluster/LeaderLeavingSpec.scala @@ -18,10 +18,8 @@ object LeaderLeavingMultiJvmSpec extends MultiNodeConfig { commonConfig( debugConfig(on = false) .withFallback(ConfigFactory.parseString(""" - akka.cluster { - leader-actions-interval = 5 s # increase the leader action task frequency to make sure we get a chance to test the LEAVING state - unreachable-nodes-reaper-interval = 30 s - }""") + # turn off unreachable reaper + akka.cluster.unreachable-nodes-reaper-interval = 300 s""") .withFallback(MultiNodeClusterSpec.clusterConfig))) } @@ -35,7 +33,7 @@ abstract class LeaderLeavingSpec import LeaderLeavingMultiJvmSpec._ - val leaderHandoffWaitingTime = 30.seconds.dilated + val leaderHandoffWaitingTime = 30.seconds "A LEADER that is LEAVING" must { @@ -45,41 +43,60 @@ abstract class LeaderLeavingSpec val oldLeaderAddress = cluster.leader - if (cluster.isLeader) { + within(leaderHandoffWaitingTime) { - cluster.leave(oldLeaderAddress) - enterBarrier("leader-left") + if (cluster.isLeader) { - // verify that a NEW LEADER have taken over - awaitCond(!cluster.isLeader) + enterBarrier("registered-listener") - // verify that the LEADER is shut down - awaitCond(!cluster.isRunning, 30.seconds.dilated) + cluster.leave(oldLeaderAddress) + enterBarrier("leader-left") - // verify that the LEADER is REMOVED - awaitCond(cluster.status == MemberStatus.Removed) + // verify that a NEW LEADER have taken over + awaitCond(!cluster.isLeader) - } else { + // verify that the LEADER is shut down + awaitCond(!cluster.isRunning) - enterBarrier("leader-left") + // verify that the LEADER is REMOVED + awaitCond(cluster.status == MemberStatus.Removed) - // verify that the LEADER is LEAVING - awaitCond(cluster.latestGossip.members.exists(m ⇒ m.status == MemberStatus.Leaving && m.address == oldLeaderAddress), leaderHandoffWaitingTime) // wait on LEAVING + } else { - // verify that the LEADER is EXITING - awaitCond(cluster.latestGossip.members.exists(m ⇒ m.status == MemberStatus.Exiting && m.address == oldLeaderAddress), leaderHandoffWaitingTime) // wait on EXITING + val leavingLatch = TestLatch() + val exitingLatch = TestLatch() + val expectedAddresses = roles.toSet map address + cluster.registerListener(new MembershipChangeListener { + def notify(members: SortedSet[Member]) { + def check(status: MemberStatus): Boolean = + (members.map(_.address) == expectedAddresses && + members.exists(m ⇒ m.address == oldLeaderAddress && m.status == status)) + if (check(MemberStatus.Leaving)) leavingLatch.countDown() + if (check(MemberStatus.Exiting)) exitingLatch.countDown() + } + }) + enterBarrier("registered-listener") - // verify that the LEADER is no longer part of the 'members' set - awaitCond(cluster.latestGossip.members.forall(_.address != oldLeaderAddress), leaderHandoffWaitingTime) + enterBarrier("leader-left") - // verify that the LEADER is not part of the 'unreachable' set - awaitCond(cluster.latestGossip.overview.unreachable.forall(_.address != oldLeaderAddress), leaderHandoffWaitingTime) + // verify that the LEADER is LEAVING + leavingLatch.await - // verify that we have a new LEADER - awaitCond(cluster.leader != oldLeaderAddress, leaderHandoffWaitingTime) + // verify that the LEADER is EXITING + exitingLatch.await + + // verify that the LEADER is no longer part of the 'members' set + awaitCond(cluster.latestGossip.members.forall(_.address != oldLeaderAddress)) + + // verify that the LEADER is not part of the 'unreachable' set + awaitCond(cluster.latestGossip.overview.unreachable.forall(_.address != oldLeaderAddress)) + + // verify that we have a new LEADER + awaitCond(cluster.leader != oldLeaderAddress) + } + + enterBarrier("finished") } - - enterBarrier("finished") } } } From aa88818f715e0784da4af9952b35973ec3d8110b Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 3 Jul 2012 11:09:34 +0200 Subject: [PATCH 02/11] Fix time sensitivity in NodeLeavingAndExitingSpec, see #2289 --- .../cluster/NodeLeavingAndExitingSpec.scala | 54 +++++++++++-------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/akka-cluster/src/multi-jvm/scala/akka/cluster/NodeLeavingAndExitingSpec.scala b/akka-cluster/src/multi-jvm/scala/akka/cluster/NodeLeavingAndExitingSpec.scala index 5f9efb0b47..565d78e9d8 100644 --- a/akka-cluster/src/multi-jvm/scala/akka/cluster/NodeLeavingAndExitingSpec.scala +++ b/akka-cluster/src/multi-jvm/scala/akka/cluster/NodeLeavingAndExitingSpec.scala @@ -18,11 +18,8 @@ object NodeLeavingAndExitingMultiJvmSpec extends MultiNodeConfig { commonConfig( debugConfig(on = false) .withFallback(ConfigFactory.parseString(""" - akka.cluster { - leader-actions-interval = 5 s # increase the leader action task frequency to make sure we get a chance to test the LEAVING state - unreachable-nodes-reaper-interval = 300 s # turn "off" - } - """) + # turn off unreachable reaper + akka.cluster.unreachable-nodes-reaper-interval = 300 s""") .withFallback(MultiNodeClusterSpec.clusterConfig))) } @@ -42,26 +39,39 @@ abstract class NodeLeavingAndExitingSpec awaitClusterUp(first, second, third) - runOn(first) { - cluster.leave(second) - } - enterBarrier("second-left") - runOn(first, third) { + val secondAddess = address(second) + val leavingLatch = TestLatch() + val exitingLatch = TestLatch() + val expectedAddresses = roles.toSet map address + cluster.registerListener(new MembershipChangeListener { + def notify(members: SortedSet[Member]) { + def check(status: MemberStatus): Boolean = + (members.map(_.address) == expectedAddresses && + members.exists(m ⇒ m.address == secondAddess && m.status == status)) + if (check(MemberStatus.Leaving)) leavingLatch.countDown() + if (check(MemberStatus.Exiting)) exitingLatch.countDown() + } + }) + enterBarrier("registered-listener") - // 1. Verify that 'second' node is set to LEAVING - // We have set the 'leader-actions-interval' to 5 seconds to make sure that we get a - // chance to test the LEAVING state before the leader moves the node to EXITING - awaitCond(cluster.latestGossip.members.exists(_.status == MemberStatus.Leaving)) // wait on LEAVING - val hasLeft = cluster.latestGossip.members.find(_.status == MemberStatus.Leaving) // verify node that left - hasLeft must be('defined) - hasLeft.get.address must be(address(second)) + runOn(third) { + cluster.leave(second) + } + enterBarrier("second-left") - // 2. Verify that 'second' node is set to EXITING - awaitCond(cluster.latestGossip.members.exists(_.status == MemberStatus.Exiting)) // wait on EXITING - val hasExited = cluster.latestGossip.members.find(_.status == MemberStatus.Exiting) // verify node that exited - hasExited must be('defined) - hasExited.get.address must be(address(second)) + // Verify that 'second' node is set to LEAVING + leavingLatch.await + + // Verify that 'second' node is set to EXITING + exitingLatch.await + + } + + // node that is leaving + runOn(second) { + enterBarrier("registered-listener") + enterBarrier("second-left") } enterBarrier("finished") From 18f113de68bef9ea018eff68e2a8a8065b189d72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Antonsson?= Date: Tue, 3 Jul 2012 11:19:40 +0200 Subject: [PATCH 03/11] Stop SBT from buffering test output to ease bug hunting on Jenkins --- project/AkkaBuild.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/project/AkkaBuild.scala b/project/AkkaBuild.scala index 7b83364ed0..e3d70fdee4 100644 --- a/project/AkkaBuild.scala +++ b/project/AkkaBuild.scala @@ -386,6 +386,7 @@ object AkkaBuild extends Build { ivyLoggingLevel in ThisBuild := UpdateLogging.Quiet, parallelExecution in Test := System.getProperty("akka.parallelExecution", "false").toBoolean, + logBuffered in Test := System.getProperty("akka.logBufferedTests", "false").toBoolean, excludeTestNames := useExcludeTestNames, excludeTestTags := useExcludeTestTags, From 962e4a963843932420f2e20ea458b0b08d92d53a Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 3 Jul 2012 11:28:24 +0200 Subject: [PATCH 04/11] Document how to boot up an Akka/play-mini application, see #2272 --- akka-docs/modules/http.rst | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/akka-docs/modules/http.rst b/akka-docs/modules/http.rst index b0f54948d3..9a5f1f3a47 100644 --- a/akka-docs/modules/http.rst +++ b/akka-docs/modules/http.rst @@ -12,11 +12,19 @@ service applications that integrates with Akka. It provides a REST API on top of Getting started --------------- -First you must make your application aware of play-mini. -In SBT you just have to add the following to your ``libraryDependencies``:: +Easiest way to get started with `Play2 Mini `_ is to use the +G8 project templates, as described in the `Play2 Mini Documentation `_. + +If you already have an Akka project and want to add Play2 Mini, you must first add the following to +your ``libraryDependencies``:: libraryDependencies += "com.typesafe" %% "play-mini" % "" +In case you need to start Play2 Mini programatically you can use:: + + play.core.server.NettyServer.main(Array()) + + Akka Mist ========= From b5eea69ebb2bc8fae310b8959584141a3c1e3b24 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Tue, 3 Jul 2012 11:43:59 +0200 Subject: [PATCH 05/11] Fixing OSGi tests by making them serially executed. --- .../akka/osgi/aries/blueprint/NamespaceHandlerTest.scala | 1 - akka-osgi/src/test/scala/akka/osgi/PojoSRTestSupport.scala | 6 +++--- project/AkkaBuild.scala | 6 ++++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/akka-osgi-aries/src/test/scala/akka/osgi/aries/blueprint/NamespaceHandlerTest.scala b/akka-osgi-aries/src/test/scala/akka/osgi/aries/blueprint/NamespaceHandlerTest.scala index 3bc32c6141..cfe9ce2e94 100644 --- a/akka-osgi-aries/src/test/scala/akka/osgi/aries/blueprint/NamespaceHandlerTest.scala +++ b/akka-osgi-aries/src/test/scala/akka/osgi/aries/blueprint/NamespaceHandlerTest.scala @@ -63,7 +63,6 @@ class ConfigNamespaceHandlerTest extends WordSpec with MustMatchers with PojoSRT "set up ActorSystem when bundle starts" in { val system = serviceForType[ActorSystem] system must not be (null) - system.settings.config.getString("some.config.key") must be("value") } diff --git a/akka-osgi/src/test/scala/akka/osgi/PojoSRTestSupport.scala b/akka-osgi/src/test/scala/akka/osgi/PojoSRTestSupport.scala index b19a90bf21..df96601d79 100644 --- a/akka-osgi/src/test/scala/akka/osgi/PojoSRTestSupport.scala +++ b/akka-osgi/src/test/scala/akka/osgi/PojoSRTestSupport.scala @@ -11,8 +11,8 @@ import java.net.URL import java.util.jar.JarInputStream import java.io.{ FileInputStream, FileOutputStream, File } -import java.util.{ Date, ServiceLoader, HashMap } import org.scalatest.{ BeforeAndAfterAll, Suite } +import java.util.{ UUID, Date, ServiceLoader, HashMap } /** * Trait that provides support for building akka-osgi tests using PojoSR @@ -26,11 +26,11 @@ trait PojoSRTestSupport extends Suite with BeforeAndAfterAll { * All bundles being found on the test classpath are automatically installed and started in the PojoSR runtime. * Implement this to define the extra bundles that should be available for testing. */ - val testBundles: Seq[BundleDescriptor] + def testBundles: Seq[BundleDescriptor] lazy val context: BundleContext = { val config = new HashMap[String, AnyRef]() - System.setProperty("org.osgi.framework.storage", "target/akka-osgi/" + System.currentTimeMillis) + System.setProperty("org.osgi.framework.storage", "target/akka-osgi/" + UUID.randomUUID().toString) val bundles = new ClasspathScanner().scanForBundles() bundles.addAll(testBundles) diff --git a/project/AkkaBuild.scala b/project/AkkaBuild.scala index 7b83364ed0..73546ca85f 100644 --- a/project/AkkaBuild.scala +++ b/project/AkkaBuild.scala @@ -222,7 +222,8 @@ object AkkaBuild extends Build { base = file("akka-osgi"), dependencies = Seq(actor), settings = defaultSettings ++ OSGi.osgi ++ Seq( - libraryDependencies ++= Dependencies.osgi + libraryDependencies ++= Dependencies.osgi, + parallelExecution in Test := false ) ) @@ -231,7 +232,8 @@ object AkkaBuild extends Build { base = file("akka-osgi-aries"), dependencies = Seq(osgi % "compile;test->test"), settings = defaultSettings ++ OSGi.osgiAries ++ Seq( - libraryDependencies ++= Dependencies.osgiAries + libraryDependencies ++= Dependencies.osgiAries, + parallelExecution in Test := false ) ) From 0c38dac2ea55081bf6359abf3d639ed42108c754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Antonsson?= Date: Tue, 3 Jul 2012 16:10:42 +0200 Subject: [PATCH 06/11] Doc typo change and clarification --- akka-docs/java/code/docs/actor/UntypedActorDocTestBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/akka-docs/java/code/docs/actor/UntypedActorDocTestBase.java b/akka-docs/java/code/docs/actor/UntypedActorDocTestBase.java index c82ce30661..1d4982b3f3 100644 --- a/akka-docs/java/code/docs/actor/UntypedActorDocTestBase.java +++ b/akka-docs/java/code/docs/actor/UntypedActorDocTestBase.java @@ -235,7 +235,7 @@ public class UntypedActorDocTestBase { final ArrayList> futures = new ArrayList>(); futures.add(ask(actorA, "request", 1000)); // using 1000ms timeout - futures.add(ask(actorB, "reqeest", t)); // using timeout from above + futures.add(ask(actorB, "another request", t)); // using timeout from above final Future> aggregate = Futures.sequence(futures, system.dispatcher()); From 63d6ac2a7ee5537fee8d8689fd60c74708a0a971 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 3 Jul 2012 16:36:11 +0200 Subject: [PATCH 07/11] Change auto-down default to off, see #2304 --- akka-cluster/src/main/resources/reference.conf | 2 +- .../src/test/scala/akka/cluster/ClusterConfigSpec.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/akka-cluster/src/main/resources/reference.conf b/akka-cluster/src/main/resources/reference.conf index b60b91ec43..706064d42c 100644 --- a/akka-cluster/src/main/resources/reference.conf +++ b/akka-cluster/src/main/resources/reference.conf @@ -25,7 +25,7 @@ akka { # Should the 'leader' in the cluster be allowed to automatically mark unreachable nodes as DOWN? # Using auto-down implies that two separate clusters will automatically be formed in case of # network partition. - auto-down = on + auto-down = off # the number of gossip daemon actors nr-of-gossip-daemons = 4 diff --git a/akka-cluster/src/test/scala/akka/cluster/ClusterConfigSpec.scala b/akka-cluster/src/test/scala/akka/cluster/ClusterConfigSpec.scala index 07671c6164..9c52a29773 100644 --- a/akka-cluster/src/test/scala/akka/cluster/ClusterConfigSpec.scala +++ b/akka-cluster/src/test/scala/akka/cluster/ClusterConfigSpec.scala @@ -31,7 +31,7 @@ class ClusterConfigSpec extends AkkaSpec { JoinTimeout must be(60 seconds) NrOfGossipDaemons must be(4) AutoJoin must be(true) - AutoDown must be(true) + AutoDown must be(false) GossipDifferentViewProbability must be(0.8 plusOrMinus 0.0001) SchedulerTickDuration must be(33 millis) SchedulerTicksPerWheel must be(512) From d4f759646ca4355590cbfd63aa5e2ff4b8148268 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Tue, 3 Jul 2012 21:26:05 +0200 Subject: [PATCH 08/11] Prolonging the timeouts for the ProducerRegistryTest --- .../src/test/scala/akka/camel/ProducerRegistryTest.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/akka-camel/src/test/scala/akka/camel/ProducerRegistryTest.scala b/akka-camel/src/test/scala/akka/camel/ProducerRegistryTest.scala index 8355906c80..876e0cc47a 100644 --- a/akka-camel/src/test/scala/akka/camel/ProducerRegistryTest.scala +++ b/akka-camel/src/test/scala/akka/camel/ProducerRegistryTest.scala @@ -19,10 +19,10 @@ class ProducerRegistryTest extends WordSpec with MustMatchers with SharedCamelSy "register a started SendProcessor for the producer, which is stopped when the actor is stopped" in { val actorRef = newEmptyActor val processor = registerProcessorFor(actorRef) - camel.awaitActivation(actorRef, 1 second) + camel.awaitActivation(actorRef, 5 second) processor.isStarted must be(true) system.stop(actorRef) - camel.awaitDeactivation(actorRef, 1 second) + camel.awaitDeactivation(actorRef, 5 second) (processor.isStopping || processor.isStopped) must be(true) } "remove and stop the SendProcessor if the actorRef is registered" in { From 602c83f451929d76307155210c2a5ac1a8dc5d7d Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Tue, 3 Jul 2012 23:12:35 +0200 Subject: [PATCH 09/11] Changing implementation of AgentSpec not to do Thread.sleep --- .../src/test/scala/akka/agent/AgentSpec.scala | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/akka-agent/src/test/scala/akka/agent/AgentSpec.scala b/akka-agent/src/test/scala/akka/agent/AgentSpec.scala index 0e20d6c866..beff8b896f 100644 --- a/akka-agent/src/test/scala/akka/agent/AgentSpec.scala +++ b/akka-agent/src/test/scala/akka/agent/AgentSpec.scala @@ -1,12 +1,11 @@ package akka.agent -import akka.dispatch.Await -import akka.util.Duration +import akka.dispatch.{ Await, Future } +import akka.util.{ Duration, Timeout } import akka.util.duration._ -import akka.util.Timeout import akka.testkit._ import scala.concurrent.stm._ -import java.util.concurrent.CountDownLatch +import java.util.concurrent.{ CountDownLatch, TimeUnit } class CountDownFunction[A](num: Int = 1) extends Function1[A, A] { val latch = new CountDownLatch(num) @@ -36,14 +35,16 @@ class AgentSpec extends AkkaSpec { "maintain order between send and sendOff" in { val countDown = new CountDownFunction[String] + val l1, l2 = new CountDownLatch(1) val agent = Agent("a") agent send (_ + "b") - val longRunning = (s: String) ⇒ { Thread.sleep(2000); s + "c" } + val longRunning = (s: String) ⇒ { l1.countDown; l2.await(5, TimeUnit.SECONDS); s + "c" } agent sendOff longRunning agent send (_ + "d") agent send countDown - + l1.await(5, TimeUnit.SECONDS) + l2.countDown countDown.await(5 seconds) agent() must be("abcd") @@ -51,16 +52,17 @@ class AgentSpec extends AkkaSpec { } "maintain order between alter and alterOff" in { - + val l1, l2 = new CountDownLatch(1) val agent = Agent("a") val r1 = agent.alter(_ + "b")(5000) - val r2 = agent.alterOff((s: String) ⇒ { Thread.sleep(2000); s + "c" })(5000) + val r2 = agent.alterOff((s: String) ⇒ { l1.countDown; l2.await(5, TimeUnit.SECONDS); s + "c" })(5000) val r3 = agent.alter(_ + "d")(5000) + val result = Future.sequence(Seq(r1, r2, r3)).map(_.mkString(":")) + l1.await(5, TimeUnit.SECONDS) + l2.countDown - Await.result(r1, 5 seconds) must be === "ab" - Await.result(r2, 5 seconds) must be === "abc" - Await.result(r3, 5 seconds) must be === "abcd" + Await.result(result, 5 seconds) must be === "ab:abc:abcd" agent() must be("abcd") From 062fe0fe9a865ce0514d5131610677bc55f98b4f Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Tue, 3 Jul 2012 23:16:37 +0200 Subject: [PATCH 10/11] Aligning the latches in the AgentSpec optimially for the test cases --- akka-agent/src/test/scala/akka/agent/AgentSpec.scala | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/akka-agent/src/test/scala/akka/agent/AgentSpec.scala b/akka-agent/src/test/scala/akka/agent/AgentSpec.scala index beff8b896f..eb33dd2e23 100644 --- a/akka-agent/src/test/scala/akka/agent/AgentSpec.scala +++ b/akka-agent/src/test/scala/akka/agent/AgentSpec.scala @@ -39,11 +39,10 @@ class AgentSpec extends AkkaSpec { val agent = Agent("a") agent send (_ + "b") - val longRunning = (s: String) ⇒ { l1.countDown; l2.await(5, TimeUnit.SECONDS); s + "c" } - agent sendOff longRunning + agent.sendOff((s: String) ⇒ { l1.countDown; l2.await(5, TimeUnit.SECONDS); s + "c" }) + l1.await(5, TimeUnit.SECONDS) agent send (_ + "d") agent send countDown - l1.await(5, TimeUnit.SECONDS) l2.countDown countDown.await(5 seconds) agent() must be("abcd") @@ -57,9 +56,9 @@ class AgentSpec extends AkkaSpec { val r1 = agent.alter(_ + "b")(5000) val r2 = agent.alterOff((s: String) ⇒ { l1.countDown; l2.await(5, TimeUnit.SECONDS); s + "c" })(5000) + l1.await(5, TimeUnit.SECONDS) val r3 = agent.alter(_ + "d")(5000) val result = Future.sequence(Seq(r1, r2, r3)).map(_.mkString(":")) - l1.await(5, TimeUnit.SECONDS) l2.countDown Await.result(result, 5 seconds) must be === "ab:abc:abcd" From 52e1881ece53b6df8420f7fcebbcea9a49d6f7dc Mon Sep 17 00:00:00 2001 From: Roland Date: Wed, 4 Jul 2012 11:30:02 +0200 Subject: [PATCH 11/11] move 'repl' script into AkkaBuild as initialCommands, thanks Pete! --- project/AkkaBuild.scala | 15 +++++++++++++++ repl | 22 ---------------------- 2 files changed, 15 insertions(+), 22 deletions(-) delete mode 100644 repl diff --git a/project/AkkaBuild.scala b/project/AkkaBuild.scala index d62ed11b29..244073b013 100644 --- a/project/AkkaBuild.scala +++ b/project/AkkaBuild.scala @@ -36,6 +36,20 @@ object AkkaBuild extends Build { Publish.defaultPublishTo in ThisBuild <<= crossTarget / "repository", Unidoc.unidocExclude := Seq(samples.id, tutorials.id), Dist.distExclude := Seq(actorTests.id, akkaSbtPlugin.id, docs.id), + initialCommands in ThisBuild := + """|import akka.actor._ + |import akka.dispatch._ + |import com.typesafe.config.ConfigFactory + |import akka.util.duration._ + |import akka.util.Timeout + |val config = ConfigFactory.parseString("akka.daemonic=on") + |val remoteConfig = ConfigFactory.parseString("akka.remote.netty{port=0,use-dispatcher-for-io=akka.actor.default-dispatcher,execution-pool-size=0},akka.actor.provider=RemoteActorRefProvider").withFallback(config) + |var system: ActorSystem = null + |def startSystem(remoting: Boolean = false) { system = ActorSystem("repl", if(remoting) remoteConfig else config) } + |implicit def ec = system.dispatcher + |implicit val timeout = Timeout(5 seconds) + |""".stripMargin, + initialCommands in Test in ThisBuild += "import akka.testkit._", // online version of docs sphinxDocs <<= baseDirectory / "akka-docs", sphinxTags in sphinxHtml += "online", @@ -68,6 +82,7 @@ object AkkaBuild extends Build { dependencies = Seq(actor), settings = defaultSettings ++ Seq( libraryDependencies ++= Dependencies.testkit, + initialCommands += "import akka.testkit._", previousArtifact := akkaPreviousArtifact("akka-testkit") ) ) diff --git a/repl b/repl deleted file mode 100644 index cbdfeb2662..0000000000 --- a/repl +++ /dev/null @@ -1,22 +0,0 @@ -import akka.actor._ -import akka.dispatch.{ Future, Promise } -import com.typesafe.config.ConfigFactory -import akka.testkit._ -val remoteConfig = try { - Class.forName("akka.remote.RemoteActorRefProvider") - "\nakka.actor.provider=akka.remote.RemoteActorRefProvider" - } catch { - case _: ClassNotFoundException => "" - } -val config=ConfigFactory.parseString(""" - akka.daemonic=on - akka.remote.netty { - use-dispatcher-for-io = akka.actor.default-dispatcher - execution-pool-size = 0 - } -""" + remoteConfig) -val sys=ActorSystem("repl", config.withFallback(ConfigFactory.load())).asInstanceOf[ExtendedActorSystem] -implicit val ec=sys.dispatcher -import akka.util.duration._ -import akka.util.Timeout -implicit val timeout=Timeout(5 seconds)