summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthewLi <matthew.lijun@huawei.com>2017-03-25 02:44:00 -0400
committerCédric Ollivier <cedric.ollivier@orange.com>2017-05-13 08:40:50 +0200
commit24aaee1511131e9528999ec7cfdb88240d7cff50 (patch)
treed7989dd30188943a9ec0c349bbb6923a660cf907
parentf5b4588ae8d59f1f1bd4ca4406419d1dc9da35df (diff)
refstack client: manually running improvement
JIRA: FUNCTEST-758 1.python tempest_conf.py can generate a reference tempest.conf under /hom/opnfv/.../refstack_client this is based on "rally verify configure-verifier" surely, user can define his/her own tempest.conf by not using this 2.python refstack_client.py -c <tempest_conf_path> --testlist <testlist_file_path> if not given, will use default path, if file not exists, will have error Change-Id: I1ceecbe8fe86fbe0d53b736a0f3b9a9ae01f262f Signed-off-by: MatthewLi <matthew.lijun@huawei.com> (cherry picked from commit 678d5f956b1af373f61f97187ff3e66fdb315654)
-rwxr-xr-xfunctest/opnfv_tests/openstack/refstack_client/refstack_client.py53
-rwxr-xr-xfunctest/opnfv_tests/openstack/refstack_client/tempest_conf.py53
2 files changed, 78 insertions, 28 deletions
diff --git a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
index 597ece3e4..101bf7360 100755
--- a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
+++ b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
@@ -14,10 +14,10 @@ import time
from functest.core import testcase
from functest.opnfv_tests.openstack.tempest import conf_utils
-from functest.utils import openstack_utils
from functest.utils.constants import CONST
import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as ft_utils
+from tempest_conf import TempestConf
""" logging configuration """
logger = ft_logger.Logger("refstack_defcore").getLogger()
@@ -35,12 +35,6 @@ class RefstackClient(testcase.TestCase):
self.CONF_PATH)
self.defcorelist = os.path.join(self.FUNCTEST_TEST,
self.DEFCORE_LIST)
- self.VERIFIER_ID = conf_utils.get_verifier_id()
- self.VERIFIER_REPO_DIR = conf_utils.get_verifier_repo_dir(
- self.VERIFIER_ID)
- self.DEPLOYMENT_ID = conf_utils.get_verifier_deployment_id()
- self.DEPLOYMENT_DIR = conf_utils.get_verifier_deployment_dir(
- self.VERIFIER_ID, self.DEPLOYMENT_ID)
def source_venv(self):
@@ -143,28 +137,18 @@ class RefstackClient(testcase.TestCase):
logger.info("Testcase %s success_rate is %s%%, is marked as %s"
% (self.case_name, success_rate, self.criteria))
- def defcore_env_prepare(self):
- try:
- img_flavor_dict = conf_utils.create_tempest_resources(
- use_custom_images=True, use_custom_flavors=True)
- conf_utils.configure_tempest_defcore(
- self.DEPLOYMENT_DIR, img_flavor_dict)
- self.source_venv()
- res = testcase.TestCase.EX_OK
- except KeyError as e:
- logger.error("defcore prepare env error with: %s", e)
- res = testcase.TestCase.EX_RUN_ERROR
-
- return res
-
def run(self):
+ '''used for functest command line,
+ functest testcase run refstack_defcore'''
self.start_time = time.time()
if not os.path.exists(conf_utils.REFSTACK_RESULTS_DIR):
os.makedirs(conf_utils.REFSTACK_RESULTS_DIR)
try:
- self.defcore_env_prepare()
+ tempestconf = TempestConf()
+ tempestconf.generate_tempestconf()
+ self.source_venv()
self.run_defcore_default()
self.parse_refstack_result()
res = testcase.TestCase.EX_OK
@@ -175,19 +159,32 @@ class RefstackClient(testcase.TestCase):
self.stop_time = time.time()
return res
+ def _prep_test(self):
+ '''Check that the config file exists.'''
+ if not os.path.isfile(self.confpath):
+ logger.error("Conf file not valid: %s" % self.confpath)
+ if not os.path.isfile(self.testlist):
+ logger.error("testlist file not valid: %s" % self.testlist)
+
def main(self, **kwargs):
+ '''used for manually running,
+ python refstack_client.py -c <tempest_conf_path>
+ --testlist <testlist_path>
+ can generate a reference tempest.conf by
+ python tempest_conf.py
+ '''
try:
- tempestconf = kwargs['config']
- testlist = kwargs['testlist']
+ self.confpath = kwargs['config']
+ self.testlist = kwargs['testlist']
except KeyError as e:
logger.error("Cannot run refstack client. Please check "
"%s", e)
return self.EX_RUN_ERROR
try:
- openstack_utils.source_credentials(CONST.openstack_creds)
- self.defcore_env_prepare()
- self.run_defcore(tempestconf, testlist)
- res = testcase.TestCase.EX_OK
+ self.source_venv()
+ self._prep_test()
+ self.run_defcore(self.confpath, self.testlist)
+ res = testcase.TestcaseBase.EX_OK
except Exception as e:
logger.error('Error with run: %s', e)
res = testcase.TestCase.EX_RUN_ERROR
diff --git a/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
new file mode 100755
index 000000000..66876bbf4
--- /dev/null
+++ b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+
+# matthew.lijun@huawei.com
+# 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 sys
+
+from functest.core import testcase
+from functest.opnfv_tests.openstack.tempest import conf_utils
+from functest.utils import openstack_utils
+from functest.utils.constants import CONST
+import functest.utils.functest_logger as ft_logger
+
+""" logging configuration """
+logger = ft_logger.Logger("refstack_defcore").getLogger()
+
+
+class TempestConf(object):
+ def __init__(self):
+ self.VERIFIER_ID = conf_utils.get_verifier_id()
+ self.VERIFIER_REPO_DIR = conf_utils.get_verifier_repo_dir(
+ self.VERIFIER_ID)
+ self.DEPLOYMENT_ID = conf_utils.get_verifier_deployment_id()
+ self.DEPLOYMENT_DIR = conf_utils.get_verifier_deployment_dir(
+ self.VERIFIER_ID, self.DEPLOYMENT_ID)
+
+ def generate_tempestconf(self):
+ try:
+ openstack_utils.source_credentials(CONST.openstack_creds)
+ img_flavor_dict = conf_utils.create_tempest_resources(
+ use_custom_images=True, use_custom_flavors=True)
+ conf_utils.configure_tempest_defcore(
+ self.DEPLOYMENT_DIR, img_flavor_dict)
+ except KeyError as e:
+ logger.error("defcore prepare env error with: %s", e)
+
+ def main(self):
+ try:
+ self.generate_tempestconf()
+ res = testcase.TestcaseBase.EX_OK
+ except Exception as e:
+ logger.error('Error with run: %s', e)
+ res = testcase.TestcaseBase.EX_RUN_ERROR
+
+ return res
+
+if __name__ == '__main__':
+ tempestconf = TempestConf()
+ result = tempestconf.main()
+ if result != testcase.TestcaseBase.EX_OK:
+ sys.exit(result)