Add ns_scale test 37/1937/1
authorMike Marchetti <mmarchetti@sandvine.com>
Thu, 15 Jun 2017 18:51:27 +0000 (14:51 -0400)
committerMike Marchetti <mmarchetti@sandvine.com>
Thu, 15 Jun 2017 18:51:27 +0000 (14:51 -0400)
Change-Id: I49dd16f7a8c6c143498b81565ce71f902e5561b8
Signed-off-by: Mike Marchetti <mmarchetti@sandvine.com>
systest/Makefile
systest/testcases/vnfs/test_vnfs.py

index fe75754..7f5a542 100644 (file)
@@ -115,6 +115,13 @@ cirros: check_OSM_HOSTNAME check_openstack_env
         JUNITXML=pytest-$@.xml \
         PYTEST_OPTIONS="$(PYTEST_OPTIONS) -m vnf" _run_test
 
+ns_scale: 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 ns_scale" _run_test
+
 smoke: check_OSM_HOSTNAME
        $(Q)$(MAKE) \
         JUNITXML=pytest-$@.xml \
index 618f3e3..efbfb10 100644 (file)
@@ -33,7 +33,7 @@ class TestClass(object):
             # first delete all nsd's
             for file in nsd_file_list:
                 try:
-                    desc = osm.get_api().package.get_descriptor_type_from_pkg(file)
+                    desc = osm.get_api().package.get_key_val_from_pkg(file)
                     ns_name=osm.ns_name_prefix+nsd_desc['name']
                     osm.get_api().ns.delete(ns_name)
                 except:
@@ -42,7 +42,7 @@ class TestClass(object):
             # delete all nsd packages
             for file in nsd_file_list:
                 try:
-                    desc = osm.get_api().package.get_descriptor_type_from_pkg(file)
+                    desc = osm.get_api().package.get_key_val_from_pkg(file)
                     osm.get_api().nsd.delete(desc['name'])
                 except: 
                     pass
@@ -50,19 +50,19 @@ class TestClass(object):
             # delete all vnfd packages
             for file in vnfd_file_list:
                 try:
-                    desc = osm.get_api().package.get_descriptor_type_from_pkg(file)
+                    desc = osm.get_api().package.get_key_val_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):
+    def vnf_upload_packages(self, osm, 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)
+            desc = osm.get_api().package.get_key_val_from_pkg(file)
             assert desc
             vnfd_descriptors.append(desc)
 
@@ -70,16 +70,18 @@ class TestClass(object):
         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)
+            desc = osm.get_api().package.get_key_val_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)
+        time.sleep(5)
+
+    def vnf_test(self,osm, openstack, vim, vnfd_file_list, nsd_file_list, ns_scale=False):
+        for file in nsd_file_list:
+            nsd_desc = osm.get_api().package.get_key_val_from_pkg(file)
 
-        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)
@@ -89,12 +91,24 @@ class TestClass(object):
             # 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)
 
+            if ns_scale:
+                # for each descriptor, scale it
+                for scale in nsd_desc['scaling-group-descriptor']:
+                    # scale it.
+                    assert not osm.get_api().ns.scale(ns_name, scale['name'], 1)
+
+                    # ensure ns is scaling-out
+                    assert utils.wait_for_value(lambda: osm.get_api().ns.get_field(ns_name,'operational-status'),result='scaling-out',wait_time=120)
+
+                    # wait for ns to be in running-state
+                    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:
-
+        for file in vnfd_file_list:
+            vnfd_desc = osm.get_api().package.get_key_val_from_pkg(file)
             assert not osm.get_api().vnfd.delete(vnfd_desc['name'])
 
     @pytest.mark.openstack
@@ -103,4 +117,14 @@ class TestClass(object):
         vnfd_file_list = osm.vnfd_descriptors_list
         nsd_file_list = osm.nsd_descriptors_list
 
+        self.vnf_upload_packages(osm, vnfd_file_list, nsd_file_list )
         self.vnf_test(osm,openstack, vim, vnfd_file_list, nsd_file_list)
+
+    @pytest.mark.openstack
+    @pytest.mark.ns_scale
+    def test_scale_vnf(self,osm, vim, openstack, cleanup_test_vnf):
+        vnfd_file_list = osm.vnfd_descriptors_list
+        nsd_file_list = osm.nsd_descriptors_list
+
+        self.vnf_upload_packages(osm, vnfd_file_list, nsd_file_list )
+        self.vnf_test(osm,openstack, vim, vnfd_file_list, nsd_file_list, ns_scale=True)