nicer displays of various durations
[tests.git] / system / TestSlice.py
index 4b40bf0..f7e406b 100644 (file)
@@ -10,7 +10,7 @@ from TestKey import TestKey
 from TestUser import TestUser
 from TestNode import TestNode, CompleterTaskNodeSsh
 from TestSsh import TestSsh
-from Completer import Completer, CompleterTask
+from Completer import CompleterTask
 
 class CompleterTaskSliceSsh (CompleterTask):
 
@@ -30,11 +30,11 @@ class CompleterTaskSliceSsh (CompleterTask):
         if self.dry_run: return True
         if self.expected:       return retcod==0
         else:                   return retcod!=0
-    def failure_message (self):
+    def failure_epilogue (self):
         if self.expected:
-            return "Could not ssh into sliver %s@%s"%(self.slicename,self.hostname)
+            print "Could not ssh into sliver %s@%s"%(self.slicename,self.hostname)
         else:
-            return "Could still ssh into sliver%s@%s (that was expected to be down)"%(self.slicename,self.hostname)
+            print "Could still ssh into sliver%s@%s (that was expected to be down)"%(self.slicename,self.hostname)
 
 class TestSlice:
 
@@ -182,7 +182,6 @@ class TestSlice:
             tasks.append( CompleterTaskSliceSsh(self.test_plc,node_spec['node_fields']['hostname'],
                                                 slicename,private_key,command,expected,dry_run))
         return tasks
-#        return Completer (tasks).run (timeout, graceout, period)
 
     def ssh_slice_basics (self, options, *args, **kwds):
         "the slice is expected to be UP and we just check a few simple sanity commands, including 'ps' to check for /proc"
@@ -235,21 +234,15 @@ class TestSlice:
         # use constant admin key
         local_key = "keys/key_admin.rsa"
         node_infos = self.test_plc.all_node_infos()
-        return [ CompleterTaskNodeSsh (nodename, qemuname, local_key, expected=expected,
-                                       command="ls -d /vservers/%s"%self.name()) \
-                 for (nodename,qemuname) in node_infos ]
-        
-        overall=True
-        for nodename in self.slice_spec['nodenames']:
-            node_spec=self.test_site.locate_node(nodename)
-            test_node=TestNode(self.test_plc,self.test_site,node_spec)
-            test_node_ssh=test_node.create_test_ssh()
-            command="ls /vservers/%s"%self.name()
-            full_command = test_node_ssh.actual_command(command)
-            retcod=utils.system(full_command,silent=True)
-            # we expect the fs to be present, retcod should be 0
-            if expected:        fine=(retcod==0)
-            else:               fine=(retcod!=0)
-            if not fine: overall=False
-        return overall
-
+        rootfs="/vservers/%s"%self.name()
+        class CompleterTaskRootfs (CompleterTaskNodeSsh):
+            def __init__ (self, nodename, qemuname):
+                CompleterTaskNodeSsh.__init__(self,nodename, qemuname, local_key, expected=expected,
+                                              command="ls -d %s"%rootfs)
+            def failure_epilogue (self):
+                if expected:
+                    print "Could not stat %s - was expected to be present"%rootfs
+                else:
+                    print "Sliver rootfs %s still present - this is unexpected"%rootfs
+                    utils.system(self.test_ssh.actual_command("ls -l %s; du -hs %s"%(rootfs,rootfs),dry_run=self.dry_run))
+        return [ CompleterTaskRootfs (nodename, qemuname) for (nodename,qemuname) in node_infos ]