From: Jozef Behran Date: Fri, 13 Nov 2015 11:29:19 +0000 (+0100) Subject: Fixed "close connection" action in MDSAL suite X-Git-Tag: release/lithium-sr3~33 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=integration%2Ftest.git;a=commitdiff_plain;h=500faa3ca6b5487e445db8756b6fb410dbffd966 Fixed "close connection" action in MDSAL suite Sending "^D" to the netconf connection does not guarantee that the connection is closed properly, leading to a spurious test failure due to failed teardown. The proper way is to open two connections, one "control" and one "netconf". The "netconf" connection then connects to netconf as usual and the "control" connection is used to control the SSH process connecting to netconf. It is used to obtain the PID of the "sshpass" process which governs the connection and to send the kill signal to that process once the connection is to be closed. Change-Id: I3a0bc1e03d1af9619ced3fa7dfcd45aad3d696fa Signed-off-by: Jozef Behran --- diff --git a/csit/suites/netconf/MDSAL/northbound.robot b/csit/suites/netconf/MDSAL/northbound.robot index b3df4cde05..68b9322e0b 100644 --- a/csit/suites/netconf/MDSAL/northbound.robot +++ b/csit/suites/netconf/MDSAL/northbound.robot @@ -29,6 +29,7 @@ Library RequestsLibrary Library SSHLibrary Resource ${CURDIR}/../../../libraries/FailFast.robot Resource ${CURDIR}/../../../libraries/SetupUtils.robot +Resource ${CURDIR}/../../../libraries/SSHKeywords.robot Resource ${CURDIR}/../../../libraries/Utils.robot Variables ${CURDIR}/../../../variables/Variables.py @@ -261,10 +262,19 @@ Open_ODL_Netconf_Connection # going to need to use this operation (Netconf Performance and Scaling # comes to my mind now as one of the things tested is the performance # of the direct netconf connection. - SSHLibrary.Open_Connection ${host} prompt=${ODL_SYSTEM_PROMPT} timeout=10s + ${control}= SSHLibrary.Open_Connection ${host} prompt=${ODL_SYSTEM_PROMPT} timeout=10s Utils.Flexible_Controller_Login + BuiltIn.Set_Suite_Variable ${ssh_control} ${control} + ${netconf}= SSHLibrary.Open_Connection ${host} prompt=${ODL_SYSTEM_PROMPT} timeout=10s + Utils.Flexible_Controller_Login + BuiltIn.Set_Suite_Variable ${ssh_netconf} ${netconf} SSHLibrary.Write sshpass -p ${password} ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${user}\@127.0.0.1 -p ${port} -s netconf ${hello}= SSHLibrary.Read_Until ${ODL_NETCONF_PROMPT} + SSHLibrary.Switch_Connection ${ssh_control} + SSHLibrary.Write ps -A | grep sshpass | cut -b 1-6 + ${pid}= SSHKeywords.Read_Command_Response + BuiltIn.Set_Suite_Variable ${ssh_netconf_pid} ${pid} + SSHLibrary.Switch_Connection ${ssh_netconf} [Return] ${hello} Transmit_Message @@ -307,7 +317,10 @@ Load_Expected_Reply Close_ODL_Netconf_Connection [Documentation] Correctly close the Netconf connection and make sure it is really dead. - Utils.Write_Bare_Ctrl_D + SSHLibrary.Switch_Connection ${ssh_control} + SSHLibrary.Write kill ${ssh_netconf_pid} + SSHLibrary.Read_Until_Prompt + SSHLibrary.Switch_Connection ${ssh_netconf} SSHLibrary.Read_Until_Prompt Setup_Everything