Skip to content

Commit

Permalink
fix(grpc): Fix large payload handling when using the emulator.
Browse files Browse the repository at this point in the history
Align ndb emulator grpc channel overrides with production overrides.
  • Loading branch information
pcostell committed Mar 15, 2024
1 parent 8f4486f commit b4db83f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
8 changes: 7 additions & 1 deletion google/cloud/ndb/client.py
Expand Up @@ -147,7 +147,13 @@ 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
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 b4db83f

Please sign in to comment.