summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--functest/opnfv_tests/openstack/refstack_client/refstack_client.py20
-rw-r--r--functest/opnfv_tests/openstack/refstack_client/tempest_conf.py35
-rw-r--r--functest/tests/unit/openstack/refstack_client/test_refstack_client.py10
-rw-r--r--tox.ini2
4 files changed, 37 insertions, 30 deletions
diff --git a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
index fe32da66b..4e8f58b62 100644
--- a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
+++ b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
@@ -38,6 +38,7 @@ LOGGER = logging.getLogger(__name__)
class RefstackClient(testcase.TestCase):
"""RefstackClient testcase implementation class."""
+ # pylint: disable=too-many-instance-attributes
def __init__(self, **kwargs):
"""Initialize RefstackClient testcase object."""
@@ -62,6 +63,7 @@ class RefstackClient(testcase.TestCase):
self.insecure = '-k'
def generate_conf(self):
+ """ Generate tempest.conf file to run tempest"""
if not os.path.exists(conf_utils.REFSTACK_RESULTS_DIR):
os.makedirs(conf_utils.REFSTACK_RESULTS_DIR)
@@ -86,11 +88,11 @@ class RefstackClient(testcase.TestCase):
"environment.log"), 'w+') as f_env:
f_env.write(
("Refstack environment:\n"
- " SUT: {}\n Scenario: {}\n Node: {}\n Date: {}\n").format(
- CONST.__getattribute__('INSTALLER_TYPE'),
- CONST.__getattribute__('DEPLOY_SCENARIO'),
- CONST.__getattribute__('NODE_NAME'),
- time.strftime("%a %b %d %H:%M:%S %Z %Y")))
+ " SUT: {}\n Scenario: {}\n Node: {}\n Date: {}\n")
+ .format(CONST.__getattribute__('INSTALLER_TYPE'),
+ CONST.__getattribute__('DEPLOY_SCENARIO'),
+ CONST.__getattribute__('NODE_NAME'),
+ time.strftime("%a %b %d %H:%M:%S %Z %Y")))
with open(os.path.join(conf_utils.REFSTACK_RESULTS_DIR,
"refstack.log"), 'w+') as f_stdout:
@@ -147,7 +149,7 @@ class RefstackClient(testcase.TestCase):
"success": success_testcases,
"errors": failed_testcases,
"skipped": skipped_testcases}
- except Exception:
+ except Exception: # pylint: disable=broad-except
self.result = 0
LOGGER.info("Testcase %s success_rate is %s%%",
@@ -170,7 +172,7 @@ class RefstackClient(testcase.TestCase):
self.run_defcore_default()
self.parse_refstack_result()
res = testcase.TestCase.EX_OK
- except Exception:
+ except Exception: # pylint: disable=broad-except
LOGGER.exception("Error with run")
res = testcase.TestCase.EX_RUN_ERROR
finally:
@@ -207,7 +209,7 @@ class RefstackClient(testcase.TestCase):
self._prep_test()
self.run_defcore(self.confpath, self.testlist)
res = testcase.TestCase.EX_OK
- except Exception as exc:
+ except Exception as exc: # pylint: disable=broad-except
LOGGER.error('Error with run: %s', exc)
res = testcase.TestCase.EX_RUN_ERROR
@@ -257,5 +259,5 @@ def main():
result = refstackclient.main(**args)
if result != testcase.TestCase.EX_OK:
return result
- except Exception:
+ except Exception: # pylint: disable=broad-except
return 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
index db7452271..5764f366c 100644
--- a/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
+++ b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
@@ -5,6 +5,9 @@
# 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
+
+""" Used to generate tempest.conf """
+
import logging
import pkg_resources
@@ -14,24 +17,23 @@ from functest.utils.constants import CONST
from functest.opnfv_tests.openstack.tempest.tempest \
import TempestResourcesManager
-""" logging configuration """
-logger = logging.getLogger(__name__)
+LOGGER = logging.getLogger(__name__)
class TempestConf(object):
+ """ TempestConf class"""
def __init__(self, **kwargs):
- 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)
+ self.verifier_id = conf_utils.get_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)
self.confpath = pkg_resources.resource_filename(
'functest',
'opnfv_tests/openstack/refstack_client/refstack_tempest.conf')
self.resources = TempestResourcesManager(**kwargs)
def generate_tempestconf(self):
+ """ Generate tempest.conf file"""
try:
openstack_utils.source_credentials(
CONST.__getattribute__('openstack_creds'))
@@ -39,29 +41,32 @@ class TempestConf(object):
use_custom_images=True,
use_custom_flavors=True)
conf_utils.configure_tempest_defcore(
- self.DEPLOYMENT_DIR,
+ self.deployment_dir,
image_id=resources.get("image_id"),
flavor_id=resources.get("flavor_id"),
image_id_alt=resources.get("image_id_alt"),
flavor_id_alt=resources.get("flavor_id_alt"),
tenant_id=resources.get("project_id"))
- except Exception as e:
- logger.error("error with generating refstack client "
- "reference tempest conf file: %s", e)
+ except Exception as err: # pylint: disable=broad-except
+ LOGGER.error("error with generating refstack client "
+ "reference tempest conf file: %s", err)
def main(self):
+ """ The main function called by entry point"""
try:
self.generate_tempestconf()
- logger.info("a reference tempest conf file generated "
+ LOGGER.info("a reference tempest conf file generated "
"at %s", self.confpath)
- except Exception as e:
- logger.error('Error with run: %s', e)
+ except Exception as err: # pylint: disable=broad-except
+ LOGGER.error('Error with run: %s', err)
def clean(self):
+ """Clean up the resources"""
self.resources.cleanup()
def main():
+ """Entry point"""
logging.basicConfig()
tempestconf = TempestConf()
tempestconf.main()
diff --git a/functest/tests/unit/openstack/refstack_client/test_refstack_client.py b/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
index 61e950a6b..a7a914cbe 100644
--- a/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
+++ b/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
@@ -10,9 +10,10 @@
# pylint: disable=missing-docstring
import logging
+import unittest
+
import mock
import pkg_resources
-import unittest
from functest.core import testcase
from functest.opnfv_tests.openstack.refstack_client.refstack_client import \
@@ -51,9 +52,7 @@ class OSRefstackClientTesting(unittest.TestCase):
"errors": ['tempest.api.volume [0.230334s]'],
"skipped": ['tempest.api.network [1.265828s]']}
- @mock.patch('functest.opnfv_tests.openstack.refstack_client.tempest_conf.'
- 'TempestConf', return_value=mock.Mock())
- def _create_client(self, *args):
+ def _create_client(self):
with mock.patch('snaps.openstack.tests.openstack_tests.'
'get_credentials', return_value=self.os_creds):
return RefstackClient()
@@ -145,8 +144,7 @@ class OSRefstackClientTesting(unittest.TestCase):
parser = RefstackClientParser()
self.assertEqual(parser.parse_args(
["--config={}".format(self._config),
- "--testlist={}".format(self._testlist)
- ]), self.default_args)
+ "--testlist={}".format(self._testlist)]), self.default_args)
if __name__ == "__main__":
diff --git a/tox.ini b/tox.ini
index b1324cfcd..bf542a9b3 100644
--- a/tox.ini
+++ b/tox.ini
@@ -34,6 +34,7 @@ modules =
functest.cli
functest.core
functest.energy
+ functest.opnfv_tests.openstack.refstack_client
functest.opnfv_tests.openstack.snaps
functest.opnfv_tests.openstack.vping
functest.opnfv_tests.sdn.odl
@@ -43,6 +44,7 @@ modules =
functest.tests.unit.core
functest.tests.unit.energy
functest.tests.unit.odl
+ functest.tests.unit.openstack.refstack_client
functest.tests.unit.openstack.snaps
functest.tests.unit.openstack.vping
functest.tests.unit.vnf.router