From 33c639793610c1b4ea868dcb8c609d091955d9ef Mon Sep 17 00:00:00 2001 From: Mika Tammi Date: Fri, 3 Nov 2023 13:17:32 +0200 Subject: [PATCH] netvm.robot: Wait for local_port to be free SSH Local Port Forwarding is used to connect to the NetVM, but for some reason some times there is a lag between freeing the bound socket, causing "Adress is already in use" -error when trying to bind to it again. Signed-off-by: Mika Tammi --- Robot-Framework/test-suites/bat-tests/netvm.robot | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Robot-Framework/test-suites/bat-tests/netvm.robot b/Robot-Framework/test-suites/bat-tests/netvm.robot index 82d21c0..68acad1 100644 --- a/Robot-Framework/test-suites/bat-tests/netvm.robot +++ b/Robot-Framework/test-suites/bat-tests/netvm.robot @@ -105,12 +105,22 @@ Connect to ghaf host Set Global Variable ${ghaf_host} ${connection} [Return] ${connection} +Port Should Be Free + [Arguments] ${port} + ${result} Run Keyword If os.sep == '/' + ... Run netstat -tulpn + ... ELSE + ... Run netstat -an + Should Not Contain ${result} :${port} + [Return] ${result} + Connect to netvm via tunnel [Documentation] Create tunnel using port ${local_port}, connect to netvm directly from test run machine, ... allow using standard SSHLibrary commands, like 'Execute Command' Switch connection ${ghaf_host} Log To Console Configuring tunnel... Write ssh-keygen -R ${netvm_ip} + Wait Until Keyword Succeeds 2 min 10s Port Should Be Free ${local_port} Create Local Ssh Tunnel local_port=${local_port} remote_host=${NETVM_IP} remote_port=22 bind_address=127.0.0.1 Log To Console Connecting to NetVM via tunnel ${connection}= Connect IP=localhost PORT=${local_port} target_output=${LOGIN}@${NETVM_NAME}