Skip to content

Commit

Permalink
free actor after each test
Browse files Browse the repository at this point in the history
  • Loading branch information
wrzontek committed Jul 4, 2024
1 parent 6789f73 commit 13992c7
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ class UtilsSpec
()
}
}
val actorName = "actorName1"
val actorName = "actorName"

val actorRef = system.actorOf(Props(new TestActor), actorName)

Utils.stopActorAndWaitUntilItsNameIsFree(actorRef, system)

// with normal system.stop(actorRef) or akka.pattern.gracefulStop this throws "actor name is not unique"
system.actorOf(Props(new TestActor), actorName)
val actorRef2 = system.actorOf(Props(new TestActor), actorName)

Utils.stopActorAndWaitUntilItsNameIsFree(actorRef2, system) // stop and free it so it doesn't impact other tests
}

"stop actor and free actor path without waiting for all of it's messages to be processed" in {
Expand All @@ -43,8 +45,7 @@ class UtilsSpec
Thread.sleep(1000)
}
}
val actorName =
"actorName2" // has to be different from the previous test, because the actor created at the end of that can still live
val actorName = "actorName"

val actorRef = system.actorOf(Props(new TestActor), actorName)

Expand All @@ -58,7 +59,9 @@ class UtilsSpec
// with gracefulStop this times out, because the PoisonPill is queued after the many normal messages
Utils.stopActorAndWaitUntilItsNameIsFree(actorRef, system)

system.actorOf(Props(new TestActor), actorName)
val actorRef2 = system.actorOf(Props(new TestActor), actorName)

Check failure on line 62 in engine/flink/management/periodic/src/test/scala/pl/touk/nussknacker/engine/management/periodic/UtilsSpec.scala

View workflow job for this annotation

GitHub Actions / REPORT-BackendTests-2.13

pl.touk.nussknacker.engine.management.periodic.UtilsSpec ► Utils should stop actor and free actor path without waiting for all of it's messages to be processed

Failed test found in: engine/flink/management/periodic/target/test-reports/TEST-pl.touk.nussknacker.engine.management.periodic.UtilsSpec.xml Error: akka.actor.InvalidActorNameException: actor name [actorName] is not unique!
Raw output
akka.actor.InvalidActorNameException: actor name [actorName] is not unique!
	at akka.actor.dungeon.ChildrenContainer$TerminatingChildrenContainer.reserve(ChildrenContainer.scala:198)
	at akka.actor.dungeon.Children.reserveChild(Children.scala:146)
	at akka.actor.dungeon.Children.reserveChild$(Children.scala:144)
	at akka.actor.ActorCell.reserveChild(ActorCell.scala:410)
	at akka.actor.dungeon.Children.makeChild(Children.scala:299)
	at akka.actor.dungeon.Children.attachChild(Children.scala:52)
	at akka.actor.dungeon.Children.attachChild$(Children.scala:51)
	at akka.actor.ActorCell.attachChild(ActorCell.scala:410)
	at akka.actor.ActorSystemImpl.actorOf(ActorSystem.scala:899)
	at pl.touk.nussknacker.engine.management.periodic.UtilsSpec.$anonfun$new$5(UtilsSpec.scala:62)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
	at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85)
	at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83)
	at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
	at org.scalatest.Transformer.apply(Transformer.scala:22)
	at org.scalatest.Transformer.apply(Transformer.scala:20)
	at org.scalatest.wordspec.AnyWordSpecLike$$anon$3.apply(AnyWordSpecLike.scala:1240)
	at org.scalatest.TestSuite.withFixture(TestSuite.scala:196)
	at org.scalatest.TestSuite.withFixture$(TestSuite.scala:195)
	at pl.touk.nussknacker.engine.management.periodic.UtilsSpec.withFixture(UtilsSpec.scala:10)
	at org.scalatest.wordspec.AnyWordSpecLike.invokeWithFixture$1(AnyWordSpecLike.scala:1238)
	at org.scalatest.wordspec.AnyWordSpecLike.$anonfun$runTest$1(AnyWordSpecLike.scala:1250)
	at org.scalatest.SuperEngine.runTestImpl(Engine.scala:306)
	at org.scalatest.wordspec.AnyWordSpecLike.runTest(AnyWordSpecLike.scala:1250)
	at org.scalatest.wordspec.AnyWordSpecLike.runTest$(AnyWordSpecLike.scala:1232)
	at pl.touk.nussknacker.engine.management.periodic.UtilsSpec.runTest(UtilsSpec.scala:10)
	at org.scalatest.wordspec.AnyWordSpecLike.$anonfun$runTests$1(AnyWordSpecLike.scala:1309)
	at org.scalatest.SuperEngine.$anonfun$runTestsInBranch$1(Engine.scala:413)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:401)
	at org.scalatest.SuperEngine.runTestsInBranch(Engine.scala:390)
	at org.scalatest.SuperEngine.$anonfun$runTestsInBranch$1(Engine.scala:427)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:401)
	at org.scalatest.SuperEngine.runTestsInBranch(Engine.scala:396)
	at org.scalatest.SuperEngine.runTestsImpl(Engine.scala:475)
	at org.scalatest.wordspec.AnyWordSpecLike.runTests(AnyWordSpecLike.scala:1309)
	at org.scalatest.wordspec.AnyWordSpecLike.runTests$(AnyWordSpecLike.scala:1308)
	at pl.touk.nussknacker.engine.management.periodic.UtilsSpec.runTests(UtilsSpec.scala:10)
	at org.scalatest.Suite.run(Suite.scala:1114)
	at org.scalatest.Suite.run$(Suite.scala:1096)
	at pl.touk.nussknacker.engine.management.periodic.UtilsSpec.org$scalatest$wordspec$AnyWordSpecLike$$super$run(UtilsSpec.scala:10)
	at org.scalatest.wordspec.AnyWordSpecLike.$anonfun$run$1(AnyWordSpecLike.scala:1354)
	at org.scalatest.SuperEngine.runImpl(Engine.scala:535)
	at org.scalatest.wordspec.AnyWordSpecLike.run(AnyWordSpecLike.scala:1354)
	at org.scalatest.wordspec.AnyWordSpecLike.run$(AnyWordSpecLike.scala:1352)
	at pl.touk.nussknacker.engine.management.periodic.UtilsSpec.org$scalatest$BeforeAndAfterAll$$super$run(UtilsSpec.scala:10)
	at org.scalatest.BeforeAndAfterAll.liftedTree1$1(BeforeAndAfterAll.scala:213)
	at org.scalatest.BeforeAndAfterAll.run(BeforeAndAfterAll.scala:210)
	at org.scalatest.BeforeAndAfterAll.run$(BeforeAndAfterAll.scala:208)
	at pl.touk.nussknacker.engine.management.periodic.UtilsSpec.run(UtilsSpec.scala:10)
	at org.scalatest.tools.Framework.org$scalatest$tools$Framework$$runSuite(Framework.scala:321)
	at org.scalatest.tools.Framework$ScalaTestTask.execute(Framework.scala:517)
	at sbt.TestRunner.runTest$1(TestFramework.scala:153)
	at sbt.TestRunner.run(TestFramework.scala:168)
	at sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1.$anonfun$apply$1(TestFramework.scala:336)
	at sbt.TestFramework$.sbt$TestFramework$$withContextLoader(TestFramework.scala:296)
	at sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1.apply(TestFramework.scala:336)
	at sbt.TestFramework$$anon$3$$anonfun$$lessinit$greater$1.apply(TestFramework.scala:336)
	at sbt.TestFunction.apply(TestFramework.scala:348)
	at sbt.Tests$.processRunnable$1(Tests.scala:475)
	at sbt.Tests$.$anonfun$makeSerial$1(Tests.scala:481)
	at sbt.std.Transform$$anon$3.$anonfun$apply$2(Transform.scala:47)
	at sbt.std.Transform$$anon$4.work(Transform.scala:69)
	at sbt.Execute.$anonfun$submit$2(Execute.scala:283)
	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
	at sbt.Execute.work(Execute.scala:292)
	at sbt.Execute.$anonfun$submit$1(Execute.scala:283)
	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
	at sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

Utils.stopActorAndWaitUntilItsNameIsFree(actorRef2, system) // stop and free it so it doesn't impact other tests
}

"ignore exceptions inside runSafely block" in {
Expand Down

0 comments on commit 13992c7

Please sign in to comment.