Testing Akka

9 views
Skip to first unread message

Stefan

unread,
Jun 24, 2010, 12:58:30 PM6/24/10
to Akka User List
Hi, I've ported my scala actor sample to akka. Now, I've got problems
running my unit tests.

I get 2 different types of errors:
java.lang.IllegalStateException: Can't build a new thread pool for a
dispatcher that is already up and running


And the other:
java.lang.IllegalStateException: Can't build a new thread pool for a
dispatcher that is already up and running
at
se.scalablesolutions.akka.dispatch.ExecutorBasedEventDrivenDispatcher.ensureNotActive(ExecutorBasedEventDrivenDispatcher.scala:
136)
at se.scalablesolutions.akka.dispatch.ThreadPoolBuilder
$class.withNewThreadPoolWithLinkedBlockingQueueWithUnboundedCapacity(ThreadPoolBuilder.scala:
69)
at
se.scalablesolutions.akka.dispatch.ExecutorBasedEventDrivenDispatcher.withNewThreadPoolWithLinkedBlockingQueueWithUnboundedCapacity(ExecutorBasedEventDrivenDispatcher.scala:
62)
at
se.scalablesolutions.akka.dispatch.ExecutorBasedEventDrivenDispatcher.init(ExecutorBasedEventDrivenDispatcher.scala:
139)
at se.scalablesolutions.akka.dispatch.Dispatchers
$globalExecutorBasedEventDrivenDispatcher$.register(Dispatchers.scala:
47)
at se.scalablesolutions.akka.actor.LocalActorRef$$anonfun$start
$1.apply(ActorRef.scala:940)
at se.scalablesolutions.akka.actor.LocalActorRef$$anonfun$start
$1.apply(ActorRef.scala:936)
at
se.scalablesolutions.akka.util.ReentrantGuard.withGuard(LockUtil.scala:
18)
at se.scalablesolutions.akka.actor.LocalActorRef.start(ActorRef.scala:
936)
at thesis.bsps.sort.akka.RegularSamplingAkkaActors$$anonfun
$1.apply(RegularSamplingAkkaActors.scala:33)
at thesis.bsps.sort.akka.RegularSamplingAkkaActors$$anonfun
$1.apply(RegularSamplingAkkaActors.scala:33)
at scala.collection.TraversableLike$$anonfun$map
$1.apply(TraversableLike.scala:204)
at scala.collection.TraversableLike$$anonfun$map
$1.apply(TraversableLike.scala:204)
at scala.collection.IndexedSeqOptimized
$class.foreach(IndexedSeqOptimized.scala:34)
at scala.collection.mutable.ArrayOps.foreach(ArrayOps.scala:34)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:
204)
at scala.collection.mutable.ArrayOps.map(ArrayOps.scala:34)
at thesis.bsps.sort.akka.RegularSamplingAkkaActors
$.PSRSWithValidArgs(RegularSamplingAkkaActors.scala:33)
at thesis.bsps.sort.akka.RegularSamplingAkkaActors
$.PSRS(RegularSamplingAkkaActors.scala:27)
at thesis.bsps.sort.RegularSamplingAkkaActorsTest$$anonfun
$testBiggerArray$1.apply$mcVI$sp(RegularSamplingAkkaActorsTest.scala:
79)
at scala.collection.immutable.Range$ByOne$class.foreach$mVc
$sp(Range.scala:275)
at scala.collection.immutable.Range$$anon$1.foreach$mVc
$sp(Range.scala:267)
at
thesis.bsps.sort.RegularSamplingAkkaActorsTest.testBiggerArray(RegularSamplingAkkaActorsTest.scala:
76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod
$1.runReflectiveCall(FrameworkMethod.java:44)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:
15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:
41)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:
20)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:
28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:
31)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:
73)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:
46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:
28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:
31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:
46)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:
38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:
390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:
197)




Any ideas?

Jonas Bonér

unread,
Jun 24, 2010, 1:05:11 PM6/24/10
to akka...@googlegroups.com

You need to paste in the code for me to help you.

--
Jonas Bonér
http://jayway.com
http://akkasource.com
twitter: jboner


--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.

Stefan

unread,
Jun 24, 2010, 2:12:40 PM6/24/10
to Akka User List
http://paste.pocoo.org/show/229454/ //akka code
http://paste.pocoo.org/show/229455/ //common helper code
http://paste.pocoo.org/show/229456/ //test code

It's also at github: http://github.com/Stefanqn/Sbt_2.8_Akka0.9

I should mention that I've rebuild akka from git (2 days ago) to add
the debug flag -g.

btw: would be nice to have such a jar with sources and java docs as an
all in one bundle for developers.

Jonas Bonér

unread,
Jun 24, 2010, 2:51:43 PM6/24/10
to akka...@googlegroups.com
Thanks. In which Actor do you get the exception and when?

> --
> You received this message because you are subscribed to the Google Groups "Akka User List" group.
> To post to this group, send email to akka...@googlegroups.com.
> To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
>
>

--
Jonas Bonér

work: http://jayway.com
code: http://akkasource.com
blog: http://jonasboner.com
twitter: @jboner

Stefan

unread,
Jun 24, 2010, 3:11:14 PM6/24/10
to Akka User List
It's non determinitic. I think it has something to do with creating
tests,run, create other test, run ... Maybe the next test is started
before the actors get shut down properly. So just some tests fail, but
it's different which one fails.

Jonas Bonér

unread,
Jun 24, 2010, 3:20:55 PM6/24/10
to akka...@googlegroups.com
Ah. I don't know if I can do anything about that.

Stefan

unread,
Jun 24, 2010, 3:36:53 PM6/24/10
to Akka User List
Could you give an advice what I have to consider when writing tests
using akka?
I really do have a bad feeling if I can't use unit-tests.

Jonas Bonér

unread,
Jun 24, 2010, 3:41:27 PM6/24/10
to akka...@googlegroups.com
I don't know what you mean really. I have never had any problems. Look at Akka's unit tests.
--
Jonas Bonér
http://jayway.com
http://akkasource.com
twitter: jboner

"Stefan" <stef...@gmail.com> wrote:

Stefan

unread,
Jun 25, 2010, 5:57:18 AM6/25/10
to Akka User List
I did look at akkas unit tests before and couldn't find anything
special. Because of that I do not know why my tests fail sometimes.
The same unit tests work fine with scala actors, so there has to be
something I do not know when testing with akka ... any ideas?

Jonas Bonér

unread,
Jun 25, 2010, 6:16:41 AM6/25/10
to akka...@googlegroups.com

Ok. I'll make a test run in the weekend and see if I make any interesting observations.

--
Jonas Bonér
http://jayway.com
http://akkasource.com
twitter: jboner


--
You received this message because you are subscribed to the Google Groups "Akka User List" grou...

Stefan

unread,
Jun 27, 2010, 7:09:08 AM6/27/10
to Akka User List
awesome! Thanks.

Stefan

unread,
Jun 28, 2010, 9:34:43 AM6/28/10
to Akka User List
I found the problem: between returning the result and stopping self
actor the next test was started. Therefore akka's fork/join dispatcher
was still up.
This means that first return the result, then stop itself is wrong.
First stop, then return result.

Jonas Bonér

unread,
Jun 28, 2010, 10:33:44 AM6/28/10
to akka...@googlegroups.com
Ah great. Sorry I didn't have time to look at it yet.
Anything Akka could do to help you in this problem?

> --


> You received this message because you are subscribed to the Google Groups "Akka User List" group.
> To post to this group, send email to akka...@googlegroups.com.
> To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
>
>

--

Stefan

unread,
Jun 28, 2010, 5:16:44 PM6/28/10
to Akka User List
I think the following 2 things might be useful:

a) Having something like akka.shutdown(), like you have for
RemoteNode. I know that the ActorRegistry does nearly the same, but
you could ensure that no new actors would be created until
akka.start() is called. This would make it explicit and easy when you
start / stop working with akka and you would have some equivalent to
RemoteNode.start

b) calling self.stop in an actor could result in an NPE if the actor
send its result message (completed work) and all actors get shutdown
somewhere else. It is somehow confusing when self is null and the
actor is still running (finishing his method).

Jonas Bonér

unread,
Jun 28, 2010, 5:19:30 PM6/28/10
to akka...@googlegroups.com

I'll think about the first idea.
The second one is being worked on right now.

--
Jonas Bonér
http://jayway.com
http://akkasource.com
twitter: jboner


--

You received this message because you are subscribed to the Google Groups "Akka User List" group.

To...

Reply all
Reply to author
Forward
0 new messages