diff options
-rw-r--r-- | docker/vnf/testcases.yaml | 29 | ||||
-rw-r--r-- | functest/ci/testcases.yaml | 29 | ||||
-rw-r--r-- | functest/opnfv_tests/sdn/odl/odl.py | 27 | ||||
-rw-r--r-- | functest/tests/unit/odl/test_odl.py | 23 |
4 files changed, 62 insertions, 46 deletions
diff --git a/docker/vnf/testcases.yaml b/docker/vnf/testcases.yaml index 54e5f292..eccabbe5 100644 --- a/docker/vnf/testcases.yaml +++ b/docker/vnf/testcases.yaml @@ -20,6 +20,21 @@ tiers: run: module: 'functest.opnfv_tests.vnf.ims.cloudify_ims' class: 'CloudifyIms' + + - + case_name: vyos_vrouter + project_name: functest + criteria: 100 + blocking: false + description: >- + This test case is vRouter testing. + dependencies: + installer: '^((?!compass|fuel).)*$' + scenario: 'os-nosdn-nofeature-ha' + run: + module: 'functest.opnfv_tests.vnf.router.cloudify_vrouter' + class: 'CloudifyVrouter' + - case_name: orchestra_openims project_name: orchestra @@ -47,17 +62,3 @@ tiers: run: module: 'functest.opnfv_tests.vnf.ims.orchestra_clearwaterims' class: 'ClearwaterImsVnf' - - - - case_name: vyos_vrouter - project_name: functest - criteria: 100 - blocking: false - description: >- - This test case is vRouter testing. - dependencies: - installer: '' - scenario: 'os-nosdn-nofeature-ha' - run: - module: 'functest.opnfv_tests.vnf.router.cloudify_vrouter' - class: 'CloudifyVrouter' diff --git a/functest/ci/testcases.yaml b/functest/ci/testcases.yaml index 1d20a920..0759fc0e 100644 --- a/functest/ci/testcases.yaml +++ b/functest/ci/testcases.yaml @@ -356,6 +356,21 @@ tiers: run: module: 'functest.opnfv_tests.vnf.ims.cloudify_ims' class: 'CloudifyIms' + + - + case_name: vyos_vrouter + project_name: functest + criteria: 100 + blocking: false + description: >- + This test case is vRouter testing. + dependencies: + installer: '^((?!compass|fuel).)*$' + scenario: 'os-nosdn-nofeature-ha' + run: + module: 'functest.opnfv_tests.vnf.router.cloudify_vrouter' + class: 'CloudifyVrouter' + - case_name: orchestra_openims project_name: orchestra @@ -383,17 +398,3 @@ tiers: run: module: 'functest.opnfv_tests.vnf.ims.orchestra_clearwaterims' class: 'ClearwaterImsVnf' - - - - case_name: vyos_vrouter - project_name: functest - criteria: 100 - blocking: false - description: >- - This test case is vRouter testing. - dependencies: - installer: '' - scenario: 'os-nosdn-nofeature-ha' - run: - module: 'functest.opnfv_tests.vnf.router.cloudify_vrouter' - class: 'CloudifyVrouter' diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py index de723d19..6c05c018 100644 --- a/functest/opnfv_tests/sdn/odl/odl.py +++ b/functest/opnfv_tests/sdn/odl/odl.py @@ -38,11 +38,13 @@ class ODLTests(robotframework.RobotFramework): """ODL test runner.""" odl_test_repo = constants.CONST.__getattribute__('dir_repo_odl_test') - neutron_suite_dir = os.path.join(odl_test_repo, - "csit/suites/openstack/neutron") - basic_suite_dir = os.path.join(odl_test_repo, - "csit/suites/integration/basic") + neutron_suite_dir = os.path.join( + odl_test_repo, "csit/suites/openstack/neutron") + basic_suite_dir = os.path.join( + odl_test_repo, "csit/suites/integration/basic") default_suites = [basic_suite_dir, neutron_suite_dir] + odl_variables_file = os.path.join( + odl_test_repo, 'csit/variables/Variables.robot') __logger = logging.getLogger(__name__) def __init__(self, **kwargs): @@ -59,18 +61,17 @@ class ODLTests(robotframework.RobotFramework): True if credentials are set. False otherwise. """ - odl_variables_files = os.path.join(cls.odl_test_repo, - 'csit/variables/Variables.robot') + try: - for line in fileinput.input(odl_variables_files, + for line in fileinput.input(cls.odl_variables_file, inplace=True): print(re.sub("@{AUTH}.*", "@{{AUTH}} {} {}".format( odlusername, odlpassword), line.rstrip())) return True - except Exception as ex: # pylint: disable=broad-except - cls.__logger.error("Cannot set ODL creds: %s", str(ex)) + except Exception: # pylint: disable=broad-except + cls.__logger.exception("Cannot set ODL creds:") return False def run_suites(self, suites=None, **kwargs): @@ -128,10 +129,12 @@ class ODLTests(robotframework.RobotFramework): except KeyError: self.__logger.exception("Cannot run ODL testcases. Please check") return self.EX_RUN_ERROR - if self.set_robotframework_vars(odlusername, odlpassword): - return super(ODLTests, self).run(variable=variable, suites=suites) + if not os.path.isfile(self.odl_variables_file): + self.__logger.info("Skip writting ODL creds") else: - return self.EX_RUN_ERROR + if not self.set_robotframework_vars(odlusername, odlpassword): + return self.EX_RUN_ERROR + return super(ODLTests, self).run(variable=variable, suites=suites) def run(self, **kwargs): """Run suites in OPNFV environment diff --git a/functest/tests/unit/odl/test_odl.py b/functest/tests/unit/odl/test_odl.py index ff25cd7a..1a3f7950 100644 --- a/functest/tests/unit/odl/test_odl.py +++ b/functest/tests/unit/odl/test_odl.py @@ -154,7 +154,7 @@ class ODLMainTesting(ODLTesting): kwargs = self._get_run_suites_kwargs() self.assertEqual(self.test.run_suites(**kwargs), status) if len(args) > 0: - args[0].assert_called_once_with(self.test.res_dir) + args[0].assert_called_once_with(self.test.odl_variables_file) if len(args) > 1: variable = [ 'KEYSTONEURL:{}://{}'.format( @@ -214,15 +214,17 @@ class ODLMainTesting(ODLTesting): def test_no_odlrestconfport(self): self._test_no_keyword('odlrestconfport') - def test_set_vars_ko(self): + @mock.patch('os.path.isfile', return_value=True) + def test_set_vars_ko(self, *args): with mock.patch.object(self.test, 'set_robotframework_vars', return_value=False) as mock_object: self._test_run_suites(testcase.TestCase.EX_RUN_ERROR) mock_object.assert_called_once_with( self._odl_username, self._odl_password) + args[0].assert_called_once_with(self.test.odl_variables_file) @mock.patch('robot.run', side_effect=RobotError) - @mock.patch('os.makedirs') + @mock.patch('os.path.isfile', return_value=True) def test_run_ko(self, *args): with mock.patch.object(self.test, 'set_robotframework_vars', return_value=True), \ @@ -230,7 +232,7 @@ class ODLMainTesting(ODLTesting): self._test_run_suites(testcase.TestCase.EX_RUN_ERROR, *args) @mock.patch('robot.run') - @mock.patch('os.makedirs') + @mock.patch('os.path.isfile', return_value=True) def test_parse_results_ko(self, *args): with mock.patch.object(self.test, 'set_robotframework_vars', return_value=True), \ @@ -239,15 +241,24 @@ class ODLMainTesting(ODLTesting): self._test_run_suites(testcase.TestCase.EX_RUN_ERROR, *args) @mock.patch('robot.run') - @mock.patch('os.makedirs') + @mock.patch('os.path.isfile', return_value=True) def test_ok(self, *args): with mock.patch.object(self.test, 'set_robotframework_vars', return_value=True), \ mock.patch.object(self.test, 'parse_results'): self._test_run_suites(testcase.TestCase.EX_OK, *args) + @mock.patch('robot.run') + @mock.patch('os.path.isfile', return_value=False) + def test_ok_no_creds(self, *args): + with mock.patch.object(self.test, 'set_robotframework_vars', + return_value=True) as mock_method, \ + mock.patch.object(self.test, 'parse_results'): + self._test_run_suites(testcase.TestCase.EX_OK, *args) + mock_method.assert_not_called() + @mock.patch('robot.run', return_value=1) - @mock.patch('os.makedirs') + @mock.patch('os.path.isfile', return_value=True) def test_testcases_in_failure(self, *args): with mock.patch.object(self.test, 'set_robotframework_vars', return_value=True), \ |