--- /dev/null
+*.pyc
+.cache
--- /dev/null
+pytest-output.xml
+*.pyc
+.cache
+descriptor-packages/
+*.xml
--- /dev/null
+# Copyright 2017 Sandvine
+# 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.
+
+#
+# These variables need to be defined in environment or passed in
+# the make invocation.
+# eg.
+# export OSM_HOSTNAME=1.2.3.4:8008
+# export OS_URL=https://<keystoneserver>:5000/v2.0
+# export OS_USERNAME=admin
+# export OS_PASSWORD=admin
+# export OS_PROJECT_NAME=admin
+OSM_HOSTNAME ?=
+OS_URL ?=
+OS_USERNAME ?=
+OS_PASSWORD_NAME ?=
+OS_PROJECT_NAME ?=
+
+ifdef OS_URL
+ OPTION_OS_URL=--os-url $(OS_URL)
+endif
+ifdef OS_USERNAME
+ OPTION_OS_USERNAME=--os-username $(OS_USERNAME)
+endif
+ifdef OS_PASSWORD
+ OPTION_OS_PASSWORD=--os-password $(OS_PASSWORD)
+endif
+ifdef OS_PROJECT_NAME
+ OPTION_OS_PROJECT_NAME=--os-project-name $(OS_PROJECT_NAME)
+endif
+
+ifdef TEST_VNFD_DESCRIPTORS
+ OPTION_TEST_VNFD_DESCRIPTORS=--osm-vnfd-descriptor-packages $(TEST_VNFD_DESCRIPTORS)
+endif
+ifdef TEST_NSD_DESCRIPTORS
+ OPTION_TEST_NSD_DESCRIPTORS=--osm-nsd-descriptor-packages $(TEST_NSD_DESCRIPTORS)
+endif
+
+DESCRIPTOR_REPO_NAME=descriptor-packages
+DESCRIPTOR_BUILD_DIR := $(shell pwd)/$(DESCRIPTOR_REPO_NAME)/build
+OPTION_DESCRIPTOR_BUILD_DIR=--osm-descriptor-packages $(DESCRIPTOR_BUILD_DIR)
+
+TEST_OSM_NS_NAME_PREFIX=pytest-$(shell date +%D-%T)-
+OPTION_TEST_OSM_NS_NAME_PREFIX=--osm-ns-name-prefix $(TEST_OSM_NS_NAME_PREFIX)
+
+JUNITXML_DIR = reports
+
+JUNITXML ?= pytest-output.xml
+
+PYTEST_OPTIONS=
+Q=@
+
+DESCRIPTOR_REPO ?= https://osm.etsi.org/gerrit/osm/$(DESCRIPTOR_REPO_NAME)
+
+
+TEST_VNFD_DESCRIPTORS ?= None
+TEST_NSD_DESCRIPTORS ?= None
+
+.NOTPARALLEL:
+all: smoke cirros ping_pong
+
+define check_env_var
+ $(Q)if [ -z "$($(1))" ]; then echo "error: $(1) not set"; exit 1; fi
+endef
+
+check_OSM_HOSTNAME:
+ $(call check_env_var,OSM_HOSTNAME)
+
+check_openstack_env:
+ $(call check_env_var,OS_URL)
+ $(call check_env_var,OS_USERNAME)
+ $(call check_env_var,OS_PASSWORD)
+ $(call check_env_var,OS_PROJECT_NAME)
+
+.PHONY: check_openstack_env check_OSM_HOSTNAME
+
+$(DESCRIPTOR_REPO_NAME):
+ @test -e $(DESCRIPTOR_REPO_NAME) || git clone $(DESCRIPTOR_REPO)
+ make -C $(DESCRIPTOR_REPO_NAME)
+
+report_dir:
+ @mkdir -p reports
+
+_run_test: $(DESCRIPTOR_REPO_NAME) report_dir
+ $(Q)py.test \
+ --osmhost $(OSM_HOSTNAME) \
+ $(OPTION_OS_URL) \
+ $(OPTION_OS_USERNAME) \
+ $(OPTION_OS_PASSWORD) \
+ $(OPTION_OS_PROJECT_NAME) \
+ $(OPTION_TEST_VNFD_DESCRIPTORS) \
+ $(OPTION_TEST_NSD_DESCRIPTORS) \
+ $(OPTION_DESCRIPTOR_BUILD_DIR) \
+ $(OPTION_TEST_OSM_NS_NAME_PREFIX) \
+ --junitxml $(JUNITXML_DIR)/$(JUNITXML) \
+ $(PYTEST_OPTIONS)
+
+cirros: check_OSM_HOSTNAME check_openstack_env
+ $(Q)$(MAKE) \
+ TEST_VNFD_DESCRIPTORS=$(DESCRIPTOR_BUILD_DIR)/vnfd_pkgs/cirros_vnf.tar.gz \
+ TEST_NSD_DESCRIPTORS=$(DESCRIPTOR_BUILD_DIR)/nsd_pkgs/cirros_ns.tar.gz \
+ JUNITXML=pytest-$@.xml \
+ PYTEST_OPTIONS="$(PYTEST_OPTIONS) -m vnf" _run_test
+
+smoke: check_OSM_HOSTNAME
+ $(Q)$(MAKE) \
+ JUNITXML=pytest-$@.xml \
+ PYTEST_OPTIONS="$(PYTEST_OPTIONS) -m smoke" _run_test
+
+vim: check_OSM_HOSTNAME check_openstack_env
+ $(Q)$(MAKE) \
+ JUNITXML=pytest-$@.xml \
+ PYTEST_OPTIONS="$(PYTEST_OPTIONS) -m vim" _run_test
+
+ping_pong: check_OSM_HOSTNAME check_openstack_env
+ $(Q)$(MAKE) \
+ TEST_VNFD_DESCRIPTORS="$(DESCRIPTOR_BUILD_DIR)/vnfd_pkgs/ping_vnf.tar.gz,$(DESCRIPTOR_BUILD_DIR)/vnfd_pkgs/pong_vnf.tar.gz" \
+ TEST_NSD_DESCRIPTORS="$(DESCRIPTOR_BUILD_DIR)/nsd_pkgs/ping_pong_ns.tar.gz" \
+ JUNITXML=pytest-$@.xml \
+ PYTEST_OPTIONS="$(PYTEST_OPTIONS) -m vnf" _run_test
+
+.PHONY: report_dir cirros vim smoke ping_pong
--- /dev/null
+# Copyright 2017 Sandvine
+#
+# 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.
+
+from lib.osm.fixtures import osm_add_options
+from lib.openstack.fixtures import openstack_add_options
+from lib.vim.fixtures import vim_add_options
+
+def pytest_addoption(parser):
+ osm_add_options(parser)
+ openstack_add_options(parser)
+ vim_add_options(parser)
--- /dev/null
+# Copyright 2017 Sandvine
+#
+# 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.
--- /dev/null
+# Copyright 2017 Sandvine
+#
+# 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.
+
+import pytest
+import json
+
+
+def openstack_add_options(parser):
+ parser.addoption("--os-url", default="", help="openstack identity url")
+ parser.addoption("--os-username", default="", help="openstack username")
+ parser.addoption("--os-password", default="", help="openstack password")
+ parser.addoption("--os-project-name", default="", help="openstack project name")
+
+@pytest.fixture
+def openstack(request):
+ from lib.openstack import openstack
+ access = {}
+ access['os-url'] = request.config.getoption("--os-url")
+ access['os-username'] = request.config.getoption("--os-username")
+ access['os-password'] = request.config.getoption("--os-password")
+ access['os-project-name'] = request.config.getoption("--os-project-name")
+ access['vim-type'] = 'openstack'
+ access['description'] = 'pytest system test'
+
+ return openstack.Openstack(access)
--- /dev/null
+# Copyright 2017 Sandvine
+#
+# 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.
+
+
+class Openstack():
+ def __init__(self,access):
+ self._os_access = access
+
+ def get_access(self):
+ return self._os_access
--- /dev/null
+# Copyright 2017 Sandvine
+#
+# 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.
--- /dev/null
+# Copyright 2017 Sandvine
+#
+# 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.
+
+import pytest
+import json
+
+
+def osm_add_options(parser):
+ parser.addoption("--osmhost", default="", help="osm hostname")
+ parser.addoption("--osm-descriptor-packages", default="", help="location of descriptor packages")
+ parser.addoption("--osm-vnfd-descriptor-packages", default="", help="vnfd packages to test")
+ parser.addoption("--osm-nsd-descriptor-packages", default="", help="nsd package to test")
+ parser.addoption("--osmfile", action="store", default="", help="osm json data file")
+ parser.addoption("--osm-ns-name-prefix", action="store", default="", help="ns name prefix to apply")
+
+'''
+@pytest.fixture
+def osm(request):
+ from osmclient.common import OsmAPI
+ with open(request.config.getoption("--osm")) as json_data:
+ osmdict=json.load(json_data)
+ return OsmAPI.OsmAPI(osmdict['ip'])
+
+'''
+
+@pytest.fixture
+def osm(request):
+ from lib.osm import osm
+ osmhost=request.config.getoption("--osmhost")
+ descriptors_dir=request.config.getoption("--osm-descriptor-packages")
+ vnfd_descriptors_list=request.config.getoption("--osm-vnfd-descriptor-packages").split(',')
+ nsd_descriptors_list=request.config.getoption("--osm-nsd-descriptor-packages").split(',')
+ ns_name_prefix=request.config.getoption("--osm-ns-name-prefix")
+ return osm.Osm(osmhost,
+ descriptors_dir=descriptors_dir,
+ vnfd_descriptors_list=vnfd_descriptors_list,
+ nsd_descriptors_list=nsd_descriptors_list,
+ ns_name_prefix=ns_name_prefix)
--- /dev/null
+# Copyright 2017 Sandvine
+#
+# 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.
+
+
+from osmclient.client import client
+
+class Osm():
+ def __init__(self,osmhost,descriptors_dir=None,vnfd_descriptors_list=None,nsd_descriptors_list=None,ns_name_prefix=None):
+ self._OsmApi=client.Client(host=osmhost)
+ self._descriptors_dir = descriptors_dir
+ self.vnfd_descriptors_list = vnfd_descriptors_list
+ self.nsd_descriptors_list = nsd_descriptors_list
+ self.ns_name_prefix = ns_name_prefix
+
+ def get_api(self):
+ return self._OsmApi
+
+ def get_descriptors_dir(self):
+ return self._descriptors_dir
--- /dev/null
+# Copyright 2017 Sandvine
+#
+# 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.
--- /dev/null
+# Copyright 2017 Sandvine
+#
+# 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.
+
+import pytest
+import json
+
+
+def vim_add_options(parser):
+ pass
+
+@pytest.fixture
+def vim(request,osm,openstack):
+ from lib.vim import vim
+ return vim.Vim(osm,openstack)
--- /dev/null
+# Copyright 2017 Sandvine
+#
+# 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.
+
+from osmclient.common.exceptions import ClientException
+
+
+class Vim():
+ def __init__(self,osm,openstack):
+ self.vim_name='pytest'
+ try:
+ osm.get_api().vim.get(self.vim_name)
+ except ClientException:
+ osm.get_api().vim.create(self.vim_name,openstack.get_access())
--- /dev/null
+# Copyright 2017 Sandvine
+#
+# 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.
+
+from lib.osm.fixtures import osm
+from lib.openstack.fixtures import openstack
+from lib.vim.fixtures import vim
--- /dev/null
+# Copyright 2017 Sandvine
+#
+# 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.
+
+import pytest
+import pprint
+import time
+
+
+@pytest.mark.smoke
+class TestClass(object):
+
+ def test_empty_vnf(self,osm):
+ assert not osm.get_api().vnf.list()
+
+ def test_empty_vnf_catalog(self,osm):
+ assert not osm.get_api().vnfd.list()
+
+ def test_empty_ns(self,osm):
+ assert not osm.get_api().ns.list()
+
+ def test_empty_ns_catalog(self,osm):
+ assert not osm.get_api().nsd.list()
--- /dev/null
+# Copyright 2017 Sandvine
+#
+# 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.
+
+import pytest
+import time
+
+
+@pytest.mark.vim
+@pytest.mark.openstack
+class TestClass(object):
+
+ def test_empty_vim(self,osm):
+ assert not osm.get_api().vim.list()
+
+ @pytest.fixture(scope='function')
+ def cleanup_test_add_vim_account(self,osm,request):
+ def teardown():
+ try:
+ osm.get_api().vim.delete('pytest')
+ except:
+ pass
+ request.addfinalizer(teardown)
+
+ @pytest.mark.openstack
+ def test_add_vim_account(self,osm,openstack,cleanup_test_add_vim_account):
+ os_access=openstack.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'] == 'openstack'
+ assert resp['vim_url'] == os_access['os-url']
+ assert resp['vim_url_admin'] == os_access['os-url']
+ assert resp['vim_tenants'][0]['user'] == os_access['os-username']
+ assert resp['vim_tenants'][0]['vim_tenant_name'] == os_access['os-project-name']
+
+ assert not osm.get_api().vim.delete('pytest')
--- /dev/null
+# Copyright 2017 Sandvine
+#
+# 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.
+
+import pytest
+import pprint
+import time
+from osmclient.common import utils
+
+
+class TestClass(object):
+
+ @pytest.fixture(scope='function')
+ def cleanup_test_vnf(self,osm,request):
+ vnfd_file_list = osm.vnfd_descriptors_list
+ nsd_file_list = osm.nsd_descriptors_list
+
+ # cleanup all ns/packages that might have been left around
+ def teardown():
+
+ # first delete all nsd's
+ for file in nsd_file_list:
+ try:
+ desc = osm.get_api().package.get_descriptor_type_from_pkg(file)
+ ns_name=osm.ns_name_prefix+nsd_desc['name']
+ osm.get_api().ns.delete(ns_name)
+ except:
+ pass
+
+ # delete all nsd packages
+ for file in nsd_file_list:
+ try:
+ desc = osm.get_api().package.get_descriptor_type_from_pkg(file)
+ osm.get_api().nsd.delete(desc['name'])
+ except:
+ pass
+
+ # delete all vnfd packages
+ for file in vnfd_file_list:
+ try:
+ desc = osm.get_api().package.get_descriptor_type_from_pkg(file)
+ osm.get_api().vnfd.delete(desc['name'])
+ except:
+ pass
+
+ request.addfinalizer(teardown)
+
+ def vnf_test(self,osm, openstack, vim, vnfd_file_list, nsd_file_list):
+ vnfd_descriptors=[]
+ for file in vnfd_file_list:
+ assert not osm.get_api().package.upload(file)
+ assert not osm.get_api().package.wait_for_upload(file)
+ desc = osm.get_api().package.get_descriptor_type_from_pkg(file)
+ assert desc
+ vnfd_descriptors.append(desc)
+
+ nsd_descriptors=[]
+ for file in nsd_file_list:
+ assert not osm.get_api().package.upload(file)
+ assert not osm.get_api().package.wait_for_upload(file)
+ desc = osm.get_api().package.get_descriptor_type_from_pkg(file)
+ assert desc
+ nsd_descriptors.append(desc)
+
+ # TODO/HACK: need to figure out why this is necessary.
+ # vnfd/nsd is there (seen on ping_pong), but the ns fails that nsd is not there,
+ # another way to check if the nsd is really ready via API?
+ time.sleep(10)
+
+ for nsd_desc in nsd_descriptors:
+ ns_name=osm.ns_name_prefix+nsd_desc['name']
+
+ assert not osm.get_api().ns.create(nsd_desc['name'],ns_name,vim.vim_name)
+
+ assert utils.wait_for_value(lambda: osm.get_api().ns.get_field(ns_name,'operational-status'),result='init')
+
+ # make sure ns is running
+ assert utils.wait_for_value(lambda: osm.get_api().ns.get_field(ns_name,'operational-status'),result='running',wait_time=120)
+
+ assert not osm.get_api().ns.delete(ns_name)
+
+ assert not osm.get_api().nsd.delete(nsd_desc['name'])
+
+ for vnfd_desc in vnfd_descriptors:
+
+ assert not osm.get_api().vnfd.delete(vnfd_desc['name'])
+
+ @pytest.mark.openstack
+ @pytest.mark.vnf
+ def test_vnf(self,osm, vim, openstack, cleanup_test_vnf):
+ vnfd_file_list = osm.vnfd_descriptors_list
+ nsd_file_list = osm.nsd_descriptors_list
+
+ self.vnf_test(osm,openstack, vim, vnfd_file_list, nsd_file_list)