3 from __future__ import absolute_import, print_function
14 from . import testutil
16 import arvnodeman.baseactor
18 class BogusActor(arvnodeman.baseactor.BaseNodeManagerActor):
19 def __init__(self, e):
20 super(BogusActor, self).__init__()
29 class ActorUnhandledExceptionTest(unittest.TestCase):
30 def test_fatal_error(self):
31 for e in (MemoryError(), threading.ThreadError(), OSError(errno.ENOMEM, "")):
32 with mock.patch('os.kill') as kill_mock:
33 act = BogusActor.start(e).tell_proxy()
35 act.actor_ref.stop(block=True)
36 self.assertTrue(kill_mock.called)
38 @mock.patch('os.kill')
39 def test_nonfatal_error(self, kill_mock):
40 act = BogusActor.start(OSError(errno.ENOENT, "")).tell_proxy()
42 act.actor_ref.stop(block=True)
43 self.assertFalse(kill_mock.called)
45 class WatchdogActorTest(unittest.TestCase):
46 @mock.patch('os.kill')
47 def test_time_timout(self, kill_mock):
48 act = BogusActor.start(OSError(errno.ENOENT, ""))
49 watch = arvnodeman.baseactor.WatchdogActor.start(1)
50 watch.stop(block=True)
52 self.assertTrue(kill_mock.called)