if not tasks: return True
if datetime.now() > timeout:
for task in tasks:
- print task.failure_message()
task.failure_epilogue()
return False
if self.verbose:
print self.message(),"->","OK" if result else "KO"
return result
def message (self): return "you-need-to-redefine-message"
- def failure_message (self): return "you-need-to-redefine-failure_message"
- def failure_epilogue (self): pass
+ def failure_epilogue (self): print "you-need-to-redefine-failure_epilogue"
# random result
class TaskTest (CompleterTask):
def message (self):
return "Task %d - delay was %d s"%(self.counter,self.delay)
- def failure_message (self): return "BOTTOM LINE: FAILURE with task (%s)"%self.counter
+ def failure_epilogue (self): print "BOTTOM LINE: FAILURE with task (%s)"%self.counter
def main ():
import sys
from Completer import CompleterTask
class CompleterTaskNodeSsh (CompleterTask):
- def __init__ (self, hostname, qemuname, local_key, command=None, message=None, boot_state="boot", expected=True, dry_run=False):
+ def __init__ (self, hostname, qemuname, local_key, command=None, boot_state="boot", expected=True, dry_run=False):
self.hostname=hostname
self.qemuname=qemuname
self.boot_state=boot_state
self.command=command if command is not None else "hostname;uname -a"
self.expected=expected
self.dry_run = dry_run
- self.message = message if message else "cannot reach %s in %s mode"%(self.hostname, self.boot_state)
self.test_ssh = TestSsh (self.hostname,key=self.local_key)
def run (self, silent):
command = self.test_ssh.actual_command(self.command)
retcod=utils.system (command, silent=silent, dry_run=self.dry_run)
if self.expected: return retcod==0
else: return retcod !=0
- def failure_message (self):
- return self.message
+ def failure_epilogue (self):
+ print "Cannot reach %s in %s mode"%(self.hostname, self.boot_state)
class TestNode:
return False
def message (self):
return "CompleterTaskBootState with node %s"%self.hostname
- def failure_message (self):
- return "node %s in state %s - expected %s"%(self.hostname,self.last_boot_state,target_boot_state)
+ def failure_epilogue (self):
+ print "node %s in state %s - expected %s"%(self.hostname,self.last_boot_state,target_boot_state)
timeout = timedelta(minutes=timeout_minutes)
graceout = timedelta(minutes=silent_minutes)
def run(self,silent):
command="ping -c 1 -w 1 %s >& /dev/null"%self.hostname
return utils.system (command, silent=silent)==0
- def failure_message (self):
- return "Cannot ping node with name %s"%self.hostname
+ def failure_epilogue (self):
+ print "Cannot ping node with name %s"%self.hostname
timeout=timedelta (seconds=timeout_seconds)
graceout=timeout
period=timedelta (seconds=period_seconds)
return self.test_sliver.check_initscript_stamp (self.stamp)
def message (self):
return "initscript checker for %s"%self.test_sliver.name()
- def failure_message (self):
- return "initscript stamp %s not found in sliver %s"%(self.stamp,self.test_sliver.name())
+ def failure_epilogue (self):
+ print "initscript stamp %s not found in sliver %s"%(self.stamp,self.test_sliver.name())
tasks=[]
for slice_spec in self.plc_spec['slices']:
return self.test_node._check_system_slice (slicename, dry_run=self.dry_run)
def message (self):
return "System slice %s @ %s"%(slicename, self.test_node.name())
- def failure_message (self):
- return "COULD not find system slice %s @ %s"%(slicename, self.test_node.name())
+ def failure_epilogue (self):
+ print "COULD not find system slice %s @ %s"%(slicename, self.test_node.name())
timeout = timedelta(minutes=timeout_minutes)
silent = timedelta (0)
period = timedelta (seconds=period_seconds)
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:
local_key = "keys/key_admin.rsa"
node_infos = self.test_plc.all_node_infos()
rootfs="/vservers/%s"%self.name()
- if expected:
- failure_message = "Could not stat %s"%rootfs
- else:
- failure_message = "Sliver rootfs still present in %s"%rootfs
class CompleterTaskRootfs (CompleterTaskNodeSsh):
def __init__ (self, nodename, qemuname):
CompleterTaskNodeSsh.__init__(self,nodename, qemuname, local_key, expected=expected,
- message=failure_message, command="ls -d %s"%rootfs)
+ command="ls -d %s"%rootfs)
def failure_epilogue (self):
- utils.system(self.test_ssh.actual_command("ls -l %s; du -hs %s"%(rootfs,rootfs),dry_run=self.dry_run))
+ 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 ]