inria IP numbering has changed + merged tweaks from trunk
[tests.git] / system / TestPlc.py
index ca70681..76b4de4 100644 (file)
@@ -278,6 +278,8 @@ class TestPlc:
     # (*) the cleanup_tracker method stops all known vservers and removes the tracker file
 
     TRACKER_FILE=os.environ['HOME']+"/running-test-plcs"
+    # how many concurrent plcs are we keeping alive - adjust with the IP pool size
+    TRACKER_KEEP_VSERVERS = 12
 
     def record_tracker (self):
         try:
@@ -300,7 +302,8 @@ class TestPlc:
         print "Recorded %s in running plcs on host %s"%(self.vservername,self.test_ssh.hostname)
         return True
 
-    def free_tracker (self, keep_vservers=3):
+    def free_tracker (self, keep_vservers=None):
+        if not keep_vservers: keep_vservers=TestPlc.TRACKER_KEEP_VSERVERS
         try:
             lines=file(TestPlc.TRACKER_FILE).readlines()
         except:
@@ -394,7 +397,8 @@ class TestPlc:
 
     ### install_rpm 
     def install_rpm(self):
-        return self.run_in_guest("yum -y install myplc-native")==0
+        return self.run_in_guest("yum -y install myplc-native")==0 \
+            and self.run_in_guest("yum -y install noderepo-%s-%s"%(self.options.pldistro,self.options.arch))==0
 
     ### 
     def configure(self):
@@ -593,20 +597,27 @@ class TestPlc:
     def nodes_booted(self):
         return self.do_nodes_booted(minutes=20,gracetime=15)
 
-    def do_nodes_ssh(self,minutes,gracetime,period=15):
+    def do_nodes_ssh(self,minutes,gracetime,period=20):
         # compute timeout
         timeout = datetime.datetime.now()+datetime.timedelta(minutes=minutes)
         graceout = datetime.datetime.now()+datetime.timedelta(minutes=gracetime)
         tocheck = self.all_hostnames()
 #        self.scan_publicKeys(tocheck)
-        utils.header("checking Connectivity on nodes %r"%tocheck)
+        utils.header("checking ssh access to root context on nodes %r"%tocheck)
+        vservername=self.vservername
         while tocheck:
             for hostname in tocheck:
-                # try to ssh in nodes
-                node_test_ssh = TestSsh (hostname,key="/etc/planetlab/root_ssh_key.rsa")
-                success=self.run_in_guest(node_test_ssh.actual_command("hostname"))==0
-                if success:
-                    utils.header('The node %s is sshable -->'%hostname)
+                # try to run 'hostname' in the node
+                # using locally cached keys - assuming we've run testplc.fetch_keys()
+                local_key = "keys/%(vservername)s.rsa"%locals()
+                command = TestSsh (hostname,key=local_key).actual_command("hostname")
+                # don't spam logs - show the command only after the grace period 
+                if datetime.datetime.now() > graceout:
+                    success=utils.system(command)
+                else:
+                    success=os.system(command)
+                if success==0:
+                    utils.header('Successfully entered root@%s'%hostname)
                     # refresh tocheck
                     tocheck.remove(hostname)
                 else:
@@ -615,8 +626,6 @@ class TestPlc:
                     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)
-                    elif datetime.datetime.now() > graceout:
-                        utils.header("Could not ssh-enter root context on %s"%hostname)
             if  not tocheck:
                 return True
             if datetime.datetime.now() > timeout:
@@ -629,7 +638,7 @@ class TestPlc:
         return True
         
     def nodes_ssh(self):
-        return self.do_nodes_ssh(minutes=30,gracetime=5)
+        return self.do_nodes_ssh(minutes=30,gracetime=10)
     
     @node_mapper
     def init_node (self): pass