Re: [akka-user] Testing PersistentActor, receiveCommand is never called (Akka 2.3.4)
Am Sonntag, 20. Juli 2014 16:14:53 UTC+2 schrieb Konrad Malawski: By the way, we are thinking of offering a TestKit for akka-persistence. I think it would be a neat addition (would make prepping journal state before your tests easier) but we have not discussed it in detail yet, let me know if you have a wish list for that kind of utility so we’ll keep them in mind :-) +1 I think that would be a great addition! best Carsten -- Read the docs: http://akka.io/docs/ Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups Akka User List group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
Re: [akka-user] Testing PersistentActor, receiveCommand is never called (Akka 2.3.4)
Ticket about testkit created: https://github.com/akka/akka/issues/15571 Feel free to share need's and nice-to-have's there. On Mon, Jul 21, 2014 at 9:50 AM, Carsten Saathoff cars...@kodemaniak.de wrote: Am Sonntag, 20. Juli 2014 16:14:53 UTC+2 schrieb Konrad Malawski: By the way, we are thinking of offering a TestKit for akka-persistence. I think it would be a neat addition (would make prepping journal state before your tests easier) but we have not discussed it in detail yet, let me know if you have a wish list for that kind of utility so we’ll keep them in mind :-) +1 I think that would be a great addition! best Carsten -- Read the docs: http://akka.io/docs/ Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups Akka User List group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout. -- Cheers, Konrad 'ktoso' Malawski hAkker @ Typesafe http://typesafe.com -- Read the docs: http://akka.io/docs/ Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups Akka User List group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
[akka-user] Testing PersistentActor, receiveCommand is never called (Akka 2.3.4)
Hi, I'm trying to test a persistent actor class ServerManager extends PersistentActor { override def persistenceId = ServerManager override def receiveRecover: Receive = { case _ = } override def receiveCommand: Receive = { case Commands.Server.Watch(address) = persist(Events.Server.WatchCreated(address)) { event = context.actorOf(Props(classOf[ServerMonitor], event.address), event.address) } case Commands.Server.Unwatch(address) = for(child - context.child(address)) context.stop(child) } } My test class looks like this : class ServerManagerTest(_system: ActorSystem) extends TestKit(_system) with ImplicitSender with WordSpecLike with Matchers with BeforeAndAfterAll { def this() = this( ActorSystem(TestActorSystem, ConfigFactory.parseString( |akka.loglevel = DEBUG |akka.persistence.journal.plugin = in-memory-journal |akka.actor.debug { | receive = on | autoreceive = on | lifecycle = on |} .stripMargin)) ) override def afterAll() { TestKit.shutdownActorSystem(system) } trait ServerManagerFixture { val actorRef = TestActorRef[ServerManager] } A ServerManager when { val address = 192.168.1.1 val cmd = Commands.Server.Watch(address) sreceived '$cmd' should { shave one child named '$address' in new ServerManagerFixture { actorRef ! cmd assert(actorRef.underlyingActor.context.children.size === 1) assert(actorRef.underlyingActor.context.child(address).isDefined) } } } } I put break point on receiveCommand and running test, but it's never called. I've checked https://github.com/akka/akka/blob/master/akka-persistence/src/test/scala/akka/persistence/PersistentActorSpec.scala ; but I can't find what i'm missing. If anyone can help : Thanks. -- Read the docs: http://akka.io/docs/ Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups Akka User List group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
Re: [akka-user] Testing PersistentActor, receiveCommand is never called (Akka 2.3.4)
Ho, OK. Maybe this should be explicitly added to documentation ? Thanks for the answer. Le dimanche 20 juillet 2014 15:46:02 UTC+2, Konrad Malawski a écrit : Hi Yann, TestActorRef is not compatible with Akka persistence. We discussed this in this issue here: https://github.com/akka/akka/issues/15293 Please use traditional testing style with persistence (as in expect messages etc). -- Konrad 'ktoso' Malawski (Sent from my phone) On 20 Jul 2014 15:23, Yann Le Moigne yann.l...@gmail.com javascript: wrote: Hi, I'm trying to test a persistent actor class ServerManager extends PersistentActor { override def persistenceId = ServerManager override def receiveRecover: Receive = { case _ = } override def receiveCommand: Receive = { case Commands.Server.Watch(address) = persist(Events.Server.WatchCreated(address)) { event = context.actorOf(Props(classOf[ServerMonitor], event.address), event.address) } case Commands.Server.Unwatch(address) = for(child - context.child(address)) context.stop(child) } } My test class looks like this : class ServerManagerTest(_system: ActorSystem) extends TestKit(_system) with ImplicitSender with WordSpecLike with Matchers with BeforeAndAfterAll { def this() = this( ActorSystem(TestActorSystem, ConfigFactory.parseString( |akka.loglevel = DEBUG |akka.persistence.journal.plugin = in-memory-journal |akka.actor.debug { | receive = on | autoreceive = on | lifecycle = on |} .stripMargin)) ) override def afterAll() { TestKit.shutdownActorSystem(system) } trait ServerManagerFixture { val actorRef = TestActorRef[ServerManager] } A ServerManager when { val address = 192.168.1.1 val cmd = Commands.Server.Watch(address) sreceived '$cmd' should { shave one child named '$address' in new ServerManagerFixture { actorRef ! cmd assert(actorRef.underlyingActor.context.children.size === 1) assert(actorRef.underlyingActor.context.child(address).isDefined) } } } } I put break point on receiveCommand and running test, but it's never called. I've checked https://github.com/akka/akka/blob/master/akka-persistence/src/test/scala/akka/persistence/PersistentActorSpec.scala ; but I can't find what i'm missing. If anyone can help : Thanks. -- Read the docs: http://akka.io/docs/ Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups Akka User List group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com javascript:. To post to this group, send email to akka...@googlegroups.com javascript:. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout. -- Read the docs: http://akka.io/docs/ Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups Akka User List group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
Re: [akka-user] Testing PersistentActor, receiveCommand is never called (Akka 2.3.4)
Yes, I agree this should be mentioned explicitly - I have created this issue to track this: https://github.com/akka/akka/issues/15569 By the way, we are thinking of offering a TestKit for akka-persistence. I think it would be a neat addition (would make prepping journal state before your tests easier) but we have not discussed it in detail yet, let me know if you have a wish list for that kind of utility so we’ll keep them in mind :-) -- Konrad 'ktoso' Malawski hAkker @ typesafe http://akka.io -- Read the docs: http://akka.io/docs/ Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups Akka User List group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
Re: [akka-user] Testing PersistentActor, receiveCommand is never called (Akka 2.3.4)
My pleasure! Feel free to ask any follow up questions :-) Happy hakking! On Sun, Jul 20, 2014 at 7:42 PM, Yann Le Moigne yann.lemoi...@gmail.com wrote: Hi Konrad Yes it help ! Thank you. For my first incursion in akka community, you was very helpfull and reactive. Thanks :) Le dimanche 20 juillet 2014 18:42:12 UTC+2, Konrad Malawski a écrit : Without modifying the tested actor you could test (1) by sending an Idenfity message to the selection (testedGuy/*), and then expect exactly one ActorIdentity as response (expect it, and then expectNoMsg). I hope this helps! On Sun, Jul 20, 2014 at 4:31 PM, Yann Le Moigne yann.l...@gmail.com wrote: I'm beginning, so nu much insight to make a whish at this time ; but of course, managed test journal lifecycle by specialized TestKit sound great. I'm trying to switch to standard testing style, but I can't find a way to replace : 1: assert(actorRef.underlyingActor.context.children.size === 1) 2: assert(actorRef.underlyingActor.context.child(address).isDefined) For the (2), using system.actorSelection(...).resolveOne(...) can help but I struggle to check (1) Le dimanche 20 juillet 2014 16:14:53 UTC+2, Konrad Malawski a écrit : Yes, I agree this should be mentioned explicitly - I have created this issue to track this: https://github.com/akka/akka/issues/15569 By the way, we are thinking of offering a TestKit for akka-persistence. I think it would be a neat addition (would make prepping journal state before your tests easier) but we have not discussed it in detail yet, let me know if you have a wish list for that kind of utility so we’ll keep them in mind :-) -- Konrad 'ktoso' Malawski hAkker @ typesafe http://akka.io -- Read the docs: http://akka.io/docs/ Check the FAQ: http://doc.akka.io/docs/akka/ current/additional/faq.html Search the archives: https://groups.google.com/ group/akka-user --- You received this message because you are subscribed to the Google Groups Akka User List group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com. To post to this group, send email to akka...@googlegroups.com. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout. -- Cheers, Konrad 'ktoso' Malawski hAkker @ Typesafe http://typesafe.com -- Read the docs: http://akka.io/docs/ Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups Akka User List group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout. -- Cheers, Konrad 'ktoso' Malawski hAkker @ Typesafe http://typesafe.com -- Read the docs: http://akka.io/docs/ Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups Akka User List group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.