def test__run_benchmark(self, mock_multi_process): scenario_cfg = { 'runner': {}, } runner = SearchRunner({}) runner._run_benchmark(mock.Mock(), 'my_method', scenario_cfg, {}) mock_multi_process.Process.assert_called_once()
def test__worker_run_immediate_stop(self): scenario_cfg = { 'runner': { 'run_step': '', }, } runner = SearchRunner({}) runner._worker_run(mock.Mock(), 'my_method', scenario_cfg, {})
def test__run_benchmark(self, mock_multi_process): cls = mock.MagicMock() scenario_cfg = { 'runner': {}, } runner = SearchRunner({}) runner._run_benchmark(cls, 'my_method', scenario_cfg, {}) self.assertEqual(mock_multi_process.Process.call_count, 1)
def test__worker_run(self): scenario_cfg = { 'runner': { 'interval': 0, 'timeout': 1 }, } runner = SearchRunner({}) runner._worker_run_once = mock.Mock(side_effect=[0, 0, 1]) runner._worker_run(mock.Mock(), 'my_method', scenario_cfg, {})
def test__worker_run_once(self): def update(*args): args[-1].update(data) data = { 'key1': { 'inner1': 'value1', 'done': 0, }, 'key2': { 'done': None, }, } runner = SearchRunner({}) runner.worker_helper = mock.Mock(side_effect=update) self.assertFalse(runner._worker_run_once('sequence 1'))
def test__worker_run_once_assertion_error_assert(self): runner = SearchRunner({}) runner.sla_action = 'assert' runner.worker_helper = mock.Mock(side_effect=y_exc.SLAValidationError) with self.assertRaises(y_exc.SLAValidationError): runner._worker_run_once('sequence 1')
def test__worker_run_once_non_assertion_error(self): runner = SearchRunner({}) runner.sla_action = 'monitor' runner.worker_helper = mock.Mock(side_effect=RuntimeError) self.assertFalse(runner._worker_run_once('sequence 1'))
def test__worker_run_once_non_assertion_error_none(self): runner = SearchRunner({}) runner.worker_helper = mock.Mock(side_effect=RuntimeError) self.assertTrue(runner._worker_run_once('sequence 1'))