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
This commit is contained in:
chenhb
2017-11-30 15:19:23 +08:00
parent 8b63ceb10d
commit b378f55a9b
3 changed files with 12 additions and 2 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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)