def setUp(self): self.domain = Domain("test-domain") self.activity_type = ActivityType( self.domain, "test-name", "test-version" )
def test_dispatch_is_catched_correctly(self): domain = Domain("test-domain") poller = ActivityPoller(domain, "task-list") # this activity does not exist, so it will provoke an # ImportError when dispatching activity_type = FakeActivityType("activity.does.not.exist") task = ActivityTask(domain, "task-list", activity_type=activity_type) worker = ActivityWorker() with patch.object(poller, "fail_with_retry") as mock: worker.process(poller, "token", task) self.assertEquals(1, mock.call_count) self.assertEquals(mock.call_args[0], ("token", task)) self.assertIn("No module named ", mock.call_args[1]["reason"])
def test_sigterm_handling(self): """ Tests that SIGTERM is correctly ignored by the poller. """ poller = FakePoller(Domain("test-domain"), "test-task-list") # restore default signal handling for SIGTERM: signal binding HAS to be # done at execution time, not in the Poller() initialization, because in # the real world that step is performed at the Supervisor() level, not in # the worker subprocess. signal.signal(signal.SIGTERM, signal.SIG_DFL) process = multiprocessing.Process(target=poller.start) process.start() time.sleep(0.5) os.kill(process.pid, signal.SIGTERM) time.sleep(0.5) # now test that we're still in the second sleep, and that we're not # in "zombie" mode yet (which would be the case if SIGTERM had its # default effect) expect(Process(process.pid).status()).to.contain("sleeping")
def setUp(self): self.domain = Domain("TestDomain") self.actor = Actor(self.domain, "test-task-list")
def build_history(self, workflow_input): domain = Domain("TestDomain") self.executor = Executor(domain, self.WORKFLOW) self.history = builder.History(self.WORKFLOW, input=workflow_input)