Merge "Add aliases "rally task|deployment|verify use""

This commit is contained in:
Jenkins 2015-02-19 13:37:42 +00:00 committed by Gerrit Code Review
commit 32c02ab658
2 changed files with 29 additions and 0 deletions

View File

@ -14,10 +14,12 @@
# under the License. # under the License.
import json import json
import re
import unittest import unittest
import mock import mock
from rally.cmd import envutils
from tests.functional import utils from tests.functional import utils
@ -77,3 +79,14 @@ class DeploymentTestCase(unittest.TestCase):
self.rally("deployment create --name t_create_env --fromenv") self.rally("deployment create --name t_create_env --fromenv")
self.rally("deployment recreate --deployment t_create_env") self.rally("deployment recreate --deployment t_create_env")
self.assertIn("t_create_env", self.rally("deployment list")) self.assertIn("t_create_env", self.rally("deployment list"))
def test_use(self):
with mock.patch.dict("os.environ", utils.TEST_ENV):
output = self.rally(
"deployment create --name t_create_env1 --fromenv")
uuid = re.search(r"Using deployment: (?P<uuid>[0-9a-f\-]{36})",
output).group("uuid")
self.rally("deployment create --name t_create_env2 --fromenv")
self.rally("deployment use --deployment %s" % uuid)
current_deployment = envutils.get_global("RALLY_DEPLOYMENT")
self.assertEqual(uuid, current_deployment)

View File

@ -473,6 +473,22 @@ class TaskTestCase(unittest.TestCase):
def test_abort(self): def test_abort(self):
pass pass
def test_use(self):
rally = utils.Rally()
with mock.patch.dict("os.environ", utils.TEST_ENV):
deployment_id = envutils.get_global("RALLY_DEPLOYMENT")
config = utils.TaskConfig(self._get_sample_task_config())
output = rally(("task start --task %(task_file)s "
"--deployment %(deployment_id)s") %
{"task_file": config.filename,
"deployment_id": deployment_id})
result = re.search(
r"(?P<uuid>[0-9a-f\-]{36}): started", output)
uuid = result.group("uuid")
rally("task use --task %s" % uuid)
current_task = envutils.get_global("RALLY_TASK")
self.assertEqual(uuid, current_task)
class SLATestCase(unittest.TestCase): class SLATestCase(unittest.TestCase):