def setUp(self): self._mock_datastore = MagicMock() self._query = query_pb2.Query() self._query.kind.add().name = 'dummy_kind' patch_retry(self, helper) self._retriable_errors = [ RPCError("dummy", code_pb2.INTERNAL, "failed"), SocketError(errno.ECONNRESET, "Connection Reset"), SocketError(errno.ETIMEDOUT, "Timed out") ] self._non_retriable_errors = [ RPCError("dummy", code_pb2.UNAUTHENTICATED, "failed"), SocketError(errno.EADDRNOTAVAIL, "Address not available") ]
def permanent_retriable_datastore_failure(self, req): raise RPCError("dummy", code_pb2.UNAVAILABLE, "failed")
def non_retriable_datastore_failure(self, req): raise RPCError("dummy", code_pb2.UNAUTHENTICATED, "failed")
def transient_retriable_datastore_failure(self, req): if self._transient_fail_count: self._transient_fail_count -= 1 raise RPCError("dummy", code_pb2.INTERNAL, "failed") else: return datastore_pb2.RunQueryResponse()
def transient_datastore_failure(self, req): if self._transient_fail_count: self._transient_fail_count -= 1 raise RPCError("dummy", 500, "failed") else: return datastore_pb2.RunQueryResponse()
def permanent_datastore_failure(self, req): raise RPCError("dummy", 500, "failed")