Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetVM: Wait for port to be free, before creating SSH Local port forward #59

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion Robot-Framework/test-suites/bat-tests/netvm.robot
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,27 @@ 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}
# TODO: Remove this workaround when the issue gets fixed upstream.
# There's an issue in robotframework-sshlibrary, which causes that the port
# is left open for some time even after explicitly calling
# "Close All Connections":
# https://github.com/robotframework/SSHLibrary/issues/435
# https://github.com/robotframework/SSHLibrary/pull/436
Wait Until Keyword Succeeds 1 min 5s 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