show kvm box iptables before pinging node
[tests.git] / system / TestPlc.py
index b9710a1..6cd6704 100644 (file)
@@ -23,6 +23,8 @@ from TestAuthSfa import TestAuthSfa
 from PlcapiUrlScanner import PlcapiUrlScanner
 from Completer import Completer, CompleterTask
 
+has_sfa_cache_filename="sfa-cache"
+
 # step methods must take (self) and return a boolean (options is a member of the class)
 
 def standby(minutes,dry_run):
@@ -40,18 +42,20 @@ def standby_generic (func):
     return actual
 
 def node_mapper (method):
-    def actual(self,*args, **kwds):
+    def map_on_nodes(self,*args, **kwds):
         overall=True
         node_method = TestNode.__dict__[method.__name__]
         for test_node in self.all_nodes():
             if not node_method(test_node, *args, **kwds): overall=False
         return overall
+    # maintain __name__ for ignore_result
+    map_on_nodes.__name__=method.__name__
     # restore the doc text
-    actual.__doc__=TestNode.__dict__[method.__name__].__doc__
-    return actual
+    map_on_nodes.__doc__=TestNode.__dict__[method.__name__].__doc__
+    return map_on_nodes
 
 def slice_mapper (method):
-    def actual(self):
+    def map_on_slices(self):
         overall=True
         slice_method = TestSlice.__dict__[method.__name__]
         for slice_spec in self.plc_spec['slices']:
@@ -60,21 +64,25 @@ def slice_mapper (method):
             test_slice=TestSlice(self,test_site,slice_spec)
             if not slice_method(test_slice,self.options): overall=False
         return overall
+    # maintain __name__ for ignore_result
+    map_on_slices.__name__=method.__name__
     # restore the doc text
-    actual.__doc__=TestSlice.__dict__[method.__name__].__doc__
-    return actual
+    map_on_slices.__doc__=TestSlice.__dict__[method.__name__].__doc__
+    return map_on_slices
 
 # run a step but return True so that we can go on
 def ignore_result (method):
-    def wrappee (self):
+    def ignoring (self):
         # ssh_slice_ignore->ssh_slice
         ref_name=method.__name__.replace('_ignore','').replace('force_','')
         ref_method=TestPlc.__dict__[ref_name]
         result=ref_method(self)
         print "Actual (but ignored) result for %(ref_name)s is %(result)s"%locals()
         return Ignored (result)
-    wrappee.__doc__="ignored version of " + method.__name__.replace('_ignore','').replace('ignore_','')
-    return wrappee
+    name=method.__name__.replace('_ignore','').replace('force_','')
+    ignoring.__name__=name
+    ignoring.__doc__="ignored version of " + name
+    return ignoring
 
 # a variant that expects the TestSlice method to return a list of CompleterTasks that
 # are then merged into a single Completer run to avoid wating for all the slices
@@ -146,6 +154,7 @@ class TestPlc:
         'sfi_list@1', 'sfi_show@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..
+        'probe_kvm_iptables',
         'ping_node', 'ssh_node_debug', 'plcsh_stress_test@1', SEP,
         'ssh_node_boot', 'node_bmlogs', 'ssh_slice', 'ssh_slice_basics', 'check_initscripts_ignore', SEP,
         'ssh_slice_sfa@1', 'sfa_delete_slice@1', 'sfa_delete_user@1', SEPSFA,
@@ -185,12 +194,23 @@ class TestPlc:
     # this was originally for centos5 but is still valid
     # for up to f12 as recent SFAs with sqlalchemy won't build before f14
     @staticmethod
-    def check_whether_build_has_sfa (rpms_url):
-        utils.header ("Checking if build provides SFA package...")
+    def _has_sfa_cached (rpms_url):
+        if os.path.isfile(has_sfa_cache_filename):
+            cached=file(has_sfa_cache_filename).read()=="yes"
+            utils.header("build provides SFA (cached):%s"%cached)
+            return cached
         # warning, we're now building 'sface' so let's be a bit more picky
-        retcod=os.system ("curl --silent %s/ | grep -q sfa-"%rpms_url)
         # full builds are expected to return with 0 here
-        if retcod==0:
+        utils.header ("Checking if build provides SFA package...")
+        retcod=os.system ("curl --silent %s/ | grep -q sfa-"%rpms_url)==0
+        encoded='yes' if retcod else 'no'
+        file(has_sfa_cache_filename,'w').write(encoded)
+        return retcod
+        
+    @staticmethod
+    def check_whether_build_has_sfa (rpms_url):
+        has_sfa=TestPlc._has_sfa_cached(rpms_url)
+        if has_sfa:
             utils.header("build does provide SFA")
         else:
             # move all steps containing 'sfa' from default_steps to other_steps
@@ -495,7 +515,7 @@ class TestPlc:
                     for key in val:
                         self.display_key_spec (key)
             elif passno == 1:
-                if key not in ['sites','initscripts','slices','keys', 'sfa']:
+                if key not in ['sites','initscripts','slices','keys']:
                     print '+   ',key,':',val
 
     def display_site_spec (self,site):
@@ -1031,6 +1051,11 @@ class TestPlc:
     def nodes_booted(self):
         return self.nodes_check_boot_state('boot',timeout_minutes=30,silent_minutes=28)
 
+    def probe_kvm_iptables (self):
+        (_,kvmbox) = self.all_node_infos()[0]
+        TestSsh(kvmbox).run("iptables-save")
+        return True
+
     # probing nodes
     def check_nodes_ping(self,timeout_seconds=120,period_seconds=10):
         class CompleterTaskPingNode (CompleterTask):