Skip to content

Commit

Permalink
netvm.robot: Wait for local_port to be free
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Mika Tammi committed Nov 3, 2023
1 parent d72dcdf commit 33c6397
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Robot-Framework/test-suites/bat-tests/netvm.robot
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 33c6397

Please sign in to comment.