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