This is an automated email from the ASF dual-hosted git repository.

pjfanning pushed a commit to branch main
in repository 
https://gitbox.apache.org/repos/asf/pekko-persistence-cassandra.git


The following commit(s) were added to refs/heads/main by this push:
     new 20bf967  Terminate the ActorSystems that specs leave running (#495)
20bf967 is described below

commit 20bf9675444c58369ec23825a7edd4e4322a6bc7
Author: PJ Fanning <[email protected]>
AuthorDate: Sun Sep 6 22:05:13 2026 +0100

    Terminate the ActorSystems that specs leave running (#495)
    
    Motivation:
    PubSubThrottlerSpec and ReconnectSpec create an ActorSystem and never 
terminate
    it, so it lives for the rest of the test JVM run. ReconnectSpec is the 
worse of
    the two, its driver is configured to keep reconnecting, so its threads 
carry on
    after the suite. AbstractEventsByTagMigrationSpec shuts down systemTwo and
    systemThree but not migrationSystem.
    
    Modification:
    Shut the ActorSystem down in afterAll in all three specs. 
PubSubThrottlerSpec
    verifies the shutdown, ReconnectSpec does not because its driver is left
    reconnecting to a Cassandra that has been stopped.
    
    Result:
    The suites release their ActorSystems instead of leaving them running for 
the
    rest of the test JVM.
    
    Tests:
    - sbt "core/Test/testOnly 
org.apache.pekko.persistence.cassandra.journal.PubSubThrottlerSpec" - passed, 
including the verified shutdown
    - sbt "core/Test/compile" - passed
    - scalafmt --mode diff-ref=upstream/main --list - no changes needed
    - ReconnectSpec and EventsByTagMigrationSpec not run - need 
Cassandra/docker, not available locally
    
    References:
    None - resource leak found while auditing actor and session lifecycles
---
 .../pekko/persistence/cassandra/EventsByTagMigrationSpec.scala |  1 +
 .../org/apache/pekko/persistence/cassandra/ReconnectSpec.scala | 10 +++++++++-
 .../persistence/cassandra/journal/PubSubThrottlerSpec.scala    | 10 +++++++++-
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git 
a/core/src/test/scala/org/apache/pekko/persistence/cassandra/EventsByTagMigrationSpec.scala
 
b/core/src/test/scala/org/apache/pekko/persistence/cassandra/EventsByTagMigrationSpec.scala
index fbbca56..494f21e 100644
--- 
a/core/src/test/scala/org/apache/pekko/persistence/cassandra/EventsByTagMigrationSpec.scala
+++ 
b/core/src/test/scala/org/apache/pekko/persistence/cassandra/EventsByTagMigrationSpec.scala
@@ -427,6 +427,7 @@ abstract class AbstractEventsByTagMigrationSpec
         e.printStackTrace()
     }
     super.afterAll()
+    shutdown(migrationSystem)
     shutdown(systemTwo)
     shutdown(systemThree)
   }
diff --git 
a/core/src/test/scala/org/apache/pekko/persistence/cassandra/ReconnectSpec.scala
 
b/core/src/test/scala/org/apache/pekko/persistence/cassandra/ReconnectSpec.scala
index ce84df4..c4ccc95 100644
--- 
a/core/src/test/scala/org/apache/pekko/persistence/cassandra/ReconnectSpec.scala
+++ 
b/core/src/test/scala/org/apache/pekko/persistence/cassandra/ReconnectSpec.scala
@@ -18,6 +18,7 @@ import pekko.actor.{ ActorSystem, Props }
 import pekko.persistence.cassandra.CassandraLifecycle.AwaitPersistenceInit
 import pekko.testkit.{ ImplicitSender, SocketUtil, TestKit }
 import com.typesafe.config.ConfigFactory
+import org.scalatest.BeforeAndAfterAll
 import org.scalatest.Suite
 import org.scalatest.concurrent.ScalaFutures
 import org.scalatest.matchers.should.Matchers
@@ -43,7 +44,14 @@ class ReconnectSpec
     with ImplicitSender
     with AnyWordSpecLike
     with Matchers
-    with ScalaFutures {
+    with ScalaFutures
+    with BeforeAndAfterAll {
+
+  override protected def afterAll(): Unit = {
+    // not verifying the shutdown, the driver is left reconnecting to a 
Cassandra that is gone
+    shutdown(system)
+    super.afterAll()
+  }
 
   "Reconnecting" must {
     "start with system off" in {
diff --git 
a/core/src/test/scala/org/apache/pekko/persistence/cassandra/journal/PubSubThrottlerSpec.scala
 
b/core/src/test/scala/org/apache/pekko/persistence/cassandra/journal/PubSubThrottlerSpec.scala
index 5caa028..dbc98ec 100644
--- 
a/core/src/test/scala/org/apache/pekko/persistence/cassandra/journal/PubSubThrottlerSpec.scala
+++ 
b/core/src/test/scala/org/apache/pekko/persistence/cassandra/journal/PubSubThrottlerSpec.scala
@@ -15,6 +15,7 @@ package org.apache.pekko.persistence.cassandra.journal
 
 import scala.concurrent.duration.DurationInt
 
+import org.scalatest.BeforeAndAfterAll
 import org.scalatest.wordspec.AnyWordSpecLike
 import org.scalatest.matchers.should.Matchers
 
@@ -25,7 +26,14 @@ import pekko.testkit.{ TestKit, TestProbe }
 class PubSubThrottlerSpec
     extends TestKit(ActorSystem("CassandraConfigCheckerSpec"))
     with AnyWordSpecLike
-    with Matchers {
+    with Matchers
+    with BeforeAndAfterAll {
+
+  override protected def afterAll(): Unit = {
+    shutdown(system, verifySystemShutdown = true)
+    super.afterAll()
+  }
+
   "PubSubThrottler" should {
     "eat up duplicate messages that arrive within the same [interval] window" 
in {
       val delegate = TestProbe()


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to