From 0e4186c7cd788b09bff3ce164d9c55eba42f2048 Mon Sep 17 00:00:00 2001 From: kasar Date: Wed, 16 Aug 2017 23:40:41 -0700 Subject: [PATCH] System test framework : 1-Added pytests VMware fixture. 2- Added vmware vim test in test_vim.py Signed-off-by: kasar --- systest/conftest.py | 2 ++ systest/lib/vmware/__init__.py | 23 +++++++++++++++ systest/lib/vmware/fixtures.py | 47 +++++++++++++++++++++++++++++++ systest/lib/vmware/vmware.py | 30 ++++++++++++++++++++ systest/testcases/conftest.py | 1 + systest/testcases/vim/test_vim.py | 16 +++++++++++ 6 files changed, 119 insertions(+) create mode 100644 systest/lib/vmware/__init__.py create mode 100644 systest/lib/vmware/fixtures.py create mode 100644 systest/lib/vmware/vmware.py diff --git a/systest/conftest.py b/systest/conftest.py index 2032002d..4611f272 100644 --- a/systest/conftest.py +++ b/systest/conftest.py @@ -17,8 +17,10 @@ from lib.osm.fixtures import osm_add_options from lib.openstack.fixtures import openstack_add_options from lib.vim.fixtures import vim_add_options +from lib.vmware.fixtures import vmware_add_options def pytest_addoption(parser): osm_add_options(parser) openstack_add_options(parser) + vmware_add_options(parser) vim_add_options(parser) diff --git a/systest/lib/vmware/__init__.py b/systest/lib/vmware/__init__.py new file mode 100644 index 00000000..861d0b25 --- /dev/null +++ b/systest/lib/vmware/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +## +# Copyright 2016-2017 VMware Inc. +# This file is part of ETSI OSM +# All Rights Reserved. +# +# 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. +# +# For those usages not covered by the Apache License, Version 2.0 please +# contact: osslegalrouting@vmware.com +## + diff --git a/systest/lib/vmware/fixtures.py b/systest/lib/vmware/fixtures.py new file mode 100644 index 00000000..b81cdff0 --- /dev/null +++ b/systest/lib/vmware/fixtures.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- + +## +# Copyright 2016-2017 VMware Inc. +# This file is part of ETSI OSM +# All Rights Reserved. +# +# 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. +# +# For those usages not covered by the Apache License, Version 2.0 please +# contact: osslegalrouting@vmware.com +## + +import pytest +import json + + +def vmware_add_options(parser): + parser.addoption("--vcd-url", default="", help="VMware vCloud identity url") + parser.addoption("--vcd-username", default="", help="VMware vCloud username") + parser.addoption("--vcd-password", default="", help="VMware vCloud password") + parser.addoption("--vcd-tenant-name", default="", help="VMware vCloud tenant name") + parser.addoption("--config", default="", help="VMware vCloud config paramters") + +@pytest.fixture +def vmware(request): + from lib.vmware import vmware + access = {} + access['vcd-url'] = request.config.getoption("--vcd-url") + access['vcd-username'] = request.config.getoption("--vcd-username") + access['vcd-password'] = request.config.getoption("--vcd-password") + access['vcd-tenant-name'] = request.config.getoption("--vcd-tenant-name") + access['config'] = request.config.getoption("--config") + access['vim-type'] = 'vmware' + access['description'] = 'pytest system test' + + return vmware.Vmware(access) diff --git a/systest/lib/vmware/vmware.py b/systest/lib/vmware/vmware.py new file mode 100644 index 00000000..76c5412b --- /dev/null +++ b/systest/lib/vmware/vmware.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- + +## +# Copyright 2016-2017 VMware Inc. +# This file is part of ETSI OSM +# All Rights Reserved. +# +# 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. +# +# For those usages not covered by the Apache License, Version 2.0 please +# contact: osslegalrouting@vmware.com +## + + +class Vmware(): + def __init__(self,access): + self._os_access = access + + def get_access(self): + return self._os_access diff --git a/systest/testcases/conftest.py b/systest/testcases/conftest.py index 9f8be17c..481ce912 100644 --- a/systest/testcases/conftest.py +++ b/systest/testcases/conftest.py @@ -16,4 +16,5 @@ from lib.osm.fixtures import osm from lib.openstack.fixtures import openstack +from lib.vmware.fixtures import vmware from lib.vim.fixtures import vim diff --git a/systest/testcases/vim/test_vim.py b/systest/testcases/vim/test_vim.py index 5ea7077e..54325168 100644 --- a/systest/testcases/vim/test_vim.py +++ b/systest/testcases/vim/test_vim.py @@ -20,6 +20,7 @@ import time @pytest.mark.vim @pytest.mark.openstack +@pytest.mark.vmware class TestClass(object): def test_empty_vim(self,osm): @@ -48,3 +49,18 @@ class TestClass(object): assert resp['vim_tenants'][0]['vim_tenant_name'] == os_access['os-project-name'] assert not osm.get_api().vim.delete('pytest') + + @pytest.mark.vmware + def test_add_vim_account_vmware(self,osm,vmware,cleanup_test_add_vim_account): + os_access=vmware.get_access() + assert not osm.get_api().vim.create('pytest',os_access) + + resp=osm.get_api().vim.get('pytest') + assert resp['name'] == 'pytest' + assert resp['type'] == 'vmware' + assert resp['vim_url'] == os_access['vcd-url'] + assert resp['vim_url_admin'] == os_access['vcd-url'] + assert resp['vim_tenants'][0]['user'] == os_access['vcd-username'] + assert resp['vim_tenants'][0]['vim_tenant_name'] == os_access['vcd-tenant-name'] + + assert not osm.get_api().vim.delete('pytest') -- 2.25.1