catching the failure right in the test method
[tests.git] / system / TestPlc.py
index f5e9b57..3fbcb09 100644 (file)
@@ -469,6 +469,12 @@ class TestPlc:
     ### install_rpm 
     def install(self):
         "yum install myplc, noderepo, and the plain bootstrapfs"
+
+        # workaround for getting pgsql5.2 on centos5
+        if self.options.fcdistro == "centos5":
+            self.run_in_guest("rpm -Uvh http://yum.pgsqlrpms.org/8.2/pgdg-centos-8.2-4.noarch.rpm")
+            self.run_in_guest("rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm")
+
         if self.options.personality == "linux32":
             arch = "i386"
         elif self.options.personality == "linux64":
@@ -676,12 +682,15 @@ class TestPlc:
                     overall=False
         return overall
 
-    def all_hostnames (self) :
-        hostnames = []
+    # return a list of tuples (nodename,qemuname)
+    def all_node_infos (self) :
+        node_infos = []
         for site_spec in self.plc_spec['sites']:
-            hostnames += [ node_spec['node_fields']['hostname'] \
+            node_infos += [ (node_spec['node_fields']['hostname'],node_spec['host_box']) \
                            for node_spec in site_spec['nodes'] ]
-        return hostnames
+        return node_infos
+    
+    def all_nodenames (self): return [ x[0] for x in self.all_node_infos() ]
 
     # silent_minutes : during the first <silent_minutes> minutes nothing gets printed
     def nodes_check_boot_state (self, target_boot_state, timeout_minutes, silent_minutes,period=15):
@@ -743,31 +752,34 @@ class TestPlc:
         else: 
             message="boot"
            local_key = "keys/key1.rsa"
-        tocheck = self.all_hostnames()
-        utils.header("checking ssh access (expected in %s mode) to nodes %r"%(message,tocheck))
+        node_infos = self.all_node_infos()
+        utils.header("checking ssh access (expected in %s mode) to nodes:"%message)
+        for (nodename,qemuname) in node_infos:
+            utils.header("hostname=%s -- qemubox=%s"%(nodename,qemuname))
         utils.header("max timeout is %d minutes, silent for %d minutes (period is %s)"%\
                          (timeout_minutes,silent_minutes,period))
-        while tocheck:
-            for hostname in tocheck:
+        while node_infos:
+            for node_info in node_infos:
+                (hostname,qemuname) = node_info
                 # try to run 'hostname' in the node
                 command = TestSsh (hostname,key=local_key).actual_command("hostname;uname -a")
                 # don't spam logs - show the command only after the grace period 
                 success = utils.system ( command, silent=datetime.datetime.now() < graceout)
                 if success==0:
                     utils.header('Successfully entered root@%s (%s)'%(hostname,message))
-                    # refresh tocheck
-                    tocheck.remove(hostname)
+                    # refresh node_infos
+                    node_infos.remove(node_info)
                 else:
                     # we will have tried real nodes once, in case they're up - but if not, just skip
                     (site_spec,node_spec)=self.locate_hostname(hostname)
                     if TestNode.is_real_model(node_spec['node_fields']['model']):
                         utils.header ("WARNING : check ssh access into real node %s - skipped"%hostname)
-                       tocheck.remove(hostname)
-            if  not tocheck:
+                       node_infos.remove(node_info)
+            if  not node_infos:
                 return True
             if datetime.datetime.now() > timeout:
-                for hostname in tocheck:
-                    utils.header("FAILURE to ssh into %s"%hostname)
+                for (hostname,qemuname) in node_infos:
+                    utils.header("FAILURE to ssh into %s (on %s)"%(hostname,qemuname))
                 return False
             # otherwise, sleep for a while
             time.sleep(period)
@@ -776,11 +788,11 @@ class TestPlc:
         
     def nodes_ssh_debug(self):
         "Tries to ssh into nodes in debug mode with the debug ssh key"
-        return self.check_nodes_ssh(debug=True,timeout_minutes=30,silent_minutes=10)
+        return self.check_nodes_ssh(debug=True,timeout_minutes=30,silent_minutes=5)
     
     def nodes_ssh_boot(self):
         "Tries to ssh into nodes in production mode with the root ssh key"
-        return self.check_nodes_ssh(debug=False,timeout_minutes=30,silent_minutes=10)
+        return self.check_nodes_ssh(debug=False,timeout_minutes=30,silent_minutes=15)
     
     @node_mapper
     def init_node (self): 
@@ -966,15 +978,13 @@ class TestPlc:
     def import_sfa(self):
         "sfa-import-plc"
        auth=self.plc_spec['sfa']['SFA_REGISTRY_ROOT_AUTH']
-        self.run_in_guest('sfa-import-plc.py')
+        return self.run_in_guest('sfa-import-plc.py')==0
 # not needed anymore
 #        self.run_in_guest('cp /etc/sfa/authorities/%s/%s.pkey /etc/sfa/authorities/server.key'%(auth,auth))
-        return True
 
     def start_sfa(self):
         "service sfa start"
-        self.run_in_guest('service sfa start')
-        return True
+        return self.run_in_guest('service sfa start')==0
 
     def setup_sfa(self):
         "sfi client configuration"
@@ -1092,8 +1102,7 @@ class TestPlc:
 
     def stop_sfa(self):
         "service sfa stop"
-        self.run_in_guest('service sfa stop')
-        return True
+        return self.run_in_guest('service sfa stop')==0
 
     def populate (self):
         "creates random entries in the PLCAPI"