File size: 3,324 Bytes
75b2876
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
diff --git a/tests/actor/test_actor.py b/tests/actor/test_actor.py
index 96015e481..05a9f5f26 100644
--- a/tests/actor/test_actor.py
+++ b/tests/actor/test_actor.py
@@ -78,31 +78,6 @@ async def _run(self) -> None:
         print(f"{self} done (should not happen)")
 
 
-class RaiseBaseExceptionActor(BaseTestActor):
-    """A faulty actor that raises a BaseException as soon as it receives a message."""
-
-    def __init__(
-        self,
-        recv: Receiver[int],
-    ) -> None:
-        """Create an instance.
-
-        Args:
-            recv: A channel receiver for int data.
-        """
-        super().__init__(name="test")
-        self._recv = recv
-
-    async def _run(self) -> None:
-        """Start the actor and crash upon receiving a message."""
-        print(f"{self} started")
-        self.inc_restart_count()
-        async for _ in self._recv:
-            print(f"{self} is about to crash")
-            raise MyBaseException("This is a test")
-        print(f"{self} done (should not happen)")
-
-
 ACTOR_INFO = ("frequenz.sdk.actor._actor", 20)
 ACTOR_ERROR = ("frequenz.sdk.actor._actor", 40)
 RUN_INFO = ("frequenz.sdk.actor._run_utils", 20)
@@ -309,41 +284,6 @@ async def test_does_not_restart_on_normal_exit(
     ]
 
 
-async def test_does_not_restart_on_base_exception(
-    actor_auto_restart_once: None,  # pylint: disable=unused-argument
-    caplog: pytest.LogCaptureFixture,
-) -> None:
-    """Create a faulty actor and expect it not to restart because it raises a base exception."""
-    caplog.set_level("DEBUG", logger="frequenz.sdk.actor._actor")
-    caplog.set_level("DEBUG", logger="frequenz.sdk.actor._run_utils")
-
-    channel: Broadcast[int] = Broadcast(name="channel")
-
-    actor = RaiseBaseExceptionActor(channel.new_receiver())
-
-    async with asyncio.timeout(1.0):
-        await channel.new_sender().send(1)
-        # We can't use pytest.raises() here because known BaseExceptions are handled
-        # specially by pytest.
-        try:
-            await run(actor)
-        except MyBaseException as error:
-            assert str(error) == "This is a test"
-
-    assert BaseTestActor.restart_count == 0
-    assert caplog.record_tuples == [
-        (*RUN_INFO, "Starting 1 actor(s)..."),
-        (*RUN_INFO, "Actor RaiseBaseExceptionActor[test]: Starting..."),
-        (*ACTOR_INFO, "Actor RaiseBaseExceptionActor[test]: Started."),
-        (*ACTOR_ERROR, "Actor RaiseBaseExceptionActor[test]: Raised a BaseException."),
-        (
-            *RUN_ERROR,
-            "Actor RaiseBaseExceptionActor[test]: Raised an exception while running.",
-        ),
-        (*RUN_INFO, "All 1 actor(s) finished."),
-    ]
-
-
 async def test_does_not_restart_if_cancelled(
     actor_auto_restart_once: None,  # pylint: disable=unused-argument
     caplog: pytest.LogCaptureFixture,
@@ -390,6 +330,6 @@ async def cancel_actor() -> None:
         (*RUN_INFO, "Actor EchoActor[EchoActor]: Starting..."),
         (*ACTOR_INFO, "Actor EchoActor[EchoActor]: Started."),
         (*ACTOR_INFO, "Actor EchoActor[EchoActor]: Cancelled."),
-        (*RUN_ERROR, "Actor EchoActor[EchoActor]: Raised an exception while running."),
+        (*RUN_INFO, "Actor EchoActor[EchoActor]: Cancelled while running."),
         (*RUN_INFO, "All 1 actor(s) finished."),
     ]