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 <jbehran@cisco.com>
Library SSHLibrary
Resource ${CURDIR}/../../../libraries/FailFast.robot
Resource ${CURDIR}/../../../libraries/SetupUtils.robot
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
Resource ${CURDIR}/../../../libraries/Utils.robot
Variables ${CURDIR}/../../../variables/Variables.py
# 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.
# 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
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.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
[Return] ${hello}
Transmit_Message
Close_ODL_Netconf_Connection
[Documentation] Correctly close the Netconf connection and make sure it is really dead.
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
SSHLibrary.Read_Until_Prompt
Setup_Everything