예제 #1
0
파일: task.py 프로젝트: plomakin/rally
    def use(self, task):
        """Set active task. Alias for "rally use task".

        :param task: Task uuid.
        """
        print("Using task: %s" % task)
        db.task_get(task)
        fileutils.update_globals_file("RALLY_TASK", task)
예제 #2
0
    def use(self, task):
        """Set active task. Alias for "rally use task".

        :param task: Task uuid.
        """
        print("Using task: %s" % task)
        db.task_get(task)
        fileutils.update_globals_file("RALLY_TASK", task)
예제 #3
0
파일: task.py 프로젝트: plomakin/rally
    def status(self, task_id=None):
        """Display current status of task.

        :param task_id: Task uuid
        Returns current status of task
        """

        task = db.task_get(task_id)
        print(_("Task %(task_id)s: %(status)s")
              % {"task_id": task_id, "status": task["status"]})
    def create(self, task, deployment, tag=None, **kw):

        try:
            input_task = api.Task.render_template('%s' % task, **kw)
        except Exception as e:
            raise e

        # we don't know what is there
        try:
            input_task = json.loads(input_task)
        except Exception as e:
            input_task = yaml.load(input_task)

        task = api.Task.create(deployment, tag)
        db.task_get(task["uuid"])

        self.start(deployment, input_task, task=task,
                   abort_on_sla_failure=False)

        return task
예제 #5
0
    def status(self, task_id=None):
        """Display current status of task.

        :param task_id: Task uuid
        Returns current status of task
        """

        task = db.task_get(task_id)
        print(
            _("Task %(task_id)s: %(status)s") % {
                "task_id": task_id,
                "status": task["status"]
            })
예제 #6
0
파일: test_api.py 프로젝트: plomakin/rally
 def _get_task(self, uuid):
     return db.task_get(uuid)
예제 #7
0
파일: task.py 프로젝트: lihaijing/rally
 def get(uuid):
     return Task(db.task_get(uuid))
예제 #8
0
 def get(uuid):
     return Task(db.task_get(uuid))
예제 #9
0
 def _get_task(self, uuid):
     return db.task_get(uuid)
예제 #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)
예제 #11
0
    def test_task_create_and_get_detailed(self):
        validation_result = {
            "etype": "FooError",
            "msg": "foo message",
            "trace": "foo t/b",
        }
        task1 = self._create_task({
            "validation_result": validation_result,
            "tags": ["bar"]
        })
        w_name = "atata"
        w_description = "tatata"
        w_position = 0
        w_args = {"a": "A"}
        w_contexts = {"c": "C"}
        w_sla = {"s": "S"}
        w_runner = {"r": "R", "type": "T"}
        w_runner_type = "T"
        sla_results = [{
            "s": "S",
            "success": True
        }, {
            "1": "2",
            "success": True
        }, {
            "a": "A",
            "success": True
        }]
        w_load_duration = 13.0
        w_full_duration = 42.0
        w_start_time = 33.77
        w_hooks = []
        w_ctx_results = [{"name": "setup:something"}]

        subtask = db.subtask_create(task1["uuid"], title="foo")
        workload = db.workload_create(task1["uuid"],
                                      subtask["uuid"],
                                      name=w_name,
                                      description=w_description,
                                      position=w_position,
                                      args=w_args,
                                      contexts=w_contexts,
                                      sla=w_sla,
                                      hooks=w_hooks,
                                      runner=w_runner,
                                      runner_type=w_runner_type)
        db.workload_data_create(task1["uuid"], workload["uuid"], 0,
                                {"raw": []})
        db.workload_set_results(workload_uuid=workload["uuid"],
                                subtask_uuid=workload["subtask_uuid"],
                                task_uuid=workload["task_uuid"],
                                sla_results=sla_results,
                                load_duration=w_load_duration,
                                full_duration=w_full_duration,
                                start_time=w_start_time,
                                contexts_results=w_ctx_results)

        task1_full = db.task_get(task1["uuid"], detailed=True)
        self.assertEqual(validation_result, task1_full["validation_result"])
        self.assertEqual(["bar"], task1_full["tags"])
        workloads = task1_full["subtasks"][0]["workloads"]
        self.assertEqual(1, len(workloads))
        workloads[0].pop("uuid")
        workloads[0].pop("created_at")
        workloads[0].pop("updated_at")

        self.assertEqual(
            {
                "subtask_uuid": subtask["uuid"],
                "task_uuid": task1["uuid"],
                "name": w_name,
                "description": w_description,
                "id": 1,
                "position": w_position,
                "data": [],
                "args": w_args,
                "contexts": w_contexts,
                "contexts_results": w_ctx_results,
                "hooks": w_hooks,
                "runner": w_runner,
                "runner_type": w_runner_type,
                "full_duration": w_full_duration,
                "load_duration": w_load_duration,
                "start_time": w_start_time,
                "max_duration": None,
                "min_duration": None,
                "failed_iteration_count": 0,
                "total_iteration_count": 0,
                "pass_sla": True,
                "sla": w_sla,
                "statistics": mock.ANY,
                "sla_results": {
                    "sla": sla_results
                }
            }, workloads[0])
예제 #12
0
파일: rallyd.py 프로젝트: dkalashnik/rallyd
def get_task(task_uuid):
    return flask.jsonify({"task": db.task_get(task_uuid)._as_dict()})
예제 #13
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)
예제 #14
0
    def test_task_create_and_get_detailed(self):
        validation_result = {
            "etype": "FooError",
            "msg": "foo message",
            "trace": "foo t/b",
        }
        task1 = self._create_task({"validation_result": validation_result,
                                   "tags": ["bar"]})
        w_name = "atata"
        w_description = "tatata"
        w_position = 0
        w_args = {"a": "A"}
        w_contexts = {"c": "C"}
        w_sla = {"s": "S"}
        w_runner = {"r": "R", "type": "T"}
        w_runner_type = "T"
        sla_results = [
            {"s": "S", "success": True},
            {"1": "2", "success": True},
            {"a": "A", "success": True}
        ]
        w_load_duration = 13.0
        w_full_duration = 42.0
        w_start_time = 33.77
        w_hooks = []
        w_ctx_results = [{"name": "setup:something"}]

        subtask = db.subtask_create(task1["uuid"], title="foo")
        workload = db.workload_create(task1["uuid"], subtask["uuid"],
                                      name=w_name, description=w_description,
                                      position=w_position, args=w_args,
                                      contexts=w_contexts, sla=w_sla,
                                      hooks=w_hooks, runner=w_runner,
                                      runner_type=w_runner_type)
        db.workload_data_create(task1["uuid"], workload["uuid"], 0,
                                {"raw": []})
        db.workload_set_results(workload_uuid=workload["uuid"],
                                subtask_uuid=workload["subtask_uuid"],
                                task_uuid=workload["task_uuid"],
                                sla_results=sla_results,
                                load_duration=w_load_duration,
                                full_duration=w_full_duration,
                                start_time=w_start_time,
                                contexts_results=w_ctx_results)

        task1_full = db.task_get(task1["uuid"], detailed=True)
        self.assertEqual(validation_result, task1_full["validation_result"])
        self.assertEqual(["bar"], task1_full["tags"])
        workloads = task1_full["subtasks"][0]["workloads"]
        self.assertEqual(1, len(workloads))
        workloads[0].pop("uuid")
        workloads[0].pop("created_at")
        workloads[0].pop("updated_at")

        self.assertEqual(
            {"subtask_uuid": subtask["uuid"],
             "task_uuid": task1["uuid"],
             "name": w_name, "description": w_description,
             "id": 1, "position": w_position,
             "data": [],
             "args": w_args,
             "contexts": w_contexts,
             "contexts_results": w_ctx_results,
             "hooks": w_hooks,
             "runner": w_runner, "runner_type": w_runner_type,
             "full_duration": w_full_duration,
             "load_duration": w_load_duration,
             "start_time": w_start_time,
             "max_duration": None, "min_duration": None,
             "failed_iteration_count": 0, "total_iteration_count": 0,
             "pass_sla": True, "sla": w_sla, "statistics": mock.ANY,
             "sla_results": {"sla": sla_results}}, workloads[0])