From 28136ae1fdf430f2bc2e994fff6f8a91da30fd3c Mon Sep 17 00:00:00 2001 From: Santosh Kumar Kodicherla Date: Mon, 28 Mar 2016 19:49:36 +0000 Subject: [PATCH] Adding testcase for create and delete VIM Closes-Bug: #1558319 Depends-On: I7dd19a0c1ce948474bb3069073b3608ce265beb4 Change-Id: If701b4434ee5a24baa8bb0abff052e8e6a1bf418 --- tacker/tests/etc/samples/local-vim.yaml | 4 ++ tacker/tests/functional/{vnfm => }/base.py | 11 ++++ tacker/tests/functional/nfvo/__init__.py | 0 tacker/tests/functional/nfvo/test_vim.py | 59 +++++++++++++++++++ .../tests/functional/vnfm/test_tosca_vnf.py | 2 +- .../vnfm/test_tosca_vnf_multiple_vdu.py | 2 +- .../tests/functional/vnfm/test_tosca_vnfd.py | 2 +- tacker/tests/functional/vnfm/test_vnf.py | 2 +- .../functional/vnfm/test_vnf_monitoring.py | 2 +- .../functional/vnfm/test_vnf_multiple_vdu.py | 2 +- tacker/tests/functional/vnfm/test_vnfd.py | 2 +- .../tests/functional/vnfm/test_vnfm_param.py | 2 +- 12 files changed, 82 insertions(+), 8 deletions(-) create mode 100644 tacker/tests/etc/samples/local-vim.yaml rename tacker/tests/functional/{vnfm => }/base.py (88%) create mode 100644 tacker/tests/functional/nfvo/__init__.py create mode 100644 tacker/tests/functional/nfvo/test_vim.py diff --git a/tacker/tests/etc/samples/local-vim.yaml b/tacker/tests/etc/samples/local-vim.yaml new file mode 100644 index 000000000..abb55cdc2 --- /dev/null +++ b/tacker/tests/etc/samples/local-vim.yaml @@ -0,0 +1,4 @@ +auth_url: http://127.0.0.1:5000 +username: nfv_user +password: devstack +project_name: nfv diff --git a/tacker/tests/functional/vnfm/base.py b/tacker/tests/functional/base.py similarity index 88% rename from tacker/tests/functional/vnfm/base.py rename to tacker/tests/functional/base.py index 7387f7acd..f41de2b08 100644 --- a/tacker/tests/functional/vnfm/base.py +++ b/tacker/tests/functional/base.py @@ -118,3 +118,14 @@ class BaseTackerTest(base.TestCase): constants.ACTIVE_SLEEP_TIME) self.assertEqual(vnf_current_status, 'ACTIVE') self.validate_vnf_instance(vnfd_instance, vnf_instance) + + def verify_vim(self, vim_instance, config_data, name, description): + self.assertIsNotNone(vim_instance) + self.assertEqual(vim_instance['vim']['description'], description) + self.assertEqual(vim_instance['vim']['name'], name) + self.assertIsNotNone(vim_instance['vim']['tenant_id']) + self.assertIsNotNone(vim_instance['vim']['id']) + self.assertEqual(vim_instance['vim']['auth_cred']['username'], + config_data['username']) + self.assertEqual(vim_instance['vim']['auth_cred']['project_name'], + config_data['project_name']) diff --git a/tacker/tests/functional/nfvo/__init__.py b/tacker/tests/functional/nfvo/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tacker/tests/functional/nfvo/test_vim.py b/tacker/tests/functional/nfvo/test_vim.py new file mode 100644 index 000000000..826bf343d --- /dev/null +++ b/tacker/tests/functional/nfvo/test_vim.py @@ -0,0 +1,59 @@ +# Copyright 2016 Brocade Communications System, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from tacker.tests.functional import base +from tacker.tests.utils import read_file + +import yaml + + +class VimTestCreate(base.BaseTackerTest): + def _test_create_delete_vim(self, vim_file, name, + description, vim_type): + data = dict() + data = yaml.load(read_file(vim_file)) + + password = data['password'] + username = data['username'] + project_name = data['project_name'] + auth_url = data['auth_url'] + vim_arg = {'vim': {'name': name, 'description': description, + 'type': vim_type, + 'auth_url': auth_url, + 'auth_cred': {'username': username, + 'password': password}, + 'vim_project': {'name': project_name}}} + + # Register vim + vim_instance = self.client.create_vim(vim_arg) + vim_id = vim_instance['vim']['id'] + self.verify_vim(vim_instance, data, name, description) + + # Read vim + vim_instance_show = self.client.show_vim(vim_id) + self.verify_vim(vim_instance_show, data, name, description) + + # Delete vim + try: + self.client.delete_vim(vim_id) + except Exception: + assert False, ("Failed to delete vim %s" % + vim_id) + + def test_create_delete_local_vim(self): + name = 'Default vim' + description = 'Local vim description' + vim_type = 'openstack' + self._test_create_delete_vim( + 'local-vim.yaml', name, description, vim_type) diff --git a/tacker/tests/functional/vnfm/test_tosca_vnf.py b/tacker/tests/functional/vnfm/test_tosca_vnf.py index 2fa067bf3..d95531e45 100644 --- a/tacker/tests/functional/vnfm/test_tosca_vnf.py +++ b/tacker/tests/functional/vnfm/test_tosca_vnf.py @@ -15,7 +15,7 @@ from oslo_config import cfg from tacker.tests import constants -from tacker.tests.functional.vnfm import base +from tacker.tests.functional import base from tacker.tests.utils import read_file diff --git a/tacker/tests/functional/vnfm/test_tosca_vnf_multiple_vdu.py b/tacker/tests/functional/vnfm/test_tosca_vnf_multiple_vdu.py index f092c7e5c..e439fcb51 100644 --- a/tacker/tests/functional/vnfm/test_tosca_vnf_multiple_vdu.py +++ b/tacker/tests/functional/vnfm/test_tosca_vnf_multiple_vdu.py @@ -15,7 +15,7 @@ from oslo_config import cfg from tacker.common import utils from tacker.tests import constants -from tacker.tests.functional.vnfm import base +from tacker.tests.functional import base from tacker.tests.utils import read_file from tacker.vm.tosca import utils as toscautils diff --git a/tacker/tests/functional/vnfm/test_tosca_vnfd.py b/tacker/tests/functional/vnfm/test_tosca_vnfd.py index 9830b93bd..60b86a97a 100644 --- a/tacker/tests/functional/vnfm/test_tosca_vnfd.py +++ b/tacker/tests/functional/vnfm/test_tosca_vnfd.py @@ -14,7 +14,7 @@ from oslo_config import cfg -from tacker.tests.functional.vnfm import base +from tacker.tests.functional import base from tacker.tests.utils import read_file CONF = cfg.CONF diff --git a/tacker/tests/functional/vnfm/test_vnf.py b/tacker/tests/functional/vnfm/test_vnf.py index 5e292438d..4236b3ae7 100644 --- a/tacker/tests/functional/vnfm/test_vnf.py +++ b/tacker/tests/functional/vnfm/test_vnf.py @@ -15,7 +15,7 @@ from oslo_config import cfg from tacker.tests import constants -from tacker.tests.functional.vnfm import base +from tacker.tests.functional import base from tacker.tests.utils import read_file diff --git a/tacker/tests/functional/vnfm/test_vnf_monitoring.py b/tacker/tests/functional/vnfm/test_vnf_monitoring.py index b07139bc3..b0759f2a2 100644 --- a/tacker/tests/functional/vnfm/test_vnf_monitoring.py +++ b/tacker/tests/functional/vnfm/test_vnf_monitoring.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from tacker.tests.functional.vnfm import base +from tacker.tests.functional import base from tacker.tests.utils import read_file diff --git a/tacker/tests/functional/vnfm/test_vnf_multiple_vdu.py b/tacker/tests/functional/vnfm/test_vnf_multiple_vdu.py index 95303896c..72edf9041 100644 --- a/tacker/tests/functional/vnfm/test_vnf_multiple_vdu.py +++ b/tacker/tests/functional/vnfm/test_vnf_multiple_vdu.py @@ -15,7 +15,7 @@ from oslo_config import cfg from tacker.common import utils from tacker.tests import constants -from tacker.tests.functional.vnfm import base +from tacker.tests.functional import base from tacker.tests.utils import read_file import yaml diff --git a/tacker/tests/functional/vnfm/test_vnfd.py b/tacker/tests/functional/vnfm/test_vnfd.py index eb293ac93..95c3eb503 100644 --- a/tacker/tests/functional/vnfm/test_vnfd.py +++ b/tacker/tests/functional/vnfm/test_vnfd.py @@ -14,7 +14,7 @@ from oslo_config import cfg -from tacker.tests.functional.vnfm import base +from tacker.tests.functional import base from tacker.tests.utils import read_file CONF = cfg.CONF diff --git a/tacker/tests/functional/vnfm/test_vnfm_param.py b/tacker/tests/functional/vnfm/test_vnfm_param.py index f8950f767..8da6b9e02 100644 --- a/tacker/tests/functional/vnfm/test_vnfm_param.py +++ b/tacker/tests/functional/vnfm/test_vnfm_param.py @@ -13,7 +13,7 @@ # under the License. from tacker.tests import constants -from tacker.tests.functional.vnfm import base +from tacker.tests.functional import base from tacker.tests.utils import read_file import yaml