dilate TestKit shutdownActorSystem (#30685)
* rather many "Failed to stop [] within [10 seconds]" in CI
This commit is contained in:
parent
9c851e4a7a
commit
697f7a0e08
4 changed files with 14 additions and 16 deletions
|
|
@ -234,10 +234,7 @@ abstract class ReplicatedShardingSpec(replicationType: ReplicationType, configA:
|
|||
|
||||
override protected def afterAll(): Unit = {
|
||||
super.afterAll()
|
||||
ActorTestKit.shutdown(
|
||||
system2,
|
||||
testKitSettings.DefaultActorSystemShutdownTimeout,
|
||||
testKitSettings.ThrowOnShutdownTimeout)
|
||||
ActorTestKit.shutdown(system2)
|
||||
}
|
||||
|
||||
"Replicated sharding" should {
|
||||
|
|
@ -294,10 +291,7 @@ abstract class ReplicatedShardingSpec(replicationType: ReplicationType, configA:
|
|||
// logging to diagnose
|
||||
// https://github.com/akka/akka/issues/30501 and
|
||||
// https://github.com/akka/akka/issues/30502
|
||||
ActorTestKit.shutdown(
|
||||
system2,
|
||||
testKitSettings.DefaultActorSystemShutdownTimeout,
|
||||
testKitSettings.ThrowOnShutdownTimeout)
|
||||
ActorTestKit.shutdown(system2)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ class ClusterShardingSpec
|
|||
val sharding2 = ClusterSharding(system2)
|
||||
|
||||
override def afterAll(): Unit = {
|
||||
ActorTestKit.shutdown(system2, 5.seconds)
|
||||
ActorTestKit.shutdown(system2)
|
||||
super.afterAll()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
|
||||
package akka.cluster.typed
|
||||
|
||||
import scala.concurrent.duration._
|
||||
|
||||
import com.typesafe.config.ConfigFactory
|
||||
import org.scalatest.wordspec.AnyWordSpecLike
|
||||
|
||||
|
|
@ -103,7 +101,7 @@ class RemoteDeployNotAllowedSpec
|
|||
system2 ! SpawnAnonymous
|
||||
probe.expectMessageType[Exception].getMessage should ===("Remote deployment not allowed for typed actors")
|
||||
} finally {
|
||||
ActorTestKit.shutdown(system2, 5.seconds)
|
||||
ActorTestKit.shutdown(system2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -878,7 +878,7 @@ trait TestKitBase {
|
|||
*/
|
||||
def shutdown(
|
||||
actorSystem: ActorSystem = system,
|
||||
duration: Duration = 10.seconds.dilated.min(10.seconds),
|
||||
duration: Duration = Duration.Undefined,
|
||||
verifySystemShutdown: Boolean = false): Unit = {
|
||||
TestKit.shutdownActorSystem(actorSystem, duration, verifySystemShutdown)
|
||||
}
|
||||
|
|
@ -1015,19 +1015,25 @@ object TestKit {
|
|||
* Shut down an actor system and wait for termination.
|
||||
* On failure debug output will be logged about the remaining actors in the system.
|
||||
*
|
||||
* The `duration` is dilated by the timefactor.
|
||||
*
|
||||
* If verifySystemShutdown is true, then an exception will be thrown on failure.
|
||||
*/
|
||||
def shutdownActorSystem(
|
||||
actorSystem: ActorSystem,
|
||||
duration: Duration = 10.seconds,
|
||||
duration: Duration = Duration.Undefined,
|
||||
verifySystemShutdown: Boolean = false): Unit = {
|
||||
val d = duration match {
|
||||
case f: FiniteDuration => f.dilated(actorSystem)
|
||||
case _ => 10.seconds.dilated(actorSystem).min(10.seconds)
|
||||
}
|
||||
actorSystem.terminate()
|
||||
try Await.ready(actorSystem.whenTerminated, duration)
|
||||
try Await.ready(actorSystem.whenTerminated, d)
|
||||
catch {
|
||||
case _: TimeoutException =>
|
||||
val msg = "Failed to stop [%s] within [%s] \n%s".format(
|
||||
actorSystem.name,
|
||||
duration,
|
||||
d,
|
||||
actorSystem.asInstanceOf[ActorSystemImpl].printTree)
|
||||
if (verifySystemShutdown) throw new RuntimeException(msg)
|
||||
else println(msg)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue