Skip to content

Commit 696548b

Browse files
authored
fix(grpc): Fix large payload handling when using the emulator. (#975)
Align ndb emulator grpc channel overrides with production overrides.
1 parent 1f7e00f commit 696548b

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

packages/google-cloud-ndb/google/cloud/ndb/client.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,14 @@ def __init__(
147147
)
148148

149149
if emulator:
150-
channel = grpc.insecure_channel(self.host)
150+
channel = grpc.insecure_channel(
151+
self.host,
152+
options=[
153+
# Default options provided in DatastoreGrpcTransport, but not when we override the channel.
154+
("grpc.max_send_message_length", -1),
155+
("grpc.max_receive_message_length", -1),
156+
],
157+
)
151158
else:
152159
user_agent = self.client_info.to_user_agent()
153160
channel = _helpers.make_secure_channel(

packages/google-cloud-ndb/tests/system/test_crud.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,24 @@ def insert(foo):
401401
thread2.join()
402402

403403

404+
@pytest.mark.usefixtures("client_context")
405+
def test_large_rpc_lookup(dispose_of, ds_client):
406+
class SomeKind(ndb.Model):
407+
foo = ndb.TextProperty()
408+
409+
foo = "a" * (500 * 1024)
410+
411+
keys = []
412+
for i in range(15):
413+
key = SomeKind(foo=foo).put()
414+
dispose_of(key._key)
415+
keys.append(key)
416+
417+
retrieved = ndb.get_multi(keys)
418+
for entity in retrieved:
419+
assert entity.foo == foo
420+
421+
404422
@pytest.mark.usefixtures("client_context")
405423
def test_large_json_property(dispose_of, ds_client):
406424
class SomeKind(ndb.Model):

0 commit comments

Comments
 (0)