From b378f55a9b78889eb82c3f6516a19ad3bebb82ea Mon Sep 17 00:00:00 2001 From: chenhb Date: Thu, 30 Nov 2017 15:19:23 +0800 Subject: [PATCH] Make the error code diffrent between running error and sla error We could decide to go running or stop our tasks by the different error code. Change-Id: If9e76858b3644127263270fc799e8df0b78b6c19 --- rally/cli/commands/task.py | 6 +++++- tests/ci/rally_gate_functions.sh | 6 ++++++ tests/unit/cli/commands/test_task.py | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/rally/cli/commands/task.py b/rally/cli/commands/task.py index 03a859fff7..18b2618278 100644 --- a/rally/cli/commands/task.py +++ b/rally/cli/commands/task.py @@ -281,6 +281,8 @@ class TaskCommands(object): If both task_args and task_args_file are specified, they are going to be merged. task_args has a higher priority so it overrides values from task_args_file. + There are 3 kinds of return codes, 0: no error, 1: running error, + 2: sla check failed. """ input_task = self._load_and_validate_task(api, task_file, @@ -310,7 +312,9 @@ class TaskCommands(object): print("Cannot start a task on unfinished deployment: %s" % e) return 1 - return self._detailed(api, task_id=task_instance["uuid"]) + if self._detailed(api, task_id=task_instance["uuid"]): + return 2 + return 0 @cliutils.args("--uuid", type=str, dest="task_id", help="UUID of task.") @envutils.with_default_task_id diff --git a/tests/ci/rally_gate_functions.sh b/tests/ci/rally_gate_functions.sh index 41ff600878..dbc240b86d 100644 --- a/tests/ci/rally_gate_functions.sh +++ b/tests/ci/rally_gate_functions.sh @@ -119,7 +119,13 @@ function run () { $PYTHON $RALLY_DIR/tests/ci/osresources.py --dump-list resources_at_start.txt + set +e rally --rally-debug task start --task $TASK $TASK_ARGS + retval=$? + if [[ $? -eq 1 ]]; then + exit $retval + fi + set -e mkdir -p rally-plot/extra $PYTHON $RALLY_DIR/tests/ci/render.py ci/index.html > rally-plot/extra/index.html diff --git a/tests/unit/cli/commands/test_task.py b/tests/unit/cli/commands/test_task.py index bfe82a6370..e7ca58ea3d 100644 --- a/tests/unit/cli/commands/test_task.py +++ b/tests/unit/cli/commands/test_task.py @@ -207,7 +207,7 @@ class TaskCommandsTestCase(test.TestCase): val = self.task.start(self.fake_api, task_path, deployment_id, do_use=True) - self.assertEqual(1, val) + self.assertEqual(2, val) mock_version.version_string.assert_called_once_with() self.fake_api.task.create.assert_called_once_with( deployment=deployment_id, tags=None)