no functional change, but a small cleanup on how sfa users are configured
[tests.git] / system / TestPlc.py
index b9710a1..2878344 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
@@ -185,12 +193,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 +514,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):