Exemplo n.º 1
0
 def test_run_command(self):
     chaos = self._get_chaos_object(Net(), 'deny-state-server')
     with patch('utility.check_output', autospec=True) as mock:
         with patch(
                 'runner.random.choice', autospec=True, return_value=chaos):
             with temp_dir() as directory:
                 runner = Runner(directory, ChaosMonkey.factory())
                 runner._run_command(enablement_timeout=0)
     self.assertEqual(mock.mock_calls, self._deny_port_call_list())
Exemplo n.º 2
0
 def test_run_command_select_restart_unit(self):
     chaos = self._get_chaos_object(Kill(), Kill.restart_cmd)
     with patch('utility.check_output', autospec=True) as mock:
         with patch(
                 'runner.random.choice', autospec=True, return_value=chaos):
             with patch('runner.Init', autospec=True) as ri_mock:
                 with temp_dir() as directory:
                     runner = Runner(directory, ChaosMonkey.factory())
                     runner._run_command(enablement_timeout=0)
     self.assertEqual(mock.mock_calls, [call(['shutdown', '-r', 'now'])])
     ri_mock.upstart.assert_called_once_with()