diff options
author | helenyao <yaohelan@huawei.com> | 2017-02-15 21:04:34 -0500 |
---|---|---|
committer | helenyao <yaohelan@huawei.com> | 2017-02-22 06:44:47 -0500 |
commit | 0a09ecbcaefbc03f2a2bb9157be05007100aee90 (patch) | |
tree | beca1f470929e47cb739884c2e1b415b28ee5ae0 /functest/ci | |
parent | 0ab99ba102cfa888f8219af5b4cdb1271ae577d2 (diff) |
Prepare env will exit when an error is raised
JIRA: FUNCTEST-727
Change-Id: I4d8e24c0cb6272d92dc777dc82d56490948598db
Signed-off-by: helenyao <yaohelan@huawei.com>
Diffstat (limited to 'functest/ci')
-rwxr-xr-x | functest/ci/prepare_env.py | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/functest/ci/prepare_env.py b/functest/ci/prepare_env.py index 6b24fe08..ba34976a 100755 --- a/functest/ci/prepare_env.py +++ b/functest/ci/prepare_env.py @@ -1,18 +1,11 @@ #!/usr/bin/env python # -# Author: Jose Lausuch (jose.lausuch@ericsson.com) -# -# Installs the Functest framework within the Docker container -# and run the tests automatically -# -# # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 # - import argparse import json import os @@ -222,20 +215,19 @@ def install_rally(): "Deployment %s does not exist." % CONST.rally_deployment_name), verbose=False) + rally_conf = os_utils.get_credentials_for_rally() with open('rally_conf.json', 'w') as fp: json.dump(rally_conf, fp) cmd = ("rally deployment create " - "--file=rally_conf.json --name={}" + "--file=rally_conf.json --name={0}" .format(CONST.rally_deployment_name)) - ft_utils.execute_command(cmd, - error_msg=("Problem while creating " - "Rally deployment")) + error_msg = "Problem while creating Rally deployment" + ft_utils.execute_command_raise(cmd, error_msg=error_msg) cmd = "rally deployment check" - ft_utils.execute_command(cmd, - error_msg=("OpenStack not responding or " - "faulty Rally deployment.")) + error_msg = "OpenStack not responding or faulty Rally deployment." + ft_utils.execute_command_raise(cmd, error_msg=error_msg) cmd = "rally deployment list" ft_utils.execute_command(cmd, @@ -250,19 +242,30 @@ def install_rally(): def install_tempest(): logger.info("Installing tempest from existing repo...") - cmd = ("rally verify create-verifier --source {0} " - "--name {1} --type tempest" - .format(CONST.dir_repo_tempest, CONST.tempest_deployment_name)) - ft_utils.execute_command(cmd, - error_msg="Problem while installing Tempest.") + cmd = ("rally verify list-verifiers | " + "grep '{0}' | wc -l".format(CONST.tempest_deployment_name)) + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) + while p.poll() is None: + line = p.stdout.readline().rstrip() + if str(line) == '0': + logger.debug("Tempest %s does not exist" % + CONST.tempest_deployment_name) + cmd = ("rally verify create-verifier --source {0} " + "--name {1} --type tempest" + .format(CONST.dir_repo_tempest, + CONST.tempest_deployment_name)) + error_msg = "Problem while installing Tempest." + ft_utils.execute_command_raise(cmd, error_msg=error_msg) def create_flavor(): - os_utils.get_or_create_flavor('m1.tiny', - '512', - '1', - '1', - public=True) + _, flavor_id = os_utils.get_or_create_flavor('m1.tiny', + '512', + '1', + '1', + public=True) + if flavor_id is None: + raise Exception('Failed to create flavor') def check_environment(): |