From: Thierry Parmentelat Date: Wed, 12 Sep 2018 10:36:10 +0000 (+0200) Subject: tcptest now explicitly passes a hostname along to the server side (before this change... X-Git-Tag: tests-6.0-5~10 X-Git-Url: http://git.onelab.eu/?p=tests.git;a=commitdiff_plain;h=72262d25e7d32f817c47494cfa7173ef283230da tcptest now explicitly passes a hostname along to the server side (before this change, only the client was receiving this info) --- diff --git a/system/TestPlc.py b/system/TestPlc.py index e704d98..6c74294 100644 --- a/system/TestPlc.py +++ b/system/TestPlc.py @@ -1437,7 +1437,8 @@ class TestPlc: # 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 - if not spec['s_sliver'].run_tcp_server(port, timeout=20): + address = spec['s_sliver'].test_node.name() + if not spec['s_sliver'].run_tcp_server(address, port, timeout=20): overall = False break diff --git a/system/TestSliver.py b/system/TestSliver.py index 32d6dff..ebbf253 100644 --- a/system/TestSliver.py +++ b/system/TestSliver.py @@ -1,5 +1,5 @@ # Thierry Parmentelat -# Copyright (C) 2010 INRIA +# Copyright (C) 2010 INRIA # import utils import os, os.path @@ -22,12 +22,12 @@ class TestSliver: return (found, privatekey) except Exception as e: print(str(e)) - + def create_test_ssh(self): private_key = self.test_slice.locate_private_key() if not private_key: raise Exception("Cannot find the private key for slice {}".format(self.test_slice.name())) - return TestSsh (self.test_node.name(), key=private_key, username=self.test_slice.name(), + return TestSsh(self.test_node.name(), key=private_key, username=self.test_slice.name(), # so that copies end up in the home dir buildname=".") @@ -37,19 +37,21 @@ class TestSliver: def check_initscript_stamp(self, stamp): utils.header("Checking for initscript stamp {} on sliver {}".format(stamp, self.name())) return self.test_ssh.run("ls -l /var/tmp/{}.stamp".format(stamp)) == 0 - - def check_tcp_ready (self, port): + + def check_tcp_ready(self, port): ready_command = "./tcptest.py ready -p {}".format(port) return self.test_ssh.copy("tcptest.py") == 0 and \ self.test_ssh.run(ready_command) == 0 - def run_tcp_server (self, port, timeout=10): - server_command = "./tcptest.py server -p {} -t {}".format(port, timeout) + def run_tcp_server(self, servername, port, timeout=10): + server_command = "./tcptest.py server -a {} -p {} -t {}"\ + .format(servername, port, timeout) return self.test_ssh.copy("tcptest.py") == 0 and \ self.test_ssh.run(server_command, background=True) == 0 - def run_tcp_client (self, servername, port, retry=5): - client_command = "./tcptest.py client -a {} -p {}".format(servername, port) + def run_tcp_client(self, servername, port, retry=5): + client_command = "./tcptest.py client -a {} -p {}"\ + .format(servername, port) if self.test_ssh.copy("tcptest.py") != 0: return False if self.test_ssh.run(client_command) == 0: @@ -57,34 +59,33 @@ class TestSliver: return False # use the node's main ssh root entrance, as the slice entrance might be down - #def tar_var_logs (self): + #def tar_var_logs(self): # return self.test_ssh.actual_command("sudo tar -C /var/log -cf - .") - def tar_var_logs (self): + def tar_var_logs(self): test_ssh = self.test_node.create_test_ssh() dir_to_tar = "/vservers/{}/var/log".format(self.test_slice.name()) return test_ssh.actual_command("tar -C {} -cf - .".format(dir_to_tar)) - - def check_hooks (self): + + def check_hooks(self): print('NOTE: slice hooks check scripts NOT (yet?) run in sudo') extensions = [ 'py','pl','sh' ] path = 'hooks/slice/' - scripts = utils.locate_hooks_scripts ('sliver '+self.name(), path,extensions) + scripts = utils.locate_hooks_scripts('sliver '+self.name(), path,extensions) overall = True for script in scripts: - if not self.check_hooks_script (script): + if not self.check_hooks_script(script): overall = False return overall - def check_hooks_script (self,local_script): + def check_hooks_script(self,local_script): script_name = os.path.basename(local_script) - utils.header ("SLIVER hook {} ({})".format(script_name, self.name())) + utils.header("SLIVER hook {} ({})".format(script_name, self.name())) test_ssh = self.create_test_ssh() test_ssh.copy_home(local_script) if test_ssh.run("./"+script_name) != 0: - utils.header ("WARNING: hooks check script {} FAILED (ignored)".format(script_name)) + utils.header("WARNING: hooks check script {} FAILED (ignored)".format(script_name)) #return False return True else: - utils.header ("SUCCESS: sliver hook {} OK".format(script_name)) + utils.header("SUCCESS: sliver hook {} OK".format(script_name)) return True - diff --git a/system/tcptest.py b/system/tcptest.py index 88c2b0d..b83db0b 100755 --- a/system/tcptest.py +++ b/system/tcptest.py @@ -65,7 +65,9 @@ class Server: parser.print_help() sys.exit(1) - myprint("==================== tcptest.py server", id='server') + myprint("==================== tcptest.py server on {}:{}" + .format(args.address, args.port), + id='server') show_network_status(id='server') server = socketserver.TCPServer((args.address, args.port), UppercaseRequestHandler) @@ -137,7 +139,9 @@ class Client: parser.print_help() sys.exit(1) - myprint("==================== tcptest.py client", id='client') + myprint("==================== tcptest.py client -> {}:{}" + .format(args.address, args.port), + id='client') result = True for i in range(1, args.loops+1): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)