Merge lp:~facundo/ubuntuone-client/support-initial-disconnection into lp:ubuntuone-client

Proposed by Facundo Batista
Status: Merged
Approved by: Facundo Batista
Approved revision: 937
Merged at revision: 941
Proposed branch: lp:~facundo/ubuntuone-client/support-initial-disconnection
Merge into: lp:ubuntuone-client
Diff against target: 67 lines (+37/-3)
2 files modified
tests/syncdaemon/test_action_queue.py (+24/-0)
ubuntuone/syncdaemon/action_queue.py (+13/-3)
To merge this branch: bzr merge lp:~facundo/ubuntuone-client/support-initial-disconnection
Reviewer Review Type Date Requested Status
Facundo Batista (community) Approve
Guillermo Gonzalez Approve
Review via email: mp+56569@code.launchpad.net

Commit message

Support connection ended in initial dialog with server (LP: #711211).

Description of the change

Support connection ended in initial dialog with server.

Tests included.

To post a comment you must log in.
Revision history for this message
Guillermo Gonzalez (verterok) :
review: Approve
Revision history for this message
Facundo Batista (facundo) wrote :

Approved with one review

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/syncdaemon/test_action_queue.py'
2--- tests/syncdaemon/test_action_queue.py 2011-03-29 15:23:30 +0000
3+++ tests/syncdaemon/test_action_queue.py 2011-04-06 13:45:55 +0000
4@@ -3845,6 +3845,30 @@
5 event, str(exc)))
6
7 @defer.inlineCallbacks
8+ def assert_send_request_and_handle_errors_on_connection_end(self, exc):
9+ """_send_request_and_handle_errors is ok when connection lost/done."""
10+ request = self.fail_please(exc)
11+ kwargs = dict(request=request, request_error=SpecificException,
12+ event_error='BAR', event_ok='FOO')
13+ d = self.action_queue._send_request_and_handle_errors(**kwargs)
14+ yield d
15+
16+ # check that SYS_UNKNOWN_ERROR wasn't sent, and that logged ok
17+ events = self.action_queue.event_queue.events
18+ self.assertNotIn('SYS_UNKNOWN_ERROR', [x[0] for x in events])
19+ self.assertTrue(self.handler.check_info(request.__name__, str(exc)))
20+
21+ def test_send_request_and_handle_errors_on_connection_lost(self):
22+ """_send_request_and_handle_errors is correct when connection lost."""
23+ e = twisted_error.ConnectionLost()
24+ return self.assert_send_request_and_handle_errors_on_connection_end(e)
25+
26+ def test_send_request_and_handle_errors_on_connection_done(self):
27+ """_send_request_and_handle_errors is correct when connection lost."""
28+ e = twisted_error.ConnectionDone()
29+ return self.assert_send_request_and_handle_errors_on_connection_end(e)
30+
31+ @defer.inlineCallbacks
32 def assert_send_request_and_handle_errors_on_server_error(self, serr):
33 """_send_request_and_handle_errors is correct when server error."""
34 # XXX: we need to replace this list with and exception list
35
36=== modified file 'ubuntuone/syncdaemon/action_queue.py'
37--- ubuntuone/syncdaemon/action_queue.py 2011-03-29 15:23:30 +0000
38+++ ubuntuone/syncdaemon/action_queue.py 2011-04-06 13:45:55 +0000
39@@ -881,6 +881,12 @@
40 except request_error, failure:
41 event = event_error
42 self.event_queue.push(event_error, error=str(failure))
43+ except (twisted_errors.ConnectionLost,
44+ twisted_errors.ConnectionDone), failure:
45+ # connection ended, just don't do anything: the SYS_CONNECTION_ETC
46+ # will be sent by normal client/protocol mechanisms, and logging
47+ # will be done later in this function.
48+ pass
49 except protocol_errors.AuthenticationRequiredError, failure:
50 # we need to separate this case from the rest because an
51 # AuthenticationRequiredError is an StorageRequestError,
52@@ -902,9 +908,13 @@
53 self.event_queue.push(event_ok)
54
55 if failure is not None:
56- logger.info("The request '%s' failed with the error: %s "
57- "and was handled with the event: %s",
58- req_name, failure, event)
59+ if event is None:
60+ logger.info("The request '%s' failed with the error: %s",
61+ req_name, failure)
62+ else:
63+ logger.info("The request '%s' failed with the error: %s "
64+ "and was handled with the event: %s",
65+ req_name, failure, event)
66 else:
67 defer.returnValue(result)
68

Subscribers

People subscribed via source and target branches