diff options
Diffstat (limited to 'functest/opnfv_tests/openstack/refstack_client')
-rwxr-xr-x | functest/opnfv_tests/openstack/refstack_client/refstack_client.py | 42 | ||||
-rwxr-xr-x | functest/opnfv_tests/openstack/refstack_client/tempest_conf.py | 8 |
2 files changed, 29 insertions, 21 deletions
diff --git a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py index ebae4b86..5f1f3a1d 100755 --- a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py +++ b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py @@ -5,6 +5,10 @@ # 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 + +from __future__ import division + + import argparse import logging import os @@ -29,9 +33,9 @@ class RefstackClient(testcase.TestCase): if "case_name" not in kwargs: kwargs["case_name"] = "refstack_defcore" super(RefstackClient, self).__init__(**kwargs) - self.FUNCTEST_TEST = CONST.dir_functest_test - self.CONF_PATH = CONST.refstack_tempest_conf_path - self.DEFCORE_LIST = CONST.refstack_defcore_list + self.FUNCTEST_TEST = CONST.__getattribute__('dir_functest_test') + self.CONF_PATH = CONST.__getattribute__('refstack_tempest_conf_path') + self.DEFCORE_LIST = CONST.__getattribute__('refstack_defcore_list') self.confpath = os.path.join(self.FUNCTEST_TEST, self.CONF_PATH) self.defcorelist = os.path.join(self.FUNCTEST_TEST, @@ -41,7 +45,7 @@ class RefstackClient(testcase.TestCase): cmd = ("cd {0};" ". .venv/bin/activate;" - "cd -;".format(CONST.dir_refstack_client)) + "cd -;".format(CONST.__getattribute__('dir_refstack_client'))) ft_utils.execute_command(cmd) def run_defcore(self, conf, testlist): @@ -49,7 +53,7 @@ class RefstackClient(testcase.TestCase): cmd = ("cd {0};" "./refstack-client test -c {1} -v --test-list {2};" - "cd -;".format(CONST.dir_refstack_client, + "cd -;".format(CONST.__getattribute__('dir_refstack_client'), conf, testlist)) ft_utils.execute_command(cmd) @@ -59,16 +63,16 @@ class RefstackClient(testcase.TestCase): cmd = ("cd {0};" "./refstack-client test -c {1} -v --test-list {2};" - "cd -;".format(CONST.dir_refstack_client, + "cd -;".format(CONST.__getattribute__('dir_refstack_client'), self.confpath, self.defcorelist)) logger.info("Starting Refstack_defcore test case: '%s'." % cmd) header = ("Refstack environment:\n" " SUT: %s\n Scenario: %s\n Node: %s\n Date: %s\n" % - (CONST.INSTALLER_TYPE, - CONST.DEPLOY_SCENARIO, - CONST.NODE_NAME, + (CONST.__getattribute__('INSTALLER_TYPE'), + CONST.__getattribute__('DEPLOY_SCENARIO'), + CONST.__getattribute__('NODE_NAME'), time.strftime("%a %b %d %H:%M:%S %Z %Y"))) f_stdout = open( @@ -123,7 +127,11 @@ class RefstackClient(testcase.TestCase): skipped_testcases += match + ", " num_executed = int(num_tests) - int(num_skipped) - success_rate = 100 * int(num_success) / int(num_executed) + + try: + self.result = 100 * int(num_success) / int(num_executed) + except ZeroDivisionError: + logger.error("No test has been executed") self.details = {"tests": int(num_tests), "failures": int(num_failures), @@ -131,12 +139,10 @@ class RefstackClient(testcase.TestCase): "errors": failed_testcases, "skipped": skipped_testcases} except Exception: - success_rate = 0 + self.result = 0 - self.result = ft_utils.check_success_rate( - self.case_name, success_rate) - logger.info("Testcase %s success_rate is %s%%, is marked as %s" - % (self.case_name, success_rate, self.result)) + logger.info("Testcase %s success_rate is %s%%" + % (self.case_name, self.result)) def run(self): '''used for functest command line, @@ -196,9 +202,9 @@ class RefstackClient(testcase.TestCase): class RefstackClientParser(object): def __init__(self): - self.FUNCTEST_TEST = CONST.dir_functest_test - self.CONF_PATH = CONST.refstack_tempest_conf_path - self.DEFCORE_LIST = CONST.refstack_defcore_list + self.FUNCTEST_TEST = CONST.__getattribute__('dir_functest_test') + self.CONF_PATH = CONST.__getattribute__('refstack_tempest_conf_path') + self.DEFCORE_LIST = CONST.__getattribute__('refstack_defcore_list') self.confpath = os.path.join(self.FUNCTEST_TEST, self.CONF_PATH) self.defcorelist = os.path.join(self.FUNCTEST_TEST, diff --git a/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py index 5c04253c..fbaad589 100755 --- a/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py +++ b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py @@ -24,12 +24,14 @@ class TempestConf(object): self.DEPLOYMENT_ID = conf_utils.get_verifier_deployment_id() self.DEPLOYMENT_DIR = conf_utils.get_verifier_deployment_dir( self.VERIFIER_ID, self.DEPLOYMENT_ID) - self.confpath = os.path.join(CONST.dir_functest_test, - CONST.refstack_tempest_conf_path) + self.confpath = os.path.join( + CONST.__getattribute__('dir_functest_test'), + CONST.__getattribute__('refstack_tempest_conf_path')) def generate_tempestconf(self): try: - openstack_utils.source_credentials(CONST.openstack_creds) + openstack_utils.source_credentials( + CONST.__getattribute__('openstack_creds')) img_flavor_dict = conf_utils.create_tempest_resources( use_custom_images=True, use_custom_flavors=True) conf_utils.configure_tempest_defcore( |