Exemplo n.º 1
0
    def test_workload_set_results_empty_raw_data(self):
        workload = db.workload_create(self.task_uuid, self.subtask_uuid,
                                      name="foo", description="descr",
                                      position=0, args={},
                                      contexts={}, sla={},
                                      hooks=[], runner={},
                                      runner_type="foo")
        sla_results = [{"s": "S", "success": False},
                       {"1": "2", "success": True},
                       {"a": "A", "success": True}]
        load_duration = 13
        full_duration = 42
        start_time = 33.33
        w_ctx_results = [{"name": "setup:something"}]

        db.workload_set_results(workload_uuid=workload["uuid"],
                                subtask_uuid=self.subtask_uuid,
                                task_uuid=self.task_uuid,
                                load_duration=load_duration,
                                full_duration=full_duration,
                                start_time=start_time,
                                sla_results=sla_results,
                                contexts_results=w_ctx_results)
        workload = db.workload_get(workload["uuid"])
        self.assertIsNone(workload["min_duration"])
        self.assertIsNone(workload["max_duration"])
        self.assertEqual(0, workload["total_iteration_count"])
        self.assertEqual(0, workload["failed_iteration_count"])
        self.assertFalse(workload["pass_sla"])
        self.assertEqual(sla_results, workload["sla_results"]["sla"])
        self.assertEqual(load_duration, workload["load_duration"])
        self.assertEqual(full_duration, workload["full_duration"])
        self.assertEqual(start_time, workload["start_time"])
        self.assertEqual(self.task_uuid, workload["task_uuid"])
        self.assertEqual(self.subtask_uuid, workload["subtask_uuid"])
Exemplo n.º 2
0
    def test_workload_set_results_empty_raw_data(self):
        workload = db.workload_create(self.task_uuid,
                                      self.subtask_uuid,
                                      name="foo",
                                      description="descr",
                                      position=0,
                                      args={},
                                      contexts={},
                                      sla={},
                                      hooks=[],
                                      runner={},
                                      runner_type="foo")
        sla_results = [{
            "s": "S",
            "success": False
        }, {
            "1": "2",
            "success": True
        }, {
            "a": "A",
            "success": True
        }]
        load_duration = 13
        full_duration = 42
        start_time = 33.33
        w_ctx_results = [{"name": "setup:something"}]

        db.workload_set_results(workload_uuid=workload["uuid"],
                                subtask_uuid=self.subtask_uuid,
                                task_uuid=self.task_uuid,
                                load_duration=load_duration,
                                full_duration=full_duration,
                                start_time=start_time,
                                sla_results=sla_results,
                                contexts_results=w_ctx_results)
        workload = db.workload_get(workload["uuid"])
        self.assertIsNone(workload["min_duration"])
        self.assertIsNone(workload["max_duration"])
        self.assertEqual(0, workload["total_iteration_count"])
        self.assertEqual(0, workload["failed_iteration_count"])
        self.assertFalse(workload["pass_sla"])
        self.assertEqual(sla_results, workload["sla_results"]["sla"])
        self.assertEqual(load_duration, workload["load_duration"])
        self.assertEqual(full_duration, workload["full_duration"])
        self.assertEqual(start_time, workload["start_time"])
        self.assertEqual(self.task_uuid, workload["task_uuid"])
        self.assertEqual(self.subtask_uuid, workload["subtask_uuid"])
Exemplo n.º 3
0
    def test_workload_set_results_with_raw_data(self):
        workload = db.workload_create(self.task_uuid,
                                      self.subtask_uuid,
                                      name="foo",
                                      description="descr",
                                      position=0,
                                      args={},
                                      contexts={},
                                      sla={},
                                      hooks=[],
                                      runner={},
                                      runner_type="foo")
        raw_data = {
            "raw": [{
                "error":
                "anError",
                "duration":
                1,
                "idle_duration":
                0,
                "timestamp":
                1,
                "atomic_actions": [{
                    "name": "foo",
                    "started_at": 1,
                    "finished_at": 3,
                    "children": []
                }]
            }, {
                "error":
                None,
                "duration":
                2,
                "idle_duration":
                0,
                "timestamp":
                1,
                "atomic_actions": [{
                    "name": "foo",
                    "started_at": 1,
                    "finished_at": 2,
                    "children": []
                }]
            }, {
                "error":
                None,
                "duration":
                0,
                "idle_duration":
                0,
                "timestamp":
                2,
                "atomic_actions": [{
                    "name": "foo",
                    "started_at": 1,
                    "finished_at": 10,
                    "children": []
                }]
            }],
        }
        sla_results = [{
            "s": "S",
            "success": True
        }, {
            "1": "2",
            "success": True
        }, {
            "a": "A",
            "success": True
        }]
        load_duration = 13
        full_duration = 42
        start_time = 33.33
        w_ctx_results = [{"name": "setup:something"}]

        db.workload_data_create(self.task_uuid, workload["uuid"], 0, raw_data)
        db.workload_set_results(workload_uuid=workload["uuid"],
                                subtask_uuid=self.subtask_uuid,
                                task_uuid=self.task_uuid,
                                load_duration=load_duration,
                                full_duration=full_duration,
                                start_time=start_time,
                                sla_results=sla_results,
                                contexts_results=w_ctx_results)
        workload = db.workload_get(workload["uuid"])

        self.assertEqual(13, workload["load_duration"])
        self.assertEqual(42, workload["full_duration"])
        self.assertEqual(0, workload["min_duration"])
        self.assertEqual(2, workload["max_duration"])
        self.assertEqual(3, workload["total_iteration_count"])
        self.assertEqual(1, workload["failed_iteration_count"])
        self.assertTrue(workload["pass_sla"])
        self.assertEqual([], workload["hooks"])
        self.assertEqual(sla_results, workload["sla_results"]["sla"])
        self.assertEqual(load_duration, workload["load_duration"])
        self.assertEqual(full_duration, workload["full_duration"])
        self.assertEqual(start_time, workload["start_time"])
        self.assertEqual(self.task_uuid, workload["task_uuid"])
        self.assertEqual(self.subtask_uuid, workload["subtask_uuid"])
Exemplo n.º 4
0
    def test_workload_set_results_with_raw_data(self):
        workload = db.workload_create(self.task_uuid, self.subtask_uuid,
                                      name="foo", description="descr",
                                      position=0, args={},
                                      contexts={}, sla={},
                                      hooks=[], runner={},
                                      runner_type="foo")
        raw_data = {
            "raw": [
                {"error": "anError",
                 "duration": 1,
                 "idle_duration": 0,
                 "timestamp": 1,
                 "atomic_actions": [
                     {"name": "foo",
                      "started_at": 1,
                      "finished_at": 3,
                      "children": []}]},
                {"error": None,
                 "duration": 2,
                 "idle_duration": 0,
                 "timestamp": 1,
                 "atomic_actions": [
                     {"name": "foo",
                      "started_at": 1,
                      "finished_at": 2,
                      "children": []}]},
                {"error": None,
                 "duration": 0,
                 "idle_duration": 0,
                 "timestamp": 2,
                 "atomic_actions": [
                     {"name": "foo",
                      "started_at": 1,
                      "finished_at": 10,
                      "children": []}]}
            ],
        }
        sla_results = [{"s": "S", "success": True},
                       {"1": "2", "success": True},
                       {"a": "A", "success": True}]
        load_duration = 13
        full_duration = 42
        start_time = 33.33
        w_ctx_results = [{"name": "setup:something"}]

        db.workload_data_create(self.task_uuid, workload["uuid"], 0, raw_data)
        db.workload_set_results(workload_uuid=workload["uuid"],
                                subtask_uuid=self.subtask_uuid,
                                task_uuid=self.task_uuid,
                                load_duration=load_duration,
                                full_duration=full_duration,
                                start_time=start_time,
                                sla_results=sla_results,
                                contexts_results=w_ctx_results)
        workload = db.workload_get(workload["uuid"])

        self.assertEqual(13, workload["load_duration"])
        self.assertEqual(42, workload["full_duration"])
        self.assertEqual(0, workload["min_duration"])
        self.assertEqual(2, workload["max_duration"])
        self.assertEqual(3, workload["total_iteration_count"])
        self.assertEqual(1, workload["failed_iteration_count"])
        self.assertTrue(workload["pass_sla"])
        self.assertEqual([], workload["hooks"])
        self.assertEqual(sla_results, workload["sla_results"]["sla"])
        self.assertEqual(load_duration, workload["load_duration"])
        self.assertEqual(full_duration, workload["full_duration"])
        self.assertEqual(start_time, workload["start_time"])
        self.assertEqual(self.task_uuid, workload["task_uuid"])
        self.assertEqual(self.subtask_uuid, workload["subtask_uuid"])