From 55f26654775abc4e99ac5a032dd1724aa13219b3 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Tue, 3 Mar 2015 11:37:34 +0100 Subject: [PATCH] cosmetic changes only + a comment on the occasional issue with cross-check-tcp --- system/TestPlc.py | 17 ++++++++++------- system/TestSliver.py | 16 ++++++++-------- system/utils.py | 8 ++++---- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/system/TestPlc.py b/system/TestPlc.py index 873b2fe..6b910a7 100644 --- a/system/TestPlc.py +++ b/system/TestPlc.py @@ -1310,20 +1310,23 @@ class TestPlc: for spec in specs: port = spec['port'] # server side - s_test_sliver = self.locate_sliver_obj_cross (spec['server_node'],spec['server_slice'],other_plcs) - if not s_test_sliver.run_tcp_server(port,timeout=20): - overall=False + # the issue here is that we have the server run in background + # and so we have no clue if it took off properly or not + # looks like in some cases it does not + s_test_sliver = self.locate_sliver_obj_cross (spec['server_node'], spec['server_slice'], other_plcs) + if not s_test_sliver.run_tcp_server(port, timeout=20): + overall = False break # idem for the client side - c_test_sliver = self.locate_sliver_obj_cross (spec['client_node'],spec['client_slice'],other_plcs) + c_test_sliver = self.locate_sliver_obj_cross (spec['client_node'], spec['client_slice'], other_plcs) # use nodename from locatesd sliver, unless 'client_connect' is set if 'client_connect' in spec: destination = spec['client_connect'] else: - destination=s_test_sliver.test_node.name() - if not c_test_sliver.run_tcp_client(destination,port): - overall=False + destination = s_test_sliver.test_node.name() + if not c_test_sliver.run_tcp_client(destination, port): + overall = False return overall # painfully enough, we need to allow for some time as netflow might show up last diff --git a/system/TestSliver.py b/system/TestSliver.py index e9aa7aa..a82b27b 100644 --- a/system/TestSliver.py +++ b/system/TestSliver.py @@ -34,24 +34,24 @@ class TestSliver: def name (self): return "%s@%s"%(self.test_slice.name(),self.test_node.name()) - def check_initscript_stamp(self,stamp): - utils.header("Checking for initscript stamp %s on sliver %s"%(stamp,self.name())) + def check_initscript_stamp(self, stamp): + utils.header("Checking for initscript stamp %s on sliver %s"%(stamp, self.name())) return self.test_ssh.run("ls -l /var/tmp/%s.stamp"%stamp)==0 - def run_tcp_server (self,port,timeout=10): + def run_tcp_server (self, port, timeout=10): server_command = "./tcptest.py server -p %d -t %d"%(port,timeout) return self.test_ssh.copy("tcptest.py")==0 and \ - self.test_ssh.run(server_command,background=True)==0 + self.test_ssh.run(server_command, background=True)==0 - def run_tcp_client (self,servername,port,retry=5): - client_command="./tcptest.py client -a %s -p %d"%(servername,port) + def run_tcp_client (self, servername, port, retry=5): + client_command="./tcptest.py client -a %s -p %d"%(servername, port) if self.test_ssh.copy("tcptest.py")!=0: return False utils.header ("tcp client - first attempt") - if self.test_ssh.run(client_command,background=False)==0: return True + if self.test_ssh.run(client_command, background=False)==0: return True # if first try has failed, wait for s an try again time.sleep(retry) utils.header ("tcp client - second attempt") - if self.test_ssh.run(client_command,background=False)==0: return True + if self.test_ssh.run(client_command, background=False)==0: return True return False # use the node's main ssh root entrance, as the slice entrance might be down diff --git a/system/utils.py b/system/utils.py index 5a869d1..701ad3f 100644 --- a/system/utils.py +++ b/system/utils.py @@ -22,8 +22,8 @@ def pprint(message,spec,depth=2): -def system(command,background=False,silent=False, dry_run=None): - dry_run = dry_run if dry_run is not None else getattr(options,'dry_run',False) +def system(command, background=False, silent=False, dry_run=None): + dry_run = dry_run if dry_run is not None else getattr(options, 'dry_run', False) if dry_run: print 'dry_run:',command return 0 @@ -59,7 +59,7 @@ def match (string, pattern): pattern=pattern.replace("?",".") return re.compile(pattern).match(string) -def locate_hooks_scripts (message,path,extensions): +def locate_hooks_scripts (message, path, extensions): print message,'searching',path,'for extensions',extensions scripts=[] for ext in extensions: @@ -70,7 +70,7 @@ def locate_hooks_scripts (message,path,extensions): # quick & dirty - should probably use the parseroption object instead # and move to TestMain as well exclude_options_keys = [ 'ensure_value' , 'read_file', 'read_module' ] -def show_options (message,options): +def show_options (message, options): now=time.strftime("%H:%M:%S", time.localtime()) print ">",now,"--",message for k in dir(options): -- 2.43.0