Skip to content

Commit 504ca92

Browse files
committed
test: add a test case for grpcMaxMessageSize
1 parent 62cd546 commit 504ca92

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

src/it/java/io/weaviate/containers/Weaviate.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ public Builder withApiKeys(String... apiKeys) {
197197
return this;
198198
}
199199

200+
public Builder withGrpcMaxMessageSize(int bytes) {
201+
environment.put("GRPC_MAX_MESSAGE_SIZE", String.valueOf(bytes));
202+
return this;
203+
}
204+
200205
public Builder enableTelemetry(boolean enable) {
201206
environment.put("DISABLE_TELEMETRY", Boolean.toString(!enable));
202207
return this;

src/it/java/io/weaviate/integration/SearchITest.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.assertj.core.api.InstanceOfAssertFactories;
1414
import org.junit.BeforeClass;
1515
import org.junit.ClassRule;
16+
import org.junit.Ignore;
1617
import org.junit.Test;
1718
import org.junit.rules.TestRule;
1819

@@ -667,4 +668,32 @@ public void testGenerative_bm25_groupBy() throws IOException {
667668
.extracting(TaskOutput::text, InstanceOfAssertFactories.STRING)
668669
.isNotBlank();
669670
}
671+
672+
/**
673+
* Ensure the client respects server's configuration for max gRPC size:
674+
* we create a server with 1-byte message size and try to send a large payload
675+
* there. If the channel is configured correctly, it will refuse to send it.
676+
*/
677+
@Test
678+
@Ignore("Exception thrown by gRPC transport causes a deadlock")
679+
public void test_maxGrpcMessageSize() throws Exception {
680+
var w = Weaviate.custom().withGrpcMaxMessageSize(1).build();
681+
var nsHugeVectors = ns("HugeVectors");
682+
683+
try (final var _client = w.getClient()) {
684+
var huge = _client.collections.create(nsHugeVectors, c -> c
685+
.vectorConfig(VectorConfig.selfProvided()));
686+
687+
final var vector = randomVector(5000, -.01f, .01f);
688+
final WeaviateObject<Map<String, Object>, Reference, ObjectMetadata> hugeObject = WeaviateObject.of(obj -> obj
689+
.metadata(ObjectMetadata.of(m -> m
690+
.vectors(Vectors.of(vector)))));
691+
692+
Assertions.assertThatThrownBy(() -> {
693+
// insertMany to route this request through gRPC.
694+
huge.data.insertMany(hugeObject);
695+
}).isInstanceOf(io.grpc.StatusRuntimeException.class);
696+
}
697+
System.out.println("here?");
698+
}
670699
}

0 commit comments

Comments
 (0)