def test_use(self): rally = utils.Rally() deployment_id = utils.get_global("RALLY_DEPLOYMENT", rally.env) 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 = utils.get_global("RALLY_TASK", rally.env) self.assertEqual(uuid, current_task)
def test_use(self): rally = utils.Rally() deployment_id = utils.get_global("RALLY_DEPLOYMENT", rally.env) 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 = utils.get_global("RALLY_TASK", rally.env) self.assertEqual(uuid, current_task)
def _start_task_in_new_thread(self, rally, cfg, report_file): deployment_id = utils.get_global("RALLY_DEPLOYMENT", rally.env) config = utils.TaskConfig(cfg) cmd = (("task start --task %(task_file)s " "--deployment %(deployment_id)s") % {"task_file": config.filename, "deployment_id": deployment_id}) report_path = os.path.join( os.environ.get("REPORTS_ROOT", "rally-cli-output-files"), "TaskTestCase", report_file) task = threading.Thread(target=rally, args=(cmd, ), kwargs={"report_path": report_path}) task.start() uuid = None while not uuid: if not uuid: uuid = utils.get_global("RALLY_TASK", rally.env) time.sleep(0.5) return task, uuid
def test_use(self): rally = utils.Rally() rally.env.update(TEST_ENV) output = rally("deployment create --name t_create_env1 --fromenv") uuid = re.search(r"Using deployment: (?P<uuid>[0-9a-f\-]{36})", output).group("uuid") rally("deployment create --name t_create_env2 --fromenv") rally("deployment use --deployment %s" % uuid) current_deployment = utils.get_global("RALLY_DEPLOYMENT", rally.env) self.assertEqual(uuid, current_deployment)
def _test_start_abort_on_sla_failure_success(self, cfg, times): rally = utils.Rally() deployment_id = utils.get_global("RALLY_DEPLOYMENT", rally.env) config = utils.TaskConfig(cfg) rally(("task start --task %(task_file)s " "--deployment %(deployment_id)s --abort-on-sla-failure") % {"task_file": config.filename, "deployment_id": deployment_id}) results = json.loads(rally("task results")) iterations_completed = len(results[0]["result"]) self.assertEqual(times, iterations_completed)
def test_validate_is_invalid(self): rally = utils.Rally() deployment_id = utils.get_global("RALLY_DEPLOYMENT", rally.env) cfg = {"invalid": "config"} config = utils.TaskConfig(cfg) self.assertRaises(utils.RallyCliError, rally, ("task validate --task %(task_file)s " "--deployment %(deployment_id)s") % {"task_file": config.filename, "deployment_id": deployment_id})
def _test_start_abort_on_sla_failure(self, cfg, times): rally = utils.Rally() deployment_id = utils.get_global("RALLY_DEPLOYMENT", rally.env) config = utils.TaskConfig(cfg) rally(("task start --task %(task_file)s " "--deployment %(deployment_id)s --abort-on-sla-failure") % {"task_file": config.filename, "deployment_id": deployment_id}) results = json.loads(rally("task results")) iterations_completed = len(results[0]["result"]) self.assertTrue(iterations_completed < times)
def test_start(self): rally = utils.Rally() deployment_id = utils.get_global("RALLY_DEPLOYMENT", rally.env) cfg = self._get_sample_task_config() config = utils.TaskConfig(cfg) 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<task_id>[0-9a-f\-]{36}): started", output) self.assertIsNotNone(result)
def test_use(self): self.rally.env.update(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 = utils.get_global("RALLY_DEPLOYMENT", self.rally.env) self.assertEqual(uuid, current_deployment)
def test_start_v2(self): rally = utils.Rally() deployment_id = utils.get_global("RALLY_DEPLOYMENT", rally.env) cfg = self._get_sample_task_config_v2() config = utils.TaskConfig(cfg) 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<task_id>[0-9a-f\-]{36}): started", output) self.assertIsNotNone(result)