def test_init(self, mock_workload_create): mock_workload_create.return_value = self.workload name = "w" description = "descr" position = 0 runner = {"type": "constant"} context = {"users": {}} sla = {"failure_rate": {"max": 0}} args = {"arg": "xxx"} hooks = [{"config": {"foo": "bar"}}] workload = objects.Workload("uuid1", "uuid2", name=name, description=description, position=position, runner=runner, context=context, sla=sla, args=args, hooks=hooks) mock_workload_create.assert_called_once_with(task_uuid="uuid1", subtask_uuid="uuid2", name=name, hooks=hooks, description=description, position=position, runner=runner, runner_type="constant", context=context, sla=sla, args=args) self.assertEqual(workload["uuid"], self.workload["uuid"])
def test_set_results(self, mock_workload_create, mock_workload_set_results): mock_workload_create.return_value = self.workload workload = objects.Workload("uuid1", "uuid2", {"bar": "baz"}) workload = workload.set_results({"data": "foo"}) mock_workload_set_results.assert_called_once_with( self.workload["uuid"], {"data": "foo"})
def test_add_workload_data(self, mock_workload_create, mock_workload_data_create): mock_workload_create.return_value = self.workload workload = objects.Workload("uuid1", "uuid2", {"bar": "baz"}) workload = workload.add_workload_data(0, {"data": "foo"}) mock_workload_data_create.assert_called_once_with( self.workload["task_uuid"], self.workload["uuid"], 0, {"data": "foo"})
def test_add_workload_data(self, mock_workload_create, mock_workload_data_create): mock_workload_create.return_value = self.workload workload = objects.Workload("uuid1", "uuid2", name="w", description="descr", position=0, runner_type="foo", runner={}, contexts=None, sla=None, args=None, hooks=[]) workload.add_workload_data(0, {"data": "foo"}) mock_workload_data_create.assert_called_once_with( self.workload["task_uuid"], self.workload["uuid"], 0, {"data": "foo"})
def test_set_results(self, mock_workload_create, mock_workload_set_results): mock_workload_create.return_value = self.workload name = "w" description = "descr" position = 0 runner_type = "constant" runner = {"times": 3} contexts = {"users": {}} sla = {"failure_rate": {"max": 0}} args = {"arg": "xxx"} load_duration = 88 full_duration = 99 start_time = 1231231277.22 sla_results = [] hooks = [] contexts_results = [{"name": "setup:something"}] workload = objects.Workload("uuid1", "uuid2", name=name, description=description, position=position, runner=runner, runner_type=runner_type, contexts=contexts, sla=sla, args=args, hooks=hooks) workload.set_results(load_duration=load_duration, full_duration=full_duration, start_time=start_time, sla_results=sla_results, contexts_results=contexts_results) mock_workload_set_results.assert_called_once_with( workload_uuid=self.workload["uuid"], subtask_uuid=self.workload["subtask_uuid"], task_uuid=self.workload["task_uuid"], load_duration=load_duration, full_duration=full_duration, start_time=start_time, sla_results=sla_results, contexts_results=contexts_results, hooks_results=None)
def test_init(self, mock_workload_create): mock_workload_create.return_value = self.workload workload = objects.Workload("uuid1", "uuid2", {"bar": "baz"}) mock_workload_create.assert_called_once_with("uuid1", "uuid2", {"bar": "baz"}) self.assertEqual(workload["uuid"], self.workload["uuid"])