Merge lp:~jameinel/bzr/2.3-bzr-connect-ssh into lp:bzr
Status: | Merged |
---|---|
Approved by: | Vincent Ladeuil |
Approved revision: | no longer in the source branch. |
Merged at revision: | 5405 |
Proposed branch: | lp:~jameinel/bzr/2.3-bzr-connect-ssh |
Merge into: | lp:bzr |
Diff against target: |
112 lines (+31/-24) 3 files modified
NEWS (+3/-0) bzrlib/tests/stub_sftp.py (+28/-22) bzrlib/tests/test_transport.py (+0/-2) |
To merge this branch: | bzr merge lp:~jameinel/bzr/2.3-bzr-connect-ssh |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Vincent Ladeuil | Approve | ||
Review via email: mp+34331@code.launchpad.net |
Commit message
Fix bug #626876 by properly waiting for the paramiko.Transport thread to finish its work.
Description of the change
This should fix the failing test that we started skipping.
Specifically, the code was expecting "ssh_server.
However, it turns out that it returns as soon as "negotiation" has completed, not when it is done with the conversation.
It turns out that paramiko will set the "self.completio
As such, I went ahead and created a different event for us to wait on, that just triggers when the thread is actually done running. Maybe we could just use "ssh_server.
Part of the confusion is that:
a) TestServerInAThread is run in a thread, when it gets a connection it
b) Starts a new thread and calls process_request, which ends up calling
finish_request which is where the TestSFTPConnect
in __init__ it calls self.setup()
c) self.setup() spawns a new thread in paramiko.Transport. Though it isn't obvious at
first that paramiko.Transport is actually a subclass of Thread.
Anyway, it makes sense to have the test 'process_request' thread just wait for the paramiko.Transport thread to finish. Arguably we shouldn't be threaded at that level at all, and SftpServer shouldn't be spawning threads per request. (Instead we should just have the main SftpServer thread which spawns and waits for paramiko.Transport threads directly.)
This code works, the test passes reliably, and it doesn't seem to have affected any other tests negatively.
bzr selftest -s bt.test_transport bzr_ssh
bzr selftest "(?i)sftp"
An even simpler one that works is to just change the line:
time.sleep(0.2)
to
ssh_server.join()
I've gone ahead and switched to that one, as I think it is easier to understand.