test that a slice resources can be released using an empty rspec to allocate and...
Thierry Parmentelat [Wed, 20 Aug 2014 11:03:19 +0000 (13:03 +0200)]
system/TestAuthSfa.py
system/TestPlc.py
system/TestSliceSfa.py
system/empty-rspec.xml [new file with mode: 0644]

index cbf52e3..6d3d542 100644 (file)
@@ -194,10 +194,16 @@ class TestAuthSfa:
     @slice_sfa_mapper
     def sfa_allocate (self, *args, **kwds): pass
     @slice_sfa_mapper
+    def sfa_allocate_empty (self, *args, **kwds): pass
+    @slice_sfa_mapper
     def sfa_provision (self, *args, **kwds): pass
     @slice_sfa_mapper
+    def sfa_provision_empty (self, *args, **kwds): pass
+    @slice_sfa_mapper
     def sfa_check_slice_plc (self, *args, **kwds): pass
     @slice_sfa_mapper
+    def sfa_check_slice_plc_empty (self, *args, **kwds): pass
+    @slice_sfa_mapper
     def sfa_update_slice (self, *args, **kwds): pass
     @slice_sfa_mapper
     def sfa_delete_slice (self, *args, **kwds): pass
index 73c5c86..9473c8d 100644 (file)
@@ -155,6 +155,7 @@ class TestPlc:
         'sfa_insert_user_in_slice@1','sfi_show_slice_researchers@1', SEPSFA,
         'sfa_discover@1', 'sfa_rspec@1', 'sfa_allocate@1', 'sfa_provision@1', SEPSFA,
         'sfa_check_slice_plc@1', 'sfa_update_slice@1', SEPSFA,
+        'sfa_rspec_empty@1','sfa_allocate_empty@1', 'sfa_provision_empty@1','sfa_check_slice_plc_empty@1', SEPSFA,
         'sfi_list@1', 'sfi_show_site@1', 'sfa_utest@1', SEPSFA,
         # we used to run plcsh_stress_test, and then ssh_node_debug and ssh_node_boot
         # but as the stress test might take a while, we sometimes missed the debug mode..
@@ -1543,7 +1544,7 @@ class TestPlc:
                                      " ".join([ plc.registry_xml_line() for plc in other_plcs ]))
         utils.header ("(Over)wrote %s"%reg_fname)
         return self.test_ssh.copy_abs(agg_fname,'/%s/etc/sfa/aggregates.xml'%self.vm_root_in_host())==0 \
-            and  self.test_ssh.copy_abs(reg_fname,'/%s/etc/sfa/registries.xml'%self.vm_root_in_host())==0
+           and self.test_ssh.copy_abs(reg_fname,'/%s/etc/sfa/registries.xml'%self.vm_root_in_host())==0
 
     def sfa_import(self):
         "use sfaadmin to import from plc"
@@ -1581,6 +1582,17 @@ class TestPlc:
         self.run_in_guest("rm -rf /root/sfi")
         return True
 
+    def sfa_rspec_empty(self):
+        "expose a static empty rspec (ships with the tests module) in the sfi directory"
+        filename="empty-rspec.xml"
+        overall=True
+        for slice_spec in self.plc_spec['sfa']['auth_sfa_specs']:
+            test_slice=TestAuthSfa(self,slice_spec)
+            in_vm = test_slice.sfi_path()
+            remote="%s/%s"%(self.vm_root_in_host(),in_vm)
+            if self.test_ssh.copy_abs (filename, remote) !=0: overall=False
+        return overall
+
     @auth_sfa_mapper
     def sfa_register_site (self): pass
     @auth_sfa_mapper
@@ -1602,10 +1614,16 @@ class TestPlc:
     @auth_sfa_mapper
     def sfa_allocate(self): pass
     @auth_sfa_mapper
+    def sfa_allocate_empty(self): pass
+    @auth_sfa_mapper
     def sfa_provision(self): pass
     @auth_sfa_mapper
+    def sfa_provision_empty(self): pass
+    @auth_sfa_mapper
     def sfa_check_slice_plc(self): pass
     @auth_sfa_mapper
+    def sfa_check_slice_plc_empty(self): pass
+    @auth_sfa_mapper
     def sfa_update_slice(self): pass
     @auth_sfa_mapper
     def sfa_remove_user_from_slice(self): pass
index a6c7f84..eba256d 100644 (file)
@@ -12,7 +12,6 @@ import utils
 from TestNode import TestNode
 from TestUser import TestUser
 from TestBoxQemu import TestBoxQemu
-from TestSsh import TestSsh
 
 from Completer import Completer, CompleterTask
 from TestSlice import CompleterTaskSliceSsh
@@ -102,6 +101,7 @@ class TestSliceSfa:
     def _resname (self,name,ext): return "%s.%s"%(name,ext)
     def adfile (self): return self._resname("ad","rspec")
     def reqfile (self): return self._resname("req","rspec")
+    def empty_reqfile (self): return "empty-rspec.xml"
     def nodefile (self): return self._resname("nodes","txt")
     
     # run as user
@@ -121,22 +121,30 @@ class TestSliceSfa:
             if self.test_plc.run_in_guest(command)!=0: return False
         return True
 
+    def _sfa_allocate(self,file,options):
+        command=self.sfi_user("allocate %s %s"%(self.hrn(),file))
+        return self.test_plc.run_in_guest(command)==0
+
     def sfa_allocate(self,options):
         "invoke run sfi allocate (on SM)"
-        command=self.sfi_user("allocate %s %s"%(self.hrn(),self.reqfile()))
-        return self.test_plc.run_in_guest(command)==0
+        return self._sfa_allocate(self.reqfile(),options)
+    def sfa_allocate_empty(self,options):
+        "invoke run sfi allocate (on SM) with an empty rspec"
+        return self._sfa_allocate(self.empty_reqfile(),options)
 
     def sfa_provision(self,options):
         "invoke run sfi provision (on SM)"
         command=self.sfi_user("provision %s"%(self.hrn()))
         return self.test_plc.run_in_guest(command)==0
+    # just a synonym
+    sfa_provision_empty = sfa_provision
 
     def plc_name (self):
         return "%s_%s"%(self.test_auth_sfa.login_base,self.slice_spec['name'])
 
     # all local nodes in slice ?
     def sfa_check_slice_plc (self,options):
-        "check the slices have been created at the plcs - all local nodes should be in slice"
+        "check the slice has been created at the plc - all local nodes should be in slice"
         slice=self.test_plc.apiserver.GetSlices(self.test_plc.auth_root(), self.plc_name())[0]
         nodes=self.test_plc.apiserver.GetNodes(self.test_plc.auth_root(), {'peer_id':None})
         result=True
@@ -148,6 +156,14 @@ class TestSliceSfa:
                 result=False
         return result
 
+    # no node left in slice ?
+    def sfa_check_slice_plc_empty (self,options):
+        "check the slice have been emptied at the plcs - no node should be in slice"
+        slices=self.test_plc.apiserver.GetSlices(self.test_plc.auth_root(), 
+                                                 self.plc_name(),
+                                                 ['node_ids'])
+        return not slices[0]['node_ids']
+
     # xxx historically this used to do the same as sfa-create-slice
     # which was later on split into 3 distinct steps, 
     # and we can ignore the first that is about setting up the rspec
diff --git a/system/empty-rspec.xml b/system/empty-rspec.xml
new file mode 100644 (file)
index 0000000..3f01b30
--- /dev/null
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<rspec xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.geni.net/resources/rspec/3" xmlns:plos="http://www.planet-lab.org/resources/sfa/ext/plos/1" xmlns:flack="http://www.protogeni.net/resources/rspec/ext/flack/1" xmlns:planetlab="http://www.planet-lab.org/resources/sfa/ext/planetlab/1" type="request" xsi:schemaLocation="http://www.geni.net/resources/rspec/3 http://www.geni.net/resources/rspec/3/request.xsd http://www.planet-lab.org/resources/sfa/ext/planetlab/1 http://www.planet-lab.org/resources/sfa/ext/planetlab/1/planetlab.xsd http://www.planet-lab.org/resources/sfa/ext/plos/1 http://www.planet-lab.org/resources/sfa/ext/plos/1/plos.xsd" expires="2014-08-19T14:21:43Z" generated="2014-08-19T13:21:43Z"/>