initial delivery of system test framework

- add initial pytest framework with fixtures for
  vim, openstack, osm
- test cirros and ping_pong ns available from repo

Change-Id: Iae1fa4bcbf55fb8bc6986e798fd662a0bd452470
Signed-off-by: Mike Marchetti <mmarchetti@sandvine.com>
diff --git a/systest/testcases/conftest.py b/systest/testcases/conftest.py
new file mode 100644
index 0000000..9f8be17
--- /dev/null
+++ b/systest/testcases/conftest.py
@@ -0,0 +1,19 @@
+# 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
diff --git a/systest/testcases/smoke/test_smoke.py b/systest/testcases/smoke/test_smoke.py
new file mode 100644
index 0000000..e915e23
--- /dev/null
+++ b/systest/testcases/smoke/test_smoke.py
@@ -0,0 +1,35 @@
+# 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()
diff --git a/systest/testcases/vim/test_vim.py b/systest/testcases/vim/test_vim.py
new file mode 100644
index 0000000..5ea7077
--- /dev/null
+++ b/systest/testcases/vim/test_vim.py
@@ -0,0 +1,50 @@
+# 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')
diff --git a/systest/testcases/vnfs/test_vnfs.py b/systest/testcases/vnfs/test_vnfs.py
new file mode 100644
index 0000000..618f3e3
--- /dev/null
+++ b/systest/testcases/vnfs/test_vnfs.py
@@ -0,0 +1,106 @@
+# 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)