Esempio n. 1
0
    def test_task_list(self):
        INIT = consts.TaskStatus.INIT
        task_init = sorted(self._create_task()["uuid"] for i in range(3))
        FINISHED = consts.TaskStatus.FINISHED
        task_finished = sorted(
            self._create_task({
                "status": FINISHED,
                "env_uuid": self.env["uuid"]
            })["uuid"] for i in range(3))

        task_all = sorted(task_init + task_finished)

        def get_uuids(status=None, env=None):
            tasks = db.task_list(status=status, env=env)
            return sorted(task["uuid"] for task in tasks)

        self.assertEqual(task_all, get_uuids(None))

        self.assertEqual(task_init, get_uuids(status=INIT))
        self.assertEqual(task_finished, get_uuids(status=FINISHED))
        self.assertRaises(exceptions.DBRecordNotFound,
                          get_uuids,
                          env="non-existing-env")

        deleted_task_uuid = task_finished.pop()
        db.task_delete(deleted_task_uuid)
        self.assertEqual(task_init, get_uuids(INIT))
        self.assertEqual(sorted(task_finished), get_uuids(FINISHED))
Esempio n. 2
0
    def test_task_delete_with_results(self):
        task_id = self._create_task()["uuid"]
        key = {
            "name": "atata",
            "description": "tatata",
            "pos": 0,
            "kw": {
                "args": {"a": "A"},
                "context": {"c": "C"},
                "sla": {"s": "S"},
                "runner": {"r": "R", "type": "T"}
            }
        }
        data = {
            "sla": [
                {"s": "S", "success": True},
                {"1": "2", "success": True},
                {"a": "A", "success": True}
            ],
            "load_duration": 13,
            "full_duration": 42
        }
        subtask = db.subtask_create(task_id, title="foo")
        workload = db.workload_create(task_id, subtask["uuid"], key)
        db.workload_data_create(task_id, workload["uuid"], 0, {"raw": []})
        db.workload_set_results(workload["uuid"], data)

        res = db.task_result_get_all_by_uuid(task_id)
        self.assertEqual(len(res), 1)
        db.task_delete(task_id)
        res = db.task_result_get_all_by_uuid(task_id)
        self.assertEqual(len(res), 0)
Esempio n. 3
0
    def test_task_list(self):
        INIT = consts.TaskStatus.INIT
        task_init = sorted(self._create_task()["uuid"] for i in moves.range(3))
        FINISHED = consts.TaskStatus.FINISHED
        task_finished = sorted(
            self._create_task({
                "status": FINISHED,
                "deployment_uuid": self.deploy["uuid"]
            })["uuid"] for i in moves.range(3))

        task_all = sorted(task_init + task_finished)

        def get_uuids(status=None, deployment=None):
            tasks = db.task_list(status=status, deployment=deployment)
            return sorted(task["uuid"] for task in tasks)

        self.assertEqual(task_all, get_uuids(None))

        self.assertEqual(task_init, get_uuids(status=INIT))
        self.assertEqual(task_finished, get_uuids(status=FINISHED))
        self.assertRaises(exceptions.DeploymentNotFound,
                          get_uuids,
                          deployment="non-existing-deployment")

        deleted_task_uuid = task_finished.pop()
        db.task_delete(deleted_task_uuid)
        self.assertEqual(task_init, get_uuids(INIT))
        self.assertEqual(sorted(task_finished), get_uuids(FINISHED))
Esempio n. 4
0
    def test_task_list(self):
        INIT = consts.TaskStatus.INIT
        task_init = sorted(self._create_task()["uuid"] for i in moves.range(3))
        FINISHED = consts.TaskStatus.FINISHED
        task_finished = sorted(self._create_task(
            {"status": FINISHED,
             "deployment_uuid": self.deploy["uuid"]}
        )["uuid"] for i in moves.range(3))

        task_all = sorted(task_init + task_finished)

        def get_uuids(status=None, deployment=None):
            tasks = db.task_list(status=status, deployment=deployment)
            return sorted(task["uuid"] for task in tasks)

        self.assertEqual(task_all, get_uuids(None))

        self.assertEqual(task_init, get_uuids(status=INIT))
        self.assertEqual(task_finished, get_uuids(status=FINISHED))
        self.assertRaises(exceptions.DeploymentNotFound,
                          get_uuids, deployment="non-existing-deployment")

        deleted_task_uuid = task_finished.pop()
        db.task_delete(deleted_task_uuid)
        self.assertEqual(task_init, get_uuids(INIT))
        self.assertEqual(sorted(task_finished), get_uuids(FINISHED))
Esempio n. 5
0
 def test_task_delete_with_results(self):
     task_id = self._create_task()["uuid"]
     db.task_result_create(task_id, {task_id: task_id}, {task_id: task_id})
     res = db.task_result_get_all_by_uuid(task_id)
     self.assertEqual(len(res), 1)
     db.task_delete(task_id)
     res = db.task_result_get_all_by_uuid(task_id)
     self.assertEqual(len(res), 0)
Esempio n. 6
0
 def test_task_delete_by_uuid_and_status(self):
     values = {
         "status": consts.TaskStatus.FINISHED,
     }
     task1 = self._create_task(values=values)["uuid"]
     task2 = self._create_task(values=values)["uuid"]
     db.task_delete(task1, status=consts.TaskStatus.FINISHED)
     self.assertRaises(exceptions.TaskNotFound, self._get_task, task1)
     self.assertEqual(task2, self._get_task(task2)["uuid"])
Esempio n. 7
0
 def test_task_delete_by_uuid_and_status(self):
     values = {
         "status": consts.TaskStatus.FINISHED,
     }
     task1 = self._create_task(values=values)["uuid"]
     task2 = self._create_task(values=values)["uuid"]
     db.task_delete(task1, status=consts.TaskStatus.FINISHED)
     self.assertRaises(exceptions.TaskNotFound, self._get_task, task1)
     self.assertEqual(task2, self._get_task(task2)["uuid"])
Esempio n. 8
0
 def test_task_delete_with_results(self):
     task_id = self._create_task()["uuid"]
     db.task_result_create(task_id,
                           {task_id: task_id},
                           {task_id: task_id})
     res = db.task_result_get_all_by_uuid(task_id)
     self.assertEqual(len(res), 1)
     db.task_delete(task_id)
     res = db.task_result_get_all_by_uuid(task_id)
     self.assertEqual(len(res), 0)
Esempio n. 9
0
 def test_task_delete_with_results(self):
     task_id = self._create_task()["uuid"]
     key = {
         "name": "atata",
         "pos": 0,
         "kw": {
             "args": {
                 "a": "A"
             },
             "context": {
                 "c": "C"
             },
             "sla": {
                 "s": "S"
             },
             "runner": {
                 "r": "R",
                 "type": "T"
             }
         }
     }
     data = {
         "raw": [],
         "sla": [{
             "s": "S",
             "success": True
         }, {
             "1": "2",
             "success": True
         }, {
             "a": "A",
             "success": True
         }],
         "load_duration":
         13,
         "full_duration":
         42
     }
     db.task_result_create(task_id, key, data)
     res = db.task_result_get_all_by_uuid(task_id)
     self.assertEqual(len(res), 1)
     db.task_delete(task_id)
     res = db.task_result_get_all_by_uuid(task_id)
     self.assertEqual(len(res), 0)
Esempio n. 10
0
    def test_task_multiple_raw_result_create(self):
        task_id = self._create_task()["uuid"]
        subtask = db.subtask_create(task_id, title="foo")
        workload = db.workload_create(task_id,
                                      subtask["uuid"],
                                      name="atata",
                                      description="foo",
                                      position=0,
                                      args={},
                                      contexts={},
                                      sla={},
                                      runner={},
                                      runner_type="r",
                                      hooks=[])

        db.workload_data_create(
            task_id, workload["uuid"], 0, {
                "raw": [
                    {
                        "error": "anError",
                        "duration": 1,
                        "timestamp": 10,
                        "idle_duration": 1,
                        "atomic_actions": []
                    },
                    {
                        "error": None,
                        "duration": 1,
                        "timestamp": 10,
                        "idle_duration": 1,
                        "atomic_actions": []
                    },
                    {
                        "error": None,
                        "duration": 2,
                        "timestamp": 10,
                        "idle_duration": 1,
                        "atomic_actions": []
                    },
                    {
                        "error": None,
                        "duration": 3,
                        "timestamp": 10,
                        "idle_duration": 1,
                        "atomic_actions": []
                    },
                ],
            })

        db.workload_data_create(
            task_id, workload["uuid"], 1, {
                "raw": [
                    {
                        "error": "anError2",
                        "timestamp": 10,
                        "duration": 1,
                        "idle_duration": 0,
                        "atomic_actions": []
                    },
                    {
                        "error": None,
                        "duration": 6,
                        "timestamp": 10,
                        "idle_duration": 1,
                        "atomic_actions": []
                    },
                    {
                        "error": None,
                        "duration": 5,
                        "timestamp": 10,
                        "idle_duration": 1,
                        "atomic_actions": []
                    },
                    {
                        "error": None,
                        "duration": 4,
                        "timestamp": 10,
                        "idle_duration": 1,
                        "atomic_actions": []
                    },
                ],
            })

        db.workload_data_create(
            task_id, workload["uuid"], 2, {
                "raw": [
                    {
                        "error": None,
                        "duration": 7,
                        "timestamp": 10,
                        "idle_duration": 1,
                        "atomic_actions": []
                    },
                    {
                        "error": None,
                        "duration": 8,
                        "timestamp": 10,
                        "idle_duration": 1,
                        "atomic_actions": []
                    },
                ],
            })

        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_set_results(workload_uuid=workload["uuid"],
                                subtask_uuid=workload["subtask_uuid"],
                                task_uuid=workload["task_uuid"],
                                load_duration=load_duration,
                                full_duration=full_duration,
                                start_time=start_time,
                                sla_results=sla_results,
                                contexts_results=w_ctx_results)

        detailed_task = db.task_get(task_id, detailed=True)
        self.assertEqual(1, len(detailed_task["subtasks"]))
        self.assertEqual(1, len(detailed_task["subtasks"][0]["workloads"]))
        workload = detailed_task["subtasks"][0]["workloads"][0]
        self.assertEqual([{
            "error": "anError",
            "timestamp": 10,
            "duration": 1,
            "idle_duration": 1,
            "atomic_actions": []
        }, {
            "error": None,
            "duration": 1,
            "timestamp": 10,
            "idle_duration": 1,
            "atomic_actions": []
        }, {
            "error": None,
            "duration": 2,
            "timestamp": 10,
            "idle_duration": 1,
            "atomic_actions": []
        }, {
            "error": None,
            "duration": 3,
            "timestamp": 10,
            "idle_duration": 1,
            "atomic_actions": []
        }, {
            "error": "anError2",
            "timestamp": 10,
            "duration": 1,
            "idle_duration": 0,
            "atomic_actions": []
        }, {
            "error": None,
            "duration": 6,
            "timestamp": 10,
            "idle_duration": 1,
            "atomic_actions": []
        }, {
            "error": None,
            "duration": 5,
            "timestamp": 10,
            "idle_duration": 1,
            "atomic_actions": []
        }, {
            "error": None,
            "duration": 4,
            "timestamp": 10,
            "idle_duration": 1,
            "atomic_actions": []
        }, {
            "error": None,
            "duration": 7,
            "timestamp": 10,
            "idle_duration": 1,
            "atomic_actions": []
        }, {
            "error": None,
            "duration": 8,
            "timestamp": 10,
            "idle_duration": 1,
            "atomic_actions": []
        }], workload["data"])
        self.assertTrue(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(2, workload["failed_iteration_count"])
        self.assertEqual(10, workload["total_iteration_count"])
        self.assertEqual(w_ctx_results, workload["contexts_results"])

        db.task_delete(task_id)
Esempio n. 11
0
 def test_task_delete(self):
     task1, task2 = self._create_task()["uuid"], self._create_task()["uuid"]
     db.task_delete(task1)
     self.assertRaises(exceptions.TaskNotFound, self._get_task, task1)
     self.assertEqual(task2, self._get_task(task2)["uuid"])
Esempio n. 12
0
 def delete(self, status=None):
     db.task_delete(self.task["uuid"], status=status)
Esempio n. 13
0
 def delete_by_uuid(uuid, status=None):
     db.task_delete(uuid, status=status)
Esempio n. 14
0
 def delete(self, status=None):
     db.task_delete(self.task["uuid"], status=status)
Esempio n. 15
0
 def delete_by_uuid(uuid, status=None):
     db.task_delete(uuid, status=status)
Esempio n. 16
0
    def test_task_multiple_raw_result_create(self):
        task_id = self._create_task()["uuid"]
        subtask = db.subtask_create(task_id, title="foo")
        workload = db.workload_create(task_id, subtask["uuid"], name="atata",
                                      description="foo", position=0, args={},
                                      contexts={}, sla={}, runner={},
                                      runner_type="r", hooks=[])

        db.workload_data_create(task_id, workload["uuid"], 0, {
            "raw": [
                {"error": "anError",
                 "duration": 1,
                 "timestamp": 10,
                 "idle_duration": 1,
                 "atomic_actions": []},
                {"error": None,
                 "duration": 1,
                 "timestamp": 10,
                 "idle_duration": 1,
                 "atomic_actions": []},
                {"error": None,
                 "duration": 2,
                 "timestamp": 10,
                 "idle_duration": 1,
                 "atomic_actions": []},
                {"error": None,
                 "duration": 3,
                 "timestamp": 10,
                 "idle_duration": 1,
                 "atomic_actions": []},
            ],
        })

        db.workload_data_create(task_id, workload["uuid"], 1, {
            "raw": [
                {"error": "anError2",
                 "timestamp": 10,
                 "duration": 1,
                 "idle_duration": 0,
                 "atomic_actions": []},
                {"error": None,
                 "duration": 6,
                 "timestamp": 10,
                 "idle_duration": 1,
                 "atomic_actions": []},
                {"error": None,
                 "duration": 5,
                 "timestamp": 10,
                 "idle_duration": 1,
                 "atomic_actions": []},
                {"error": None,
                 "duration": 4,
                 "timestamp": 10,
                 "idle_duration": 1,
                 "atomic_actions": []},
            ],
        })

        db.workload_data_create(task_id, workload["uuid"], 2, {
            "raw": [
                {"error": None,
                 "duration": 7,
                 "timestamp": 10,
                 "idle_duration": 1,
                 "atomic_actions": []},
                {"error": None,
                 "duration": 8,
                 "timestamp": 10,
                 "idle_duration": 1,
                 "atomic_actions": []},
            ],
        })

        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_set_results(workload_uuid=workload["uuid"],
                                subtask_uuid=workload["subtask_uuid"],
                                task_uuid=workload["task_uuid"],
                                load_duration=load_duration,
                                full_duration=full_duration,
                                start_time=start_time,
                                sla_results=sla_results,
                                contexts_results=w_ctx_results)

        detailed_task = db.task_get(task_id, detailed=True)
        self.assertEqual(1, len(detailed_task["subtasks"]))
        self.assertEqual(1, len(detailed_task["subtasks"][0]["workloads"]))
        workload = detailed_task["subtasks"][0]["workloads"][0]
        self.assertEqual([
            {"error": "anError", "timestamp": 10, "duration": 1,
             "idle_duration": 1, "atomic_actions": []},
            {"error": None, "duration": 1, "timestamp": 10, "idle_duration": 1,
             "atomic_actions": []},
            {"error": None, "duration": 2, "timestamp": 10, "idle_duration": 1,
             "atomic_actions": []},
            {"error": None, "duration": 3, "timestamp": 10, "idle_duration": 1,
             "atomic_actions": []},
            {"error": "anError2", "timestamp": 10, "duration": 1,
             "idle_duration": 0, "atomic_actions": []},
            {"error": None, "duration": 6, "timestamp": 10, "idle_duration": 1,
             "atomic_actions": []},
            {"error": None, "duration": 5, "timestamp": 10, "idle_duration": 1,
             "atomic_actions": []},
            {"error": None, "duration": 4, "timestamp": 10, "idle_duration": 1,
             "atomic_actions": []},
            {"error": None, "duration": 7, "timestamp": 10, "idle_duration": 1,
             "atomic_actions": []},
            {"error": None, "duration": 8, "timestamp": 10, "idle_duration": 1,
             "atomic_actions": []}], workload["data"])
        self.assertTrue(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(2, workload["failed_iteration_count"])
        self.assertEqual(10, workload["total_iteration_count"])
        self.assertEqual(w_ctx_results, workload["contexts_results"])

        db.task_delete(task_id)
Esempio n. 17
0
 def test_task_delete(self):
     task1, task2 = self._create_task()["uuid"], self._create_task()["uuid"]
     db.task_delete(task1)
     self.assertRaises(exceptions.TaskNotFound, self._get_task, task1)
     self.assertEqual(task2, self._get_task(task2)["uuid"])
Esempio n. 18
0
    def test_task_multiple_raw_result_create(self):
        task_id = self._create_task()["uuid"]
        key = {
            "name": "atata",
            "description": "tatata",
            "pos": 0,
            "kw": {
                "args": {"a": "A"},
                "context": {"c": "C"},
                "sla": {"s": "S"},
                "runner": {"r": "R", "type": "T"},
                "hooks": [],
            }
        }

        subtask = db.subtask_create(task_id, title="foo")
        workload = db.workload_create(task_id, subtask["uuid"], key)

        db.workload_data_create(task_id, workload["uuid"], 0, {
            "raw": [
                {"error": "anError", "timestamp": 10, "duration": 1,
                 "atomic_actions": []},
                {"duration": 1, "timestamp": 10, "duration": 1,
                 "atomic_actions": []},
                {"duration": 2, "timestamp": 10, "duration": 1,
                 "atomic_actions": []},
                {"duration": 3, "timestamp": 10, "duration": 1,
                 "atomic_actions": []},
            ],
        })

        db.workload_data_create(task_id, workload["uuid"], 1, {
            "raw": [
                {"error": "anError2", "timestamp": 10, "duration": 1,
                 "atomic_actions": []},
                {"duration": 6, "timestamp": 10, "duration": 1,
                 "atomic_actions": []},
                {"duration": 5, "timestamp": 10, "duration": 1,
                 "atomic_actions": []},
                {"duration": 4, "timestamp": 10, "duration": 1,
                 "atomic_actions": []},
            ],
        })

        db.workload_data_create(task_id, workload["uuid"], 2, {
            "raw": [
                {"duration": 7, "timestamp": 10, "duration": 1,
                 "atomic_actions": []},
                {"duration": 8, "timestamp": 10, "duration": 1,
                 "atomic_actions": []},
            ],
        })

        db.workload_set_results(workload["uuid"], {
            "sla": [{"success": True}],
            "load_duration": 13,
            "full_duration": 42
        })

        res = db.task_result_get_all_by_uuid(task_id)
        self.assertEqual(len(res), 1)
        self.assertEqual(res[0]["key"], key)
        self.assertEqual(res[0]["data"], {
            "raw": [
                {"error": "anError", "timestamp": 10, "duration": 1,
                 "atomic_actions": []},
                {"duration": 1, "timestamp": 10, "duration": 1,
                 "atomic_actions": []},
                {"duration": 2, "timestamp": 10, "duration": 1,
                 "atomic_actions": []},
                {"duration": 3, "timestamp": 10, "duration": 1,
                 "atomic_actions": []},
                {"error": "anError2", "timestamp": 10, "duration": 1,
                 "atomic_actions": []},
                {"duration": 6, "timestamp": 10, "duration": 1,
                 "atomic_actions": []},
                {"duration": 5, "timestamp": 10, "duration": 1,
                 "atomic_actions": []},
                {"duration": 4, "timestamp": 10, "duration": 1,
                 "atomic_actions": []},
                {"duration": 7, "timestamp": 10, "duration": 1,
                 "atomic_actions": []},
                {"duration": 8, "timestamp": 10, "duration": 1,
                 "atomic_actions": []},
            ],
            "sla": [{"success": True}],
            "hooks": [],
            "load_duration": 13,
            "full_duration": 42
        })

        db.task_delete(task_id)
        res = db.task_result_get_all_by_uuid(task_id)
        self.assertEqual(len(res), 0)