X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=system%2FTestSlice.py;h=f5049d3b471a8b90ed65975cd95a49a2ff2f13e9;hb=55177a1292ca841809a3194015d32f76f1f0420c;hp=0b61e7e6b5b7ebcd82b7cd4f3da7f2b23f4ed095;hpb=40054e80b3cea64e2747cac8053acada7c02b365;p=tests.git diff --git a/system/TestSlice.py b/system/TestSlice.py index 0b61e7e..f5049d3 100644 --- a/system/TestSlice.py +++ b/system/TestSlice.py @@ -8,11 +8,11 @@ import time from TestKey import TestKey from TestUser import TestUser -from TestNode import TestNode +from TestNode import TestNode, CompleterTaskNodeSsh from TestSsh import TestSsh from Completer import Completer, CompleterTask -class CompleterTaskSshSlice (CompleterTask): +class CompleterTaskSliceSsh (CompleterTask): def __init__ (self, test_plc, hostname, slicename, private_key,command, expected, dry_run): self.test_plc=test_plc @@ -143,7 +143,7 @@ class TestSlice: key_names += user_spec['key_names'] return self.test_plc.locate_private_key_from_key_names (key_names) - # to be used through TestPlc.slice_mapper_tasks + # for TestPlc.slice_mapper__tasks # i.e. returns a list of CompleterTasks that are merged into the same Completer run # to avoid waiting for as many slices as the Plc has # also the __doc__ lines are used for the TestPlc methods, e.g. just 'ssh_slice' @@ -179,7 +179,7 @@ class TestSlice: dry_run = getattr(options,'dry_run',False) for nodename in self.slice_spec['nodenames']: (site_spec,node_spec) = self.test_plc.locate_node(nodename) - tasks.append( CompleterTaskSshSlice(self.test_plc,node_spec['node_fields']['hostname'], + 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) @@ -222,24 +222,28 @@ class TestSlice: if not success: utils.header ("WRONG RESULT for %s"%msg) return success - def check_rootfs (self, expected): - 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 - - def slice_fs_present (self, options): - "check that /vservers/ can be found" - return self.check_rootfs (expected=True) - def slice_fs_deleted (self, options): - "check that /vservers/ has been properly wiped off on all nodes" - return self.check_rootfs (expected=False) + # for TestPlc.slice_mapper__tasks + # check that /vservers/<> is present/deleted + def slice_fs_present__tasks (self, options): + "checks that /vservers/ exists on the filesystem" + return self.check_rootfs_tasks(options,expected=True) + def slice_fs_deleted__tasks (self, options): + "checks that /vservers/ has been properly wiped off" + return self.check_rootfs_tasks (options,expected=False) + + def check_rootfs_tasks (self, options, expected): + # use constant admin key + 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) + def failure_epilogue (self): + 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 ]