Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(grpc): Fix large payload handling when using the emulator. #975

Merged
merged 1 commit into from Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion google/cloud/ndb/client.py
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
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