Merge lp:~nataliabidart/ubuntuone-client/server-rescan-handles-errors-from-server into lp:ubuntuone-client

Proposed by Natalia Bidart
Status: Merged
Approved by: dobey
Approved revision: 490
Merged at revision: not available
Proposed branch: lp:~nataliabidart/ubuntuone-client/server-rescan-handles-errors-from-server
Merge into: lp:ubuntuone-client
Diff against target: 198 lines (+123/-25)
2 files modified
tests/syncdaemon/test_action_queue.py (+90/-0)
ubuntuone/syncdaemon/action_queue.py (+33/-25)
To merge this branch: bzr merge lp:~nataliabidart/ubuntuone-client/server-rescan-handles-errors-from-server
Reviewer Review Type Date Requested Status
Guillermo Gonzalez Approve
Facundo Batista (community) Approve
Review via email: mp+23260@code.launchpad.net

Commit message

Refactored ActionQueue.server_rescan so generic error handling is made.

Description of the change

Refactored ActionQueue.server_rescan so generic error handling is made.

The erro handling is done usingthe generic helper added in former branches. Please note that the special case of firing or not the self.deferred should be removed once Bug #561736 is resolved.

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

Like it!

review: Approve
Revision history for this message
Guillermo Gonzalez (verterok) :
review: Approve
Revision history for this message
John Lenton (chipaca) wrote :
Download full text (8.5 KiB)

The attempt to merge lp:~nataliabidart/ubuntuone-client/server-rescan-handles-errors-from-server into lp:ubuntuone-client failed.Below is the output from the failed tests.

Using saved parent location: bzr+ssh://bazaar.launchpad.net/~ubuntuone-control-tower/ubuntuone-storage-protocol/trunk/
No revisions to pull.
/usr/bin/gnome-autogen.sh
checking for autoconf >= 2.53...
(B testing autoconf2.50... not found.
  testing autoconf... found 2.65
checking for automake >= 1.10...
(B testing automake-1.11... found 1.11.1
checking for libtool >= 1.5...
(B testing libtoolize... found 2.2.6b
checking for intltool >= 0.30...
(B testing intltoolize... found 0.41.0
checking for pkg-config >= 0.14.0...
(B testing pkg-config... found 0.22
Checking for required M4 macros...
(BChecking for forbidden M4 macros...
(BProcessing ./configure.ac
(BRunning libtoolize...
(Blibtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
Running intltoolize...
(BRunning aclocal-1.11...
(BRunning autoconf...
(BRunning autoheader...
(BRunning automake-1.11...
(BRunning ./configure --prefix=/home/john/canonical/ubuntuone-storage-protocol/trunk ...
(Bchecking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for library containing strerror... none required
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of comm...

Read more...

Revision history for this message
John Lenton (chipaca) wrote :
Download full text (10.2 KiB)

The attempt to merge lp:~nataliabidart/ubuntuone-client/server-rescan-handles-errors-from-server into lp:ubuntuone-client failed.Below is the output from the failed tests.

Using saved parent location: bzr+ssh://bazaar.launchpad.net/~ubuntuone-control-tower/ubuntuone-storage-protocol/trunk/
No revisions to pull.
/usr/bin/gnome-autogen.sh
checking for autoconf >= 2.53...
(B testing autoconf2.50... not found.
  testing autoconf... found 2.65
checking for automake >= 1.10...
(B testing automake-1.11... found 1.11.1
checking for libtool >= 1.5...
(B testing libtoolize... found 2.2.6b
checking for intltool >= 0.30...
(B testing intltoolize... found 0.41.0
checking for pkg-config >= 0.14.0...
(B testing pkg-config... found 0.22
Checking for required M4 macros...
(BChecking for forbidden M4 macros...
(BProcessing ./configure.ac
(BRunning libtoolize...
(Blibtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
Running intltoolize...
(BRunning aclocal-1.11...
(BRunning autoconf...
(BRunning autoheader...
(BRunning automake-1.11...
(BRunning ./configure --with-protocol=/home/john/canonical/ubuntuone-storage-protocol/trunk ...
(Bchecking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for library containing strerror... none required
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length ...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/syncdaemon/test_action_queue.py'
--- tests/syncdaemon/test_action_queue.py 2010-04-12 15:55:43 +0000
+++ tests/syncdaemon/test_action_queue.py 2010-04-12 19:44:26 +0000
@@ -1935,6 +1935,25 @@
1935 self.assertFalse(self.action_queue.deferred.called)1935 self.assertFalse(self.action_queue.deferred.called)
19361936
1937 @defer.inlineCallbacks1937 @defer.inlineCallbacks
1938 def test_send_request_and_handle_errors_when_fire_deferred_false(self):
1939 """_send_request_and_handle_errors doesn't fire the deferred."""
1940
1941 event = 'SYS_SPECIFIC_ERROR'
1942 EVENTS[event] = ('error',) # add event to the global valid events list
1943 self.addCleanup(lambda: EVENTS.pop(event))
1944
1945 exc = SpecificException('The request failed!')
1946 request = self.fail_please(exc)
1947 kwargs = dict(request=request, request_error=SpecificException,
1948 event_error=event, event_ok='YADDA_YADDA',
1949 fire_deferred=False)
1950 d = self.action_queue._send_request_and_handle_errors(**kwargs)
1951 yield d
1952
1953 # assert internal deferred wasn't fired
1954 self.assertFalse(self.action_queue.deferred.called)
1955
1956 @defer.inlineCallbacks
1938 def test_check_version_when_unsupported_version_exception(self):1957 def test_check_version_when_unsupported_version_exception(self):
1939 """Test error handling after UnsupportedVersionError."""1958 """Test error handling after UnsupportedVersionError."""
1940 # raise a UnsupportedVersionError1959 # raise a UnsupportedVersionError
@@ -2059,3 +2078,74 @@
20592078
2060 # assert internal deferred was fired2079 # assert internal deferred was fired
2061 self.assertTrue(self.action_queue.deferred.called)2080 self.assertTrue(self.action_queue.deferred.called)
2081
2082 @defer.inlineCallbacks
2083 def test_server_rescan_as_a_whole(self):
2084 """Test error handling after server_rescan with no error."""
2085
2086 def faked_get_root(marker):
2087 """Fake the action_queue.get_root."""
2088 root_id=object()
2089 self.action_queue.event_queue.push('SYS_ROOT_RECEIVED',
2090 root_id=root_id)
2091 return root_id
2092
2093 self.patch(self.action_queue, 'get_root', faked_get_root)
2094
2095 self.action_queue.client.query = \
2096 self.succeed_please(result=self.action_queue.client)
2097 yield self.action_queue.server_rescan(root_mdid=object(), data_gen=list)
2098 event = ('SYS_SERVER_RESCAN_DONE', (), {})
2099 self.assertEqual(event, self.action_queue.event_queue.events[-1])
2100
2101 # assert internal deferred wasn't fired
2102 self.assertFalse(self.action_queue.deferred.called)
2103
2104 @defer.inlineCallbacks
2105 def test_server_rescan_when_get_root_fails(self):
2106 """Test error handling after server_rescan when get_root fails."""
2107
2108 msg = protocol_pb2.Message()
2109 msg.type = protocol_pb2.Message.ERROR
2110 msg.error.type = protocol_pb2.Error.PROTOCOL_ERROR
2111 msg.error.comment = 'get_root failed'
2112 exc = errors.StorageRequestError(request=None, message=msg)
2113 self.patch(self.action_queue, 'get_root', self.fail_please(exc))
2114
2115 self.action_queue.client.query = self.fail_please(NotImplementedError())
2116
2117 yield self.action_queue.server_rescan(root_mdid=object(), data_gen=list)
2118
2119 event = ('SYS_SERVER_RESCAN_DONE', (), {})
2120 self.assertNotIn(event, self.action_queue.event_queue.events)
2121
2122 event = ('SYS_SERVER_ERROR', (), {'error': str(exc)})
2123 self.assertEqual(event, self.action_queue.event_queue.events[-1])
2124
2125 # assert internal deferred wasn't fired
2126 self.assertFalse(self.action_queue.deferred.called)
2127
2128 @defer.inlineCallbacks
2129 def test_server_rescan_when_query_fails(self):
2130 """Test error handling after server_rescan when query fails."""
2131
2132 self.patch(self.action_queue, 'get_root',
2133 self.succeed_please(result=object()))
2134
2135 msg = protocol_pb2.Message()
2136 msg.type = protocol_pb2.Message.ERROR
2137 msg.error.type = protocol_pb2.Error.PROTOCOL_ERROR
2138 msg.error.comment = 'query failed'
2139 exc = errors.StorageRequestError(request=None, message=msg)
2140 self.action_queue.client.query = self.fail_please(exc)
2141
2142 yield self.action_queue.server_rescan(root_mdid=object(), data_gen=list)
2143
2144 event = ('SYS_SERVER_RESCAN_DONE', (), {})
2145 self.assertNotIn(event, self.action_queue.event_queue.events)
2146
2147 event = ('SYS_SERVER_ERROR', (), {'error': str(exc)})
2148 self.assertEqual(event, self.action_queue.event_queue.events[-1])
2149
2150 # assert internal deferred wasn't fired
2151 self.assertFalse(self.action_queue.deferred.called)
20622152
=== modified file 'ubuntuone/syncdaemon/action_queue.py'
--- ubuntuone/syncdaemon/action_queue.py 2010-04-12 15:55:43 +0000
+++ ubuntuone/syncdaemon/action_queue.py 2010-04-12 19:44:26 +0000
@@ -886,6 +886,7 @@
886 @defer.inlineCallbacks886 @defer.inlineCallbacks
887 def _send_request_and_handle_errors(self, request, request_error,887 def _send_request_and_handle_errors(self, request, request_error,
888 event_error, event_ok,888 event_error, event_ok,
889 fire_deferred=True,
889 args=(), kwargs={}):890 args=(), kwargs={}):
890 """Send 'request' to the server, using params 'args' and 'kwargs'.891 """Send 'request' to the server, using params 'args' and 'kwargs'.
891892
@@ -907,7 +908,7 @@
907 finally:908 finally:
908 # common handling for all cases909 # common handling for all cases
909 if client is not self.client:910 if client is not self.client:
910 client_mismatch_msg = "Client mismatch while processing "\911 client_mismatch_msg = "Client mismatch while processing " \
911 "the request '%s', " \912 "the request '%s', " \
912 "client (%r) is not self.client (%r)."913 "client (%r) is not self.client (%r)."
913 logger.warning(client_mismatch_msg, req_name,914 logger.warning(client_mismatch_msg, req_name,
@@ -932,9 +933,10 @@
932 if failure is not None:933 if failure is not None:
933 logger.error("The request '%s' failed with the error:\n\n%s\n",934 logger.error("The request '%s' failed with the error:\n\n%s\n",
934 req_name, failure)935 req_name, failure)
935 # it looks like we won't be authenticating, so hook up the936 if fire_deferred:
936 # for-testing deferred now937 # it looks like we won't be authenticating, so hook up the
937 self.deferred.callback(Failure(failure))938 # for-testing deferred now
939 self.deferred.callback(Failure(failure))
938 else:940 else:
939 defer.returnValue(result)941 defer.returnValue(result)
940942
@@ -998,31 +1000,37 @@
998 # callback the deferred if everything went ok1000 # callback the deferred if everything went ok
999 self.deferred.callback(self.client)1001 self.deferred.callback(self.client)
10001002
1001 @defer.inlineCallbacks
1002 def server_rescan(self, root_mdid, data_gen):1003 def server_rescan(self, root_mdid, data_gen):
1003 """Do the server rescan."""1004 """Do the server rescan."""
1004 client = self.client1005
1005 yield self.get_root(root_mdid)1006 @defer.inlineCallbacks
1006 if client is not self.client:1007 def _get_root_and_query(root_mdid, data_gen):
1007 return1008 """Get user's root and then query each element in data_gen()."""
1008 data = data_gen()1009 yield self.get_root(root_mdid)
1009 logger.info("Server rescan: will query %d objects", len(data))1010 data = data_gen()
1010 # we check we're going to actually log, because this could be expensive1011 logger.info("Server rescan: will query %d objects", len(data))
1011 if logger.isEnabledFor(TRACE):1012 # check we're going to actually log, because this could be expensive
1012 for share, node, hash in data:1013 if logger.isEnabledFor(TRACE):
1013 logger.trace("Server rescan: share: %r, node: %r, hash: %s",1014 for share, node, hash in data:
1014 share or '/root/', node, hash)1015 logger.trace("Server rescan: share: %r, node: %r, hash: %s",
1015 logger.trace("Server rescan: all data shown")1016 share or '/root/', node, hash)
1016 yield client.query(data)1017 logger.trace("Server rescan: all data shown")
1017 if client is not self.client:1018 yield self.client.query(data)
1018 return1019
1019 logger.info("Server rescan: done")1020 get_root_and_query_d = self._send_request_and_handle_errors(
1020 self.event_queue.push('SYS_SERVER_RESCAN_DONE')1021 request=_get_root_and_query,
1022 request_error=None, event_error=None,
1023 event_ok='SYS_SERVER_RESCAN_DONE', fire_deferred=False,
1024 args=(root_mdid, data_gen)
1025 )
1026 return get_root_and_query_d
10211027
1022 def get_root(self, marker):1028 def get_root(self, marker):
1023 """1029 """Get the user's root uuid.
1024 Get the user's root uuid. Use the uuid_map, so the caller can1030
1025 use the marker in followup operations.1031 Use the uuid_map, so the caller can use the marker in followup
1032 operations.
1033
1026 """1034 """
1027 log = mklog(logger, 'get_root', '', marker, marker=marker)1035 log = mklog(logger, 'get_root', '', marker, marker=marker)
1028 log.debug('starting')1036 log.debug('starting')

Subscribers

People subscribed via source and target branches