def test_terminator_death(self): # This test will bring down the nose process, so we run it in a child # process. child_pid = os.fork() if child_pid == 0: core = Mock() store = Mock() def dies(): raise TypeError("thread dies!") core._get_nodes_by_id = MagicMock(return_value=[]) leader = ProvisionerLeader(store, core) leader.run_terminator = dies leader.initialize() store.contend_leader.assert_called_with(leader) leader_thread = tevent.spawn(leader.inaugurate) tevent.joinall([leader_thread]) else: pid, exit = os.wait() # exit is a 16-bit number, whose low byte is the signal number that # killed the process, and whose high byte is the exit status (if # the signal number is zero); the high bit of the low byte is set # if a core file was produced. # # Check that the signal number is zero and the exit code is the # expected one. self.assertEqual(exit & 0xff, 0) self.assertEqual(exit >> 8 & 0xff, os.EX_SOFTWARE)
def _shutdown_processes(self, threads): self.dtrs.stop() self.provisioner.stop() tevent.joinall(threads)
def _shutdown_processes(self, threads): self.dtrs.dashi.cancel() tevent.joinall(threads)