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

Possible race condition when closing tunnel created using Create Local Ssh Tunnel #435

Open
mikatammi opened this issue Nov 3, 2023 · 2 comments · May be fixed by #436
Open

Possible race condition when closing tunnel created using Create Local Ssh Tunnel #435

mikatammi opened this issue Nov 3, 2023 · 2 comments · May be fixed by #436

Comments

@mikatammi
Copy link

mikatammi commented Nov 3, 2023

Steps to reproduce:

Have multiple test cases run after another, which do "Create Local Ssh Tunnel" in setup-phase, and "Close All Connections" in teardown-phase.

Expected results:

Close All Connections would close all the connections, and then the Create Local Ssh Tunnel would simply work.

What really happens:

As in the picture below, the tests start to say OSError: [Errno 98] Address already in use

image

I'm suspecting there should be some kind of wait, eg. t.wait() for the thread after calling shutdown here: https://github.com/robotframework/SSHLibrary/blob/master/src/SSHLibrary/pythonforward.py#L44

@mikatammi
Copy link
Author

mikatammi commented Nov 3, 2023

I'm able to circumvent around the issue by using this keyword which I copy-pasted from the test cases of the SSHLibrary, but I still think it would be nice to fix the actual issue:

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}

and then call Wait Until Keyword Succeeds 2 min 10s Port Should Be Free ${local_port} before calling the "Create Local Ssh Tunnel"

tiiuae/ci-test-automation@a790633

@mikatammi
Copy link
Author

From the documentatin of socketserver:
"Finally, call server_close() to close the socket (unless you used a with statement).". So I think the line self.server.server_close() should be added after the shutdown to clean things up

mikatammi added a commit to mikatammi/SSHLibrary that referenced this issue Nov 3, 2023
This should fix robotframework#435

Signed-off-by: Mika Tammi <mika.tammi@unikie.com>
@mikatammi mikatammi linked a pull request Nov 3, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant