diff options
Diffstat (limited to 'functest')
27 files changed, 64 insertions, 77 deletions
diff --git a/functest/ci/run_tests.py b/functest/ci/run_tests.py index 37b90f92..5793c04a 100755 --- a/functest/ci/run_tests.py +++ b/functest/ci/run_tests.py @@ -144,7 +144,7 @@ def run_test(test, tier_name, testcases=None): try: module = importlib.import_module(run_dict['module']) cls = getattr(module, run_dict['class']) - test_case = cls() + test_case = cls(case_name=test_name) try: kwargs = run_dict['args'] diff --git a/functest/core/feature.py b/functest/core/feature.py index 325c10d4..5149f80f 100644 --- a/functest/core/feature.py +++ b/functest/core/feature.py @@ -8,10 +8,9 @@ from functest.utils.constants import CONST class Feature(base.TestCase): - def __init__(self, project='functest', case='', repo='', cmd=''): - super(Feature, self).__init__() + def __init__(self, project='functest', case_name='', repo='', cmd=''): + super(Feature, self).__init__(case_name=case_name) self.project_name = project - self.case_name = case self.cmd = cmd self.repo = CONST.__getattribute__(repo) self.result_file = self.get_result_file() diff --git a/functest/core/testcase.py b/functest/core/testcase.py index b540cfb5..8c5fd647 100644 --- a/functest/core/testcase.py +++ b/functest/core/testcase.py @@ -27,10 +27,10 @@ class TestCase(object): logger = ft_logger.Logger(__name__).getLogger() - def __init__(self): + def __init__(self, case_name=""): self.details = {} self.project_name = "functest" - self.case_name = "" + self.case_name = case_name self.criteria = "" self.start_time = "" self.stop_time = "" @@ -87,6 +87,7 @@ class TestCase(object): It could be overriden if the common implementation is not suitable. The following attributes must be set before pushing the results to DB: + * project_name, * case_name, * criteria, * start_time, diff --git a/functest/core/vnf_base.py b/functest/core/vnf_base.py index 3f0adcc6..3d3a441f 100644 --- a/functest/core/vnf_base.py +++ b/functest/core/vnf_base.py @@ -21,11 +21,10 @@ class VnfOnBoardingBase(base.TestCase): logger = ft_logger.Logger(__name__).getLogger() - def __init__(self, project='functest', case='', repo='', cmd=''): - super(VnfOnBoardingBase, self).__init__() + def __init__(self, project='functest', case_name='', repo='', cmd=''): + super(VnfOnBoardingBase, self).__init__(case_name=case_name) self.repo = repo self.project_name = project - self.case_name = case self.cmd = cmd self.details = {} self.result_dir = CONST.dir_results diff --git a/functest/opnfv_tests/features/barometer.py b/functest/opnfv_tests/features/barometer.py index 6011340f..8432bda4 100644 --- a/functest/opnfv_tests/features/barometer.py +++ b/functest/opnfv_tests/features/barometer.py @@ -18,7 +18,7 @@ class BarometerCollectd(base.Feature): def __init__(self): super(BarometerCollectd, self).__init__(project='barometer', - case='barometercollectd', + case_name='barometercollectd', repo='dir_repo_barometer') def execute(self): diff --git a/functest/opnfv_tests/features/copper.py b/functest/opnfv_tests/features/copper.py index 689341ea..6ed5e0ce 100644 --- a/functest/opnfv_tests/features/copper.py +++ b/functest/opnfv_tests/features/copper.py @@ -20,6 +20,6 @@ import functest.core.feature as base class Copper(base.Feature): def __init__(self): super(Copper, self).__init__(project='copper', - case='copper-notification', + case_name='copper-notification', repo='dir_repo_copper') self.cmd = 'cd %s/tests && bash run.sh && cd -' % self.repo diff --git a/functest/opnfv_tests/features/doctor.py b/functest/opnfv_tests/features/doctor.py index d32bbfc9..e35eadee 100644 --- a/functest/opnfv_tests/features/doctor.py +++ b/functest/opnfv_tests/features/doctor.py @@ -19,6 +19,6 @@ import functest.core.feature as base class Doctor(base.Feature): def __init__(self): super(Doctor, self).__init__(project='doctor', - case='doctor-notification', + case_name='doctor-notification', repo='dir_repo_doctor') self.cmd = 'cd %s/tests && ./run.sh' % self.repo diff --git a/functest/opnfv_tests/features/domino.py b/functest/opnfv_tests/features/domino.py index e34429bc..cf5f23d1 100644 --- a/functest/opnfv_tests/features/domino.py +++ b/functest/opnfv_tests/features/domino.py @@ -20,6 +20,6 @@ import functest.core.feature as base class Domino(base.Feature): def __init__(self): super(Domino, self).__init__(project='domino', - case='domino-multinode', + case_name='domino-multinode', repo='dir_repo_domino') self.cmd = 'cd %s && ./tests/run_multinode.sh' % self.repo diff --git a/functest/opnfv_tests/features/netready.py b/functest/opnfv_tests/features/netready.py index 88f377c2..7648a9b3 100644 --- a/functest/opnfv_tests/features/netready.py +++ b/functest/opnfv_tests/features/netready.py @@ -15,7 +15,7 @@ class GluonVping(base.Feature): def __init__(self): super(GluonVping, self).__init__(project='netready', - case='gluon_vping', + case_name='gluon_vping', repo='dir_repo_netready') dir_netready_functest = '{}/test/functest'.format(self.repo) self.cmd = ('cd %s && python ./gluon-test-suite.py' % diff --git a/functest/opnfv_tests/features/odl_sfc.py b/functest/opnfv_tests/features/odl_sfc.py index fff7f2b0..d3947e37 100644 --- a/functest/opnfv_tests/features/odl_sfc.py +++ b/functest/opnfv_tests/features/odl_sfc.py @@ -14,7 +14,7 @@ class OpenDaylightSFC(base.Feature): def __init__(self): super(OpenDaylightSFC, self).__init__(project='sfc', - case='functest-odl-sfc', + case_name='functest-odl-sfc', repo='dir_repo_sfc') dir_sfc_functest = '{}/sfc/tests/functest'.format(self.repo) self.cmd = 'cd %s && python ./run_tests.py' % dir_sfc_functest diff --git a/functest/opnfv_tests/features/promise.py b/functest/opnfv_tests/features/promise.py index a7f4e628..b76a1910 100644 --- a/functest/opnfv_tests/features/promise.py +++ b/functest/opnfv_tests/features/promise.py @@ -18,7 +18,7 @@ import functest.core.feature as base class Promise(base.Feature): def __init__(self): super(Promise, self).__init__(project='promise', - case='promise', + case_name='promise', repo='dir_repo_promise') dir_promise_functest = '{}/promise/test/functest'.format(self.repo) self.cmd = 'cd %s && python ./run_tests.py' % dir_promise_functest diff --git a/functest/opnfv_tests/features/sdnvpn.py b/functest/opnfv_tests/features/sdnvpn.py index 10e3146c..ea31f20a 100644 --- a/functest/opnfv_tests/features/sdnvpn.py +++ b/functest/opnfv_tests/features/sdnvpn.py @@ -14,7 +14,7 @@ class SdnVpnTests(base.Feature): def __init__(self): super(SdnVpnTests, self).__init__(project='sdnvpn', - case='bgpvpn', + case_name='bgpvpn', repo='dir_repo_sdnvpn') dir_sfc_functest = '{}/sdnvpn/test/functest'.format(self.repo) self.cmd = 'cd %s && python ./run_tests.py' % dir_sfc_functest diff --git a/functest/opnfv_tests/features/security_scan.py b/functest/opnfv_tests/features/security_scan.py index 2374b39f..3cde9d31 100644 --- a/functest/opnfv_tests/features/security_scan.py +++ b/functest/opnfv_tests/features/security_scan.py @@ -15,7 +15,7 @@ from functest.utils.constants import CONST class SecurityScan(base.Feature): def __init__(self): super(SecurityScan, self).__init__(project='securityscanning', - case='security_scan', + case_name='security_scan', repo='dir_repo_securityscan') self.cmd = ('. {0}/stackrc && ' 'cd {1} && ' diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py index 8c6abc15..1fe6143e 100644 --- a/functest/opnfv_tests/openstack/rally/rally.py +++ b/functest/opnfv_tests/openstack/rally/rally.py @@ -56,8 +56,8 @@ class RallyBase(testcase.TestCase): RALLY_PRIVATE_SUBNET_CIDR = CONST.rally_subnet_cidr RALLY_ROUTER_NAME = CONST.rally_router_name - def __init__(self): - super(RallyBase, self).__init__() + def __init__(self, case_name=''): + super(RallyBase, self).__init__(case_name) self.mode = '' self.summary = [] self.scenario_dir = '' diff --git a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py index 37aa9e39..2d04869a 100755 --- a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py +++ b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py @@ -25,9 +25,8 @@ logger = ft_logger.Logger("refstack_defcore").getLogger() class RefstackClient(testcase.TestCase): - def __init__(self): - super(RefstackClient, self).__init__() - self.case_name = "refstack_defcore" + def __init__(self, case_name="refstack_defcore"): + super(RefstackClient, self).__init__(case_name) self.FUNCTEST_TEST = CONST.dir_functest_test self.CONF_PATH = CONST.refstack_tempest_conf_path self.DEFCORE_LIST = CONST.refstack_defcore_list @@ -194,8 +193,8 @@ class RefstackClient(testcase.TestCase): class RefstackClientParser(testcase.TestCase): - def __init__(self): - super(RefstackClientParser, self).__init__() + def __init__(self, case_name=''): + super(RefstackClientParser, self).__init__(case_name) self.FUNCTEST_TEST = CONST.dir_functest_test self.CONF_PATH = CONST.refstack_tempest_conf_path self.DEFCORE_LIST = CONST.refstack_defcore_list diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py index 0addbd17..c3184e35 100644 --- a/functest/opnfv_tests/openstack/tempest/tempest.py +++ b/functest/opnfv_tests/openstack/tempest/tempest.py @@ -28,8 +28,8 @@ logger = ft_logger.Logger("Tempest").getLogger() class TempestCommon(testcase.TestCase): - def __init__(self): - super(TempestCommon, self).__init__() + def __init__(self, case_name=''): + super(TempestCommon, self).__init__(case_name) self.MODE = "" self.OPTION = "" self.VERIFIER_ID = conf_utils.get_verifier_id() @@ -234,35 +234,31 @@ class TempestCommon(testcase.TestCase): class TempestSmokeSerial(TempestCommon): - def __init__(self): - TempestCommon.__init__(self) - self.case_name = "tempest_smoke_serial" + def __init__(self, case_name='tempest_smoke_serial'): + TempestCommon.__init__(self, case_name) self.MODE = "smoke" self.OPTION = "--concurrency 1" class TempestSmokeParallel(TempestCommon): - def __init__(self): - TempestCommon.__init__(self) - self.case_name = "tempest_smoke_parallel" + def __init__(self, case_name='tempest_smoke_parallel'): + TempestCommon.__init__(self, case_name) self.MODE = "smoke" self.OPTION = "" class TempestFullParallel(TempestCommon): - def __init__(self): - TempestCommon.__init__(self) - self.case_name = "tempest_full_parallel" + def __init__(self, case_name="tempest_full_parallel"): + TempestCommon.__init__(self, case_name) self.MODE = "full" class TempestMultisite(TempestCommon): - def __init__(self): - TempestCommon.__init__(self) - self.case_name = "multisite" + def __init__(self, case_name="multisite"): + TempestCommon.__init__(self, case_name) self.MODE = "feature_multisite" self.OPTION = "--concurrency 1" conf_utils.install_verifier_ext(CONST.dir_repo_kingbird) @@ -270,17 +266,15 @@ class TempestMultisite(TempestCommon): class TempestCustom(TempestCommon): - def __init__(self): - TempestCommon.__init__(self) - self.case_name = "tempest_custom" + def __init__(self, case_name="tempest_custom"): + TempestCommon.__init__(self, case_name) self.MODE = "custom" self.OPTION = "--concurrency 1" class TempestDefcore(TempestCommon): - def __init__(self): - TempestCommon.__init__(self) - self.case_name = "tempest_defcore" + def __init__(self, case_name="tempest_defcore"): + TempestCommon.__init__(self, case_name) self.MODE = "defcore" self.OPTION = "--concurrency 1" diff --git a/functest/opnfv_tests/openstack/vping/vping_base.py b/functest/opnfv_tests/openstack/vping/vping_base.py index 584ded38..64cb0004 100644 --- a/functest/opnfv_tests/openstack/vping/vping_base.py +++ b/functest/opnfv_tests/openstack/vping/vping_base.py @@ -18,8 +18,8 @@ from functest.utils.constants import CONST class VPingBase(testcase.TestCase): - def __init__(self): - super(VPingBase, self).__init__() + def __init__(self, case_name=''): + super(VPingBase, self).__init__(case_name) self.logger = None self.functest_repo = CONST.dir_repo_functest self.repo = CONST.dir_vping diff --git a/functest/opnfv_tests/openstack/vping/vping_ssh.py b/functest/opnfv_tests/openstack/vping/vping_ssh.py index fc2f01c6..a68b0ff7 100755 --- a/functest/opnfv_tests/openstack/vping/vping_ssh.py +++ b/functest/opnfv_tests/openstack/vping/vping_ssh.py @@ -24,9 +24,8 @@ import functest.core.testcase as testcase class VPingSSH(vping_base.VPingBase): - def __init__(self): - super(VPingSSH, self).__init__() - self.case_name = 'vping_ssh' + def __init__(self, case_name='vping_ssh'): + super(VPingSSH, self).__init__(case_name) self.logger = ft_logger.Logger(self.case_name).getLogger() def do_vping(self, vm, test_ip): diff --git a/functest/opnfv_tests/openstack/vping/vping_userdata.py b/functest/opnfv_tests/openstack/vping/vping_userdata.py index fa91c12a..e9b86998 100755 --- a/functest/opnfv_tests/openstack/vping/vping_userdata.py +++ b/functest/opnfv_tests/openstack/vping/vping_userdata.py @@ -18,9 +18,8 @@ import vping_base class VPingUserdata(vping_base.VPingBase): - def __init__(self): - super(VPingUserdata, self).__init__() - self.case_name = 'vping_userdata' + def __init__(self, case_name='vping_userdata'): + super(VPingUserdata, self).__init__(case_name) self.logger = ft_logger.Logger(self.case_name).getLogger() def boot_vm_preparation(self, config, vmname, test_ip): diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py index ccc1101a..c0e2a9ae 100755 --- a/functest/opnfv_tests/sdn/odl/odl.py +++ b/functest/opnfv_tests/sdn/odl/odl.py @@ -72,10 +72,6 @@ class ODLTests(testcase.TestCase): res_dir = '/home/opnfv/functest/results/odl/' logger = ft_logger.Logger("opendaylight").getLogger() - def __init__(self): - testcase.TestCase.__init__(self) - self.case_name = "odl" - @classmethod def set_robotframework_vars(cls, odlusername="admin", odlpassword="admin"): """Set credentials in csit/variables/Variables.py. diff --git a/functest/opnfv_tests/sdn/onos/onos.py b/functest/opnfv_tests/sdn/onos/onos.py index d482ae32..fe37669a 100644 --- a/functest/opnfv_tests/sdn/onos/onos.py +++ b/functest/opnfv_tests/sdn/onos/onos.py @@ -32,9 +32,6 @@ class OnosBase(testcase.TestCase): onos_sfc_path = os.path.join(CONST.dir_repo_functest, CONST.dir_onos_sfc) - def __init__(self): - super(OnosBase, self).__init__() - def run(self): self.start_time = time.time() try: @@ -52,9 +49,8 @@ class OnosBase(testcase.TestCase): class Onos(OnosBase): - def __init__(self): - super(Onos, self).__init__() - self.case_name = 'onos' + def __init__(self, case_name='onos'): + super(Onos, self).__init__(case_name) self.log_path = os.path.join(self.onos_repo_path, 'TestON/logs') def set_onos_ip(self): diff --git a/functest/opnfv_tests/vnf/aaa/aaa.py b/functest/opnfv_tests/vnf/aaa/aaa.py index bdedcf7c..f80e7bcc 100755 --- a/functest/opnfv_tests/vnf/aaa/aaa.py +++ b/functest/opnfv_tests/vnf/aaa/aaa.py @@ -21,7 +21,7 @@ class AaaVnf(vnf_base.VnfOnBoardingBase): logger = ft_logger.Logger("VNF AAA").getLogger() def __init__(self): - super(AaaVnf, self).__init__(case="aaa") + super(AaaVnf, self).__init__(case_name="aaa") def deploy_orchestrator(self): self.logger.info("No VNFM needed to deploy a free radius here") @@ -56,6 +56,7 @@ class AaaVnf(vnf_base.VnfOnBoardingBase): kwargs = {} return self.main(**kwargs) + if __name__ == '__main__': parser = argparse.ArgumentParser() args = vars(parser.parse_args()) diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.py b/functest/opnfv_tests/vnf/ims/cloudify_ims.py index 404f208e..d739335d 100644 --- a/functest/opnfv_tests/vnf/ims/cloudify_ims.py +++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.py @@ -25,9 +25,9 @@ import functest.utils.openstack_utils as os_utils class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase): - def __init__(self, project='functest', case='cloudify_ims', + def __init__(self, project='functest', case_name='cloudify_ims', repo='', cmd=''): - super(CloudifyIms, self).__init__(project, case, repo, cmd) + super(CloudifyIms, self).__init__(project, case_name, repo, cmd) self.logger = ft_logger.Logger(__name__).getLogger() # Retrieve the configuration diff --git a/functest/opnfv_tests/vnf/ims/opera_ims.py b/functest/opnfv_tests/vnf/ims/opera_ims.py index d022b3c7..7ca96ae1 100644 --- a/functest/opnfv_tests/vnf/ims/opera_ims.py +++ b/functest/opnfv_tests/vnf/ims/opera_ims.py @@ -21,9 +21,9 @@ import functest.utils.functest_logger as ft_logger class OperaIms(clearwater_ims_base.ClearwaterOnBoardingBase): - def __init__(self, project='functest', case='opera_ims', + def __init__(self, project='functest', case_name='opera_ims', repo=CONST.dir_repo_opera, cmd=''): - super(OperaIms, self).__init__(project, case, repo, cmd) + super(OperaIms, self).__init__(project, case_name, repo, cmd) self.logger = ft_logger.Logger(__name__).getLogger() self.ellis_file = os.path.join(self.result_dir, 'ellis.info') self.live_test_file = os.path.join(self.result_dir, diff --git a/functest/opnfv_tests/vnf/ims/orchestra_ims.py b/functest/opnfv_tests/vnf/ims/orchestra_ims.py index 5c19be09..213d690d 100755 --- a/functest/opnfv_tests/vnf/ims/orchestra_ims.py +++ b/functest/opnfv_tests/vnf/ims/orchestra_ims.py @@ -78,9 +78,9 @@ def servertest(host, port): class ImsVnf(vnf_base.VnfOnBoardingBase): - def __init__(self, project='functest', case='orchestra_ims', + def __init__(self, project='functest', case_name='orchestra_ims', repo='', cmd=''): - super(ImsVnf, self).__init__(project, case, repo, cmd) + super(ImsVnf, self).__init__(project, case_name, repo, cmd) self.ob_password = "openbaton" self.ob_username = "admin" self.ob_https = False diff --git a/functest/tests/unit/core/test_testcase.py b/functest/tests/unit/core/test_testcase.py index 32104194..5ff41cd6 100644 --- a/functest/tests/unit/core/test_testcase.py +++ b/functest/tests/unit/core/test_testcase.py @@ -26,10 +26,11 @@ class TestCaseTesting(unittest.TestCase): logging.disable(logging.CRITICAL) + _case_name = "base" + def setUp(self): - self.test = testcase.TestCase() + self.test = testcase.TestCase(case_name=self._case_name) self.test.project = "functest" - self.test.case_name = "base" self.test.start_time = "1" self.test.stop_time = "2" self.test.criteria = "PASS" @@ -46,6 +47,10 @@ class TestCaseTesting(unittest.TestCase): testcase.TestCase.EX_PUSH_TO_DB_ERROR) mock_function.assert_not_called() + def test_missing_project_name(self): + self.test.project_name = None + self._test_missing_attribute() + def test_missing_case_name(self): self.test.case_name = None self._test_missing_attribute() @@ -69,7 +74,7 @@ class TestCaseTesting(unittest.TestCase): self.assertEqual(self.test.push_to_db(), testcase.TestCase.EX_OK) mock_function.assert_called_once_with( - self.test.project, self.test.case_name, self.test.start_time, + self.test.project, self._case_name, self.test.start_time, self.test.stop_time, self.test.criteria, self.test.details) @mock.patch('functest.utils.functest_utils.push_results_to_db', @@ -78,7 +83,7 @@ class TestCaseTesting(unittest.TestCase): self.assertEqual(self.test.push_to_db(), testcase.TestCase.EX_PUSH_TO_DB_ERROR) mock_function.assert_called_once_with( - self.test.project, self.test.case_name, self.test.start_time, + self.test.project, self._case_name, self.test.start_time, self.test.stop_time, self.test.criteria, self.test.details) @mock.patch('functest.utils.functest_utils.push_results_to_db', @@ -87,7 +92,7 @@ class TestCaseTesting(unittest.TestCase): self.assertEqual(self.test.push_to_db(), testcase.TestCase.EX_OK) mock_function.assert_called_once_with( - self.test.project, self.test.case_name, self.test.start_time, + self.test.project, self._case_name, self.test.start_time, self.test.stop_time, self.test.criteria, self.test.details) def test_check_criteria_missing(self): diff --git a/functest/tests/unit/core/test_vnf_base.py b/functest/tests/unit/core/test_vnf_base.py index 1680f03f..96706040 100644 --- a/functest/tests/unit/core/test_vnf_base.py +++ b/functest/tests/unit/core/test_vnf_base.py @@ -19,9 +19,8 @@ class VnfBaseTesting(unittest.TestCase): def setUp(self): self.test = vnf_base.VnfOnBoardingBase(project='functest', - case='aaa') + case_name='aaa') self.test.project = "functest" - self.test.case_name = "aaa" self.test.start_time = "1" self.test.stop_time = "5" self.test.criteria = "" |