def test_run_actions_single_and_multi_params(self): content = """ benchmark: plugin/0: terasort: time: 30s plugin/1: terasort2 """ test_plan = yaml.load(content) mock_client = MagicMock() with patch( 'cloud_weather_report.run_action', autospec=True, side_effect=[self.make_benchmark_data(), self.make_benchmark_data()]) as mock_cr: result = cloud_weather_report.run_actions( test_plan, mock_client, make_fake_status()) calls = [call(mock_client, 'plugin/6', 'terasort', action_param={"time": "30s"}, timeout=3600), call(mock_client, 'plugin/7', 'terasort2', action_param=None, timeout=3600)] self.assertItemsEqual(mock_cr.mock_calls, calls) self.assertEqual(result, [ {"terasort": self.make_benchmark_data()["meta"]["composite"]}, {"terasort2": self.make_benchmark_data()["meta"]["composite"]}])
def test_run_actions_benchmark_with_no_param(self): content = """ benchmark: plugin/1: terasort """ test_plan = yaml.load(content) mock_client = MagicMock() with patch('cloud_weather_report.run_action', autospec=True, return_value=self.make_benchmark_data()) as mock_cr: result = cloud_weather_report.run_actions(test_plan, mock_client, make_fake_status()) calls = [ call(mock_client, 'plugin/7', 'terasort', action_param=None, timeout=3600) ] self.assertEqual(mock_cr.mock_calls, calls) self.assertEqual( result, [{ "terasort": self.make_benchmark_data()["meta"]["composite"] }])
def test_run_actions(self): content = """ tests: - foo-test - bar-test benchmark: plugin: terasort: time: 30s concurrency: 10 """ test_plan = yaml.load(content) mock_client = MagicMock() with patch('cloud_weather_report.run_action', autospec=True, return_value=self.make_benchmark_data()) as mock_cr: result = cloud_weather_report.run_actions(test_plan, mock_client, make_fake_status()) calls = [ call(mock_client, 'plugin/6', 'terasort', action_param={ "time": "30s", "concurrency": 10 }, timeout=3600) ] self.assertEqual(mock_cr.mock_calls, calls) self.assertEqual( result, [{ "terasort": self.make_benchmark_data()["meta"]["composite"] }])
def test_run_actions_benchmark_with_no_param(self): content = """ benchmark: plugin/1: terasort """ test_plan = yaml.load(content) mock_client = MagicMock() with patch('cloud_weather_report.run_action', autospec=True, return_value=self.make_benchmark_data()) as mock_cr: result = cloud_weather_report.run_actions( test_plan, mock_client, make_fake_status()) calls = [call(mock_client, 'plugin/7', 'terasort', action_param=None, timeout=3600)] self.assertEqual(mock_cr.mock_calls, calls) self.assertEqual(result, [ {"terasort": self.make_benchmark_data()["meta"]["composite"]}])
def test_run_actions_single_and_multi_params(self): content = """ benchmark: plugin/0: terasort: time: 30s plugin/1: terasort2 """ test_plan = yaml.load(content) mock_client = MagicMock() with patch('cloud_weather_report.run_action', autospec=True, side_effect=[ self.make_benchmark_data(), self.make_benchmark_data() ]) as mock_cr: result = cloud_weather_report.run_actions(test_plan, mock_client, make_fake_status()) calls = [ call(mock_client, 'plugin/6', 'terasort', action_param={"time": "30s"}, timeout=3600), call(mock_client, 'plugin/7', 'terasort2', action_param=None, timeout=3600) ] self.assertItemsEqual(mock_cr.mock_calls, calls) self.assertEqual( result, [{ "terasort": self.make_benchmark_data()["meta"]["composite"] }, { "terasort2": self.make_benchmark_data()["meta"]["composite"] }])
def test_run_actions(self): content = """ tests: - foo-test - bar-test benchmark: plugin: terasort: time: 30s concurrency: 10 """ test_plan = yaml.load(content) mock_client = MagicMock() with patch('cloud_weather_report.run_action', autospec=True, return_value=self.make_benchmark_data()) as mock_cr: result = cloud_weather_report.run_actions( test_plan, mock_client, make_fake_status()) calls = [call(mock_client, 'plugin/6', 'terasort', action_param={"time": "30s", "concurrency": 10}, timeout=3600)] self.assertEqual(mock_cr.mock_calls, calls) self.assertEqual(result, [ {"terasort": self.make_benchmark_data()["meta"]["composite"]}])