Skip to content

Commit

Permalink
fix(grpc): Fix large payload handling when using the emulator. (#975)
Browse files Browse the repository at this point in the history
Align ndb emulator grpc channel overrides with production overrides.
  • Loading branch information
pcostell authored Mar 16, 2024
1 parent 8f4486f commit d9162ae
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
9 changes: 8 additions & 1 deletion google/cloud/ndb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,14 @@ def __init__(
)

if emulator:
channel = grpc.insecure_channel(self.host)
channel = grpc.insecure_channel(
self.host,
options=[
# Default options provided in DatastoreGrpcTransport, but not when we override the channel.
("grpc.max_send_message_length", -1),
("grpc.max_receive_message_length", -1),
],
)
else:
user_agent = self.client_info.to_user_agent()
channel = _helpers.make_secure_channel(
Expand Down
18 changes: 18 additions & 0 deletions tests/system/test_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,24 @@ def insert(foo):
thread2.join()


@pytest.mark.usefixtures("client_context")
def test_large_rpc_lookup(dispose_of, ds_client):
class SomeKind(ndb.Model):
foo = ndb.TextProperty()

foo = "a" * (500 * 1024)

keys = []
for i in range(15):
key = SomeKind(foo=foo).put()
dispose_of(key._key)
keys.append(key)

retrieved = ndb.get_multi(keys)
for entity in retrieved:
assert entity.foo == foo


@pytest.mark.usefixtures("client_context")
def test_large_json_property(dispose_of, ds_client):
class SomeKind(ndb.Model):
Expand Down

0 comments on commit d9162ae

Please sign in to comment.