From 2599163df4acc4c239239f955fcdb8128b04b9d0 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Wed, 21 May 2014 10:15:34 +0200 Subject: [PATCH] CompleterTask used to have a failure_message mechanism, then we added failure_epilogue, now we remove failure_message --- system/Completer.py | 6 ++---- system/TestNode.py | 7 +++---- system/TestPlc.py | 16 ++++++++-------- system/TestSlice.py | 18 +++++++++--------- 4 files changed, 22 insertions(+), 25 deletions(-) diff --git a/system/Completer.py b/system/Completer.py index 155397e..3cf724e 100755 --- a/system/Completer.py +++ b/system/Completer.py @@ -31,7 +31,6 @@ class Completer: 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: @@ -64,8 +63,7 @@ class CompleterTask: 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): @@ -81,7 +79,7 @@ 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 diff --git a/system/TestNode.py b/system/TestNode.py index 28b013a..c8ca1e8 100644 --- a/system/TestNode.py +++ b/system/TestNode.py @@ -10,7 +10,7 @@ from TestSsh import TestSsh 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 @@ -18,15 +18,14 @@ class CompleterTaskNodeSsh (CompleterTask): 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: diff --git a/system/TestPlc.py b/system/TestPlc.py index d0d04d2..6c8bb55 100644 --- a/system/TestPlc.py +++ b/system/TestPlc.py @@ -1021,8 +1021,8 @@ class TestPlc: 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) @@ -1049,8 +1049,8 @@ class TestPlc: 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) @@ -1134,8 +1134,8 @@ class TestPlc: 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']: @@ -1327,8 +1327,8 @@ class TestPlc: 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) diff --git a/system/TestSlice.py b/system/TestSlice.py index f5049d3..0043d4c 100644 --- a/system/TestSlice.py +++ b/system/TestSlice.py @@ -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: @@ -236,14 +236,14 @@ 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 ] -- 2.43.0