Remove VnfOnBoarding 21/60321/4
authorCédric Ollivier <cedric.ollivier@orange.com>
Sun, 29 Jul 2018 19:40:20 +0000 (21:40 +0200)
committerCédric Ollivier <cedric.ollivier@orange.com>
Mon, 30 Jul 2018 00:22:45 +0000 (02:22 +0200)
All the vnfs are now inherating from scenarios.

Change-Id: I63509102067676ca0676b773db542086caa02d84
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
(cherry picked from commit 366adc757e3beaeb1db7811df511a0e38c3eee6d)

api/apidoc/functest.core.rst
api/apidoc/functest.core.vnf.rst [deleted file]
functest/core/vnf.py [deleted file]
functest/tests/unit/core/test_vnf.py [deleted file]
tox.ini

index c3aa54e..2dd6d46 100644 (file)
@@ -11,5 +11,3 @@ Submodules
 
 .. toctree::
 
-   functest.core.vnf
-
diff --git a/api/apidoc/functest.core.vnf.rst b/api/apidoc/functest.core.vnf.rst
deleted file mode 100644 (file)
index 9fd6b37..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-functest.core.vnf module
-========================
-
-.. automodule:: functest.core.vnf
-    :members:
-    :undoc-members:
-    :show-inheritance:
diff --git a/functest/core/vnf.py b/functest/core/vnf.py
deleted file mode 100644 (file)
index a6afd4e..0000000
+++ /dev/null
@@ -1,187 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright (c) 2016 Orange and others.
-#
-# 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
-
-"""Define the parent class of all VNF TestCases."""
-
-import logging
-import uuid
-
-from snaps.config.user import UserConfig
-from snaps.config.project import ProjectConfig
-from snaps.openstack.create_user import OpenStackUser
-from snaps.openstack.create_project import OpenStackProject
-from snaps.openstack.utils import keystone_utils
-from snaps.openstack.tests import openstack_tests
-
-from xtesting.core import vnf
-from functest.utils import constants
-
-__author__ = ("Morgan Richomme <morgan.richomme@orange.com>, "
-              "Valentin Boucher <valentin.boucher@orange.com>")
-
-
-class VnfPreparationException(vnf.VnfPreparationException):
-    """Raise when VNF preparation cannot be executed."""
-
-
-class OrchestratorDeploymentException(vnf.OrchestratorDeploymentException):
-    """Raise when orchestrator cannot be deployed."""
-
-
-class VnfDeploymentException(vnf.VnfDeploymentException):
-    """Raise when VNF cannot be deployed."""
-
-
-class VnfTestException(vnf.VnfTestException):
-    """Raise when VNF cannot be tested."""
-
-
-class VnfOnBoarding(vnf.VnfOnBoarding):
-    # pylint: disable=too-many-instance-attributes
-    """Base model for OpenStack VNF test cases."""
-
-    __logger = logging.getLogger(__name__)
-
-    def __init__(self, **kwargs):
-        super(VnfOnBoarding, self).__init__(**kwargs)
-        self.uuid = uuid.uuid4()
-        self.user_name = "{}-{}".format(self.case_name, self.uuid)
-        self.tenant_name = "{}-{}".format(self.case_name, self.uuid)
-        self.snaps_creds = {}
-        self.created_object = []
-        self.os_project = None
-        self.tenant_description = "Created by OPNFV Functest: {}".format(
-            self.case_name)
-
-    def prepare(self):
-        """
-        Prepare the environment for VNF testing:
-
-            * Creation of a user,
-            * Creation of a tenant,
-            * Allocation admin role to the user on this tenant
-
-        Returns base.TestCase.EX_OK if preparation is successfull
-
-        Raise VnfPreparationException in case of problem
-        """
-        try:
-            self.__logger.info(
-                "Prepare VNF: %s, description: %s", self.case_name,
-                self.tenant_description)
-            snaps_creds = openstack_tests.get_credentials(
-                os_env_file=constants.ENV_FILE)
-
-            self.os_project = OpenStackProject(
-                snaps_creds,
-                ProjectConfig(
-                    name=self.tenant_name,
-                    description=self.tenant_description,
-                    domain=snaps_creds.project_domain_name
-                ))
-            self.os_project.create()
-            self.created_object.append(self.os_project)
-
-            snaps_creds.project_domain_id = \
-                self.os_project.get_project().domain_id
-            snaps_creds.user_domain_id = \
-                self.os_project.get_project().domain_id
-
-            for role in ['admin', 'Admin']:
-                if keystone_utils.get_role_by_name(
-                        keystone_utils.keystone_client(snaps_creds), role):
-                    admin_role = role
-                    break
-
-            user_creator = OpenStackUser(
-                snaps_creds,
-                UserConfig(
-                    name=self.user_name,
-                    password=str(uuid.uuid4()),
-                    project_name=self.tenant_name,
-                    domain_name=snaps_creds.user_domain_name,
-                    roles={admin_role: self.tenant_name}))
-            user_creator.create()
-            self.created_object.append(user_creator)
-            self.snaps_creds = user_creator.get_os_creds(self.tenant_name)
-            self.__logger.debug("snaps creds: %s", self.snaps_creds)
-
-            return vnf.VnfOnBoarding.EX_OK
-        except Exception:  # pylint: disable=broad-except
-            self.__logger.exception("Exception raised during VNF preparation")
-            raise VnfPreparationException
-
-    def deploy_orchestrator(self):
-        """
-        Deploy an orchestrator (optional).
-
-        If this method is overriden then raise orchestratorDeploymentException
-        if error during orchestrator deployment
-        """
-        self.__logger.info("Deploy orchestrator (if necessary)")
-        return True
-
-    def deploy_vnf(self):
-        """
-        Deploy the VNF
-
-        This function MUST be implemented by vnf test cases.
-        The details section MAY be updated in the vnf test cases.
-
-        The deployment can be executed via a specific orchestrator
-        or using build-in orchestrators such as heat, OpenBaton, cloudify,
-        juju, onap, ...
-
-        Returns:
-            True if the VNF is properly deployed
-            False if the VNF is not deployed
-
-        Raise VnfDeploymentException if error during VNF deployment
-        """
-        self.__logger.error("VNF must be deployed")
-        raise VnfDeploymentException
-
-    def test_vnf(self):
-        """
-        Test the VNF
-
-        This function MUST be implemented by vnf test cases.
-        The details section MAY be updated in the vnf test cases.
-
-        Once a VNF is deployed, it is assumed that specific test suite can be
-        run to validate the VNF.
-        Please note that the same test suite can be used on several test case
-        (e.g. clearwater test suite can be used whatever the orchestrator used
-        for the deployment)
-
-        Returns:
-            True if VNF tests are PASS
-            False if test suite is FAIL
-
-        Raise VnfTestException if error during VNF test
-        """
-        self.__logger.error("VNF must be tested")
-        raise VnfTestException
-
-    def clean(self):
-        """
-        Clean VNF test case.
-
-        It is up to the test providers to delete resources used for the tests.
-        By default we clean:
-
-            * the user,
-            * the tenant
-        """
-        self.__logger.info('Removing the VNF resources ..')
-        for creator in reversed(self.created_object):
-            try:
-                creator.clean()
-            except Exception as exc:  # pylint: disable=broad-except
-                self.__logger.error('Unexpected error cleaning - %s', exc)
diff --git a/functest/tests/unit/core/test_vnf.py b/functest/tests/unit/core/test_vnf.py
deleted file mode 100644 (file)
index 81d9eef..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright (c) 2016 Orange and others.
-#
-# 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
-
-# pylint: disable=missing-docstring
-
-import logging
-import unittest
-
-import mock
-from snaps.openstack.os_credentials import OSCreds
-from xtesting.core import testcase
-
-from functest.core import vnf
-from functest.utils import constants
-
-
-class VnfBaseTesting(unittest.TestCase):
-    """The class testing VNF."""
-    # pylint: disable=missing-docstring,too-many-public-methods
-
-    tenant_name = 'test_tenant_name'
-    tenant_description = 'description'
-
-    def setUp(self):
-        self.test = vnf.VnfOnBoarding(project='functest', case_name='foo')
-
-    def test_run_deploy_orch_exc(self):
-        with mock.patch.object(self.test, 'prepare'), \
-                mock.patch.object(self.test, 'deploy_orchestrator',
-                                  side_effect=Exception) as mock_method, \
-                mock.patch.object(self.test, 'deploy_vnf',
-                                  return_value=True), \
-                mock.patch.object(self.test, 'test_vnf',
-                                  return_value=True):
-            self.assertEqual(self.test.run(),
-                             testcase.TestCase.EX_TESTCASE_FAILED)
-            mock_method.assert_called_with()
-
-    def test_run_deploy_vnf_exc(self):
-        with mock.patch.object(self.test, 'prepare'),\
-            mock.patch.object(self.test, 'deploy_orchestrator',
-                              return_value=True), \
-            mock.patch.object(self.test, 'deploy_vnf',
-                              side_effect=Exception) as mock_method:
-            self.assertEqual(self.test.run(),
-                             testcase.TestCase.EX_TESTCASE_FAILED)
-            mock_method.assert_called_with()
-
-    def test_run_test_vnf_exc(self):
-        with mock.patch.object(self.test, 'prepare'),\
-            mock.patch.object(self.test, 'deploy_orchestrator',
-                              return_value=True), \
-            mock.patch.object(self.test, 'deploy_vnf', return_value=True), \
-            mock.patch.object(self.test, 'test_vnf',
-                              side_effect=Exception) as mock_method:
-            self.assertEqual(self.test.run(),
-                             testcase.TestCase.EX_TESTCASE_FAILED)
-            mock_method.assert_called_with()
-
-    def test_run_deploy_orch_ko(self):
-        with mock.patch.object(self.test, 'prepare'),\
-                mock.patch.object(self.test, 'deploy_orchestrator',
-                                  return_value=False), \
-                mock.patch.object(self.test, 'deploy_vnf',
-                                  return_value=True), \
-                mock.patch.object(self.test, 'test_vnf',
-                                  return_value=True):
-            self.assertEqual(self.test.run(),
-                             testcase.TestCase.EX_TESTCASE_FAILED)
-
-    def test_run_vnf_deploy_ko(self):
-        with mock.patch.object(self.test, 'prepare'),\
-                mock.patch.object(self.test, 'deploy_orchestrator',
-                                  return_value=True), \
-                mock.patch.object(self.test, 'deploy_vnf',
-                                  return_value=False), \
-                mock.patch.object(self.test, 'test_vnf',
-                                  return_value=True):
-            self.assertEqual(self.test.run(),
-                             testcase.TestCase.EX_TESTCASE_FAILED)
-
-    def test_run_vnf_test_ko(self):
-        with mock.patch.object(self.test, 'prepare'),\
-                mock.patch.object(self.test, 'deploy_orchestrator',
-                                  return_value=True), \
-                mock.patch.object(self.test, 'deploy_vnf',
-                                  return_value=True), \
-                mock.patch.object(self.test, 'test_vnf',
-                                  return_value=False):
-            self.assertEqual(self.test.run(),
-                             testcase.TestCase.EX_TESTCASE_FAILED)
-
-    def test_run_default(self):
-        with mock.patch.object(self.test, 'prepare'),\
-                mock.patch.object(self.test, 'deploy_orchestrator',
-                                  return_value=True), \
-                mock.patch.object(self.test, 'deploy_vnf',
-                                  return_value=True), \
-                mock.patch.object(self.test, 'test_vnf',
-                                  return_value=True):
-            self.assertEqual(self.test.run(), testcase.TestCase.EX_OK)
-
-    @mock.patch('functest.core.vnf.OpenStackUser')
-    @mock.patch('functest.core.vnf.OpenStackProject')
-    @mock.patch('snaps.openstack.tests.openstack_tests.get_credentials',
-                side_effect=Exception)
-    def test_prepare_exc1(self, *args):
-        with self.assertRaises(Exception):
-            self.test.prepare()
-        args[0].assert_called_with(os_env_file=constants.ENV_FILE)
-        args[1].assert_not_called()
-        args[2].assert_not_called()
-
-    @mock.patch('functest.core.vnf.OpenStackUser')
-    @mock.patch('functest.core.vnf.OpenStackProject', side_effect=Exception)
-    @mock.patch('snaps.openstack.tests.openstack_tests.get_credentials')
-    def test_prepare_exc2(self, *args):
-        with self.assertRaises(Exception):
-            self.test.prepare()
-        args[0].assert_called_with(os_env_file=constants.ENV_FILE)
-        args[1].assert_called_with(mock.ANY, mock.ANY)
-        args[2].assert_not_called()
-
-    @mock.patch('functest.core.vnf.OpenStackUser', side_effect=Exception)
-    @mock.patch('snaps.openstack.utils.keystone_utils.get_role_by_name',
-                return_value="admin")
-    @mock.patch('snaps.openstack.utils.keystone_utils.keystone_client')
-    @mock.patch('functest.core.vnf.OpenStackProject')
-    @mock.patch('snaps.openstack.tests.openstack_tests.get_credentials')
-    def test_prepare_exc3(self, *args):
-        with self.assertRaises(Exception):
-            self.test.prepare()
-        args[0].assert_called_with(os_env_file=constants.ENV_FILE)
-        args[1].assert_called_with(mock.ANY, mock.ANY)
-        args[2].assert_called_with(mock.ANY)
-        args[3].assert_called_with(mock.ANY, mock.ANY)
-        args[4].assert_called_with(mock.ANY, mock.ANY)
-
-    @mock.patch('functest.core.vnf.OpenStackUser')
-    @mock.patch('snaps.openstack.utils.keystone_utils.get_role_by_name',
-                return_value="admin")
-    @mock.patch('snaps.openstack.utils.keystone_utils.keystone_client')
-    @mock.patch('functest.core.vnf.OpenStackProject')
-    @mock.patch('snaps.openstack.tests.openstack_tests.get_credentials')
-    def test_prepare_default(self, *args):
-        self.assertEqual(self.test.prepare(), testcase.TestCase.EX_OK)
-        args[0].assert_called_with(os_env_file=constants.ENV_FILE)
-        args[1].assert_called_with(mock.ANY, mock.ANY)
-        args[2].assert_called_with(mock.ANY)
-        args[3].assert_called_with(mock.ANY, mock.ANY)
-        args[4].assert_called_with(mock.ANY, mock.ANY)
-
-    def test_deploy_vnf_unimplemented(self):
-        with self.assertRaises(vnf.VnfDeploymentException):
-            self.test.deploy_vnf()
-
-    def test_test_vnf_unimplemented(self):
-        with self.assertRaises(vnf.VnfTestException):
-            self.test.test_vnf()
-
-    def test_deploy_orch_unimplemented(self):
-        self.assertTrue(self.test.deploy_orchestrator())
-
-    @mock.patch('snaps.openstack.tests.openstack_tests.get_credentials',
-                return_value=OSCreds(
-                    username='user', password='pass',
-                    auth_url='http://foo.com:5000/v3', project_name='bar'),
-                side_effect=Exception)
-    def test_prepare_keystone_client_ko(self, *args):
-        with self.assertRaises(vnf.VnfPreparationException):
-            self.test.prepare()
-        args[0].assert_called_once()
-
-    def test_vnf_clean_exc(self):
-        obj = mock.Mock()
-        obj.clean.side_effect = Exception
-        self.test.created_object = [obj]
-        self.test.clean()
-        obj.clean.assert_called_with()
-
-    def test_vnf_clean(self):
-        obj = mock.Mock()
-        self.test.created_object = [obj]
-        self.test.clean()
-        obj.clean.assert_called_with()
-
-
-if __name__ == "__main__":
-    logging.disable(logging.CRITICAL)
-    unittest.main(verbosity=2)
diff --git a/tox.ini b/tox.ini
index e196d42..66dd20b 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -99,7 +99,6 @@ commands =
 dirs =
   functest/tests/unit/ci
   functest/tests/unit/cli
-  functest/tests/unit/core
   functest/tests/unit/odl
   functest/tests/unit/openstack
   functest/tests/unit/utils