From: Alex Yang Date: Mon, 14 Aug 2017 15:47:37 +0000 (+0800) Subject: Fix validate_ssh_client X-Git-Tag: opnfv-5.0.0~7 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=acc4428e76422ad5c60f5433f325258214e6bc3b;p=snaps.git Fix validate_ssh_client After the "try..finally.." statement is executed, the ssh_client is closed by the "finally" statement. So the out.channel.in_buffer is not readable and the testcases failed. Change-Id: I3fbf620cb9ccee62c515b83fed9fd01238ad3262 Signed-off-by: Alex Yang --- diff --git a/snaps/openstack/tests/create_instance_tests.py b/snaps/openstack/tests/create_instance_tests.py index 1ef96fd..19173d2 100644 --- a/snaps/openstack/tests/create_instance_tests.py +++ b/snaps/openstack/tests/create_instance_tests.py @@ -1766,18 +1766,17 @@ def validate_ssh_client(instance_creator): if ssh_client: try: out = ssh_client.exec_command('pwd')[1] + channel = out.channel + in_buffer = channel.in_buffer + pwd_out = in_buffer.read(1024) + if not pwd_out or len(pwd_out) < 10: + return False + return True finally: ssh_client.close() else: return False - channel = out.channel - in_buffer = channel.in_buffer - pwd_out = in_buffer.read(1024) - if not pwd_out or len(pwd_out) < 10: - return False - return True - return False