1313import io .temporal .internal .replay .ReplayWorkflowTaskHandler ;
1414import io .temporal .internal .retryer .GrpcMessageTooLargeException ;
1515import io .temporal .internal .worker .PollerOptions ;
16+ import io .temporal .serviceclient .GrpcCompression ;
17+ import io .temporal .serviceclient .WorkflowServiceStubsOptions ;
1618import io .temporal .testUtils .LoggerUtils ;
1719import io .temporal .testing .internal .SDKTestWorkflowRule ;
1820import io .temporal .workflow .shared .TestActivities ;
2224import org .junit .Test ;
2325
2426public class GrpcMessageTooLargeTest {
25- private static final String QUERY_ERROR_MESSAGE =
26- "Failed to send query response: RESOURCE_EXHAUSTED: grpc: received message larger than max" ;
27+ // This string is kept intentionally short to match multiple possible too-large error messages
28+ private static final String TOO_BIG_ERR_MESSAGE = "larger than max" ;
29+ private static final WorkflowServiceStubsOptions GRPC_COMPRESSION_DISABLED =
30+ WorkflowServiceStubsOptions .newBuilder ().setGrpcCompression (GrpcCompression .NONE ).build ();
2731 private static final String VERY_LARGE_DATA ;
2832
2933 static {
@@ -39,21 +43,31 @@ public class GrpcMessageTooLargeTest {
3943 @ Rule
4044 public SDKTestWorkflowRule activityStartWorkflowRule =
4145 SDKTestWorkflowRule .newBuilder ()
46+ .setWorkflowServiceStubsOptions (GRPC_COMPRESSION_DISABLED )
4247 .setWorkflowTypes (ActivityStartWorkflowImpl .class )
4348 .setActivityImplementations (new TestActivityImpl ())
4449 .build ();
4550
4651 @ Rule
4752 public SDKTestWorkflowRule failureWorkflowRule =
48- SDKTestWorkflowRule .newBuilder ().setWorkflowTypes (FailureWorkflowImpl .class ).build ();
53+ SDKTestWorkflowRule .newBuilder ()
54+ .setWorkflowServiceStubsOptions (GRPC_COMPRESSION_DISABLED )
55+ .setWorkflowTypes (FailureWorkflowImpl .class )
56+ .build ();
4957
5058 @ Rule
5159 public SDKTestWorkflowRule querySuccessWorkflowRule =
52- SDKTestWorkflowRule .newBuilder ().setWorkflowTypes (QuerySuccessWorkflowImpl .class ).build ();
60+ SDKTestWorkflowRule .newBuilder ()
61+ .setWorkflowServiceStubsOptions (GRPC_COMPRESSION_DISABLED )
62+ .setWorkflowTypes (QuerySuccessWorkflowImpl .class )
63+ .build ();
5364
5465 @ Rule
5566 public SDKTestWorkflowRule queryFailureWorkflowRule =
56- SDKTestWorkflowRule .newBuilder ().setWorkflowTypes (QueryFailureWorkflowImpl .class ).build ();
67+ SDKTestWorkflowRule .newBuilder ()
68+ .setWorkflowServiceStubsOptions (GRPC_COMPRESSION_DISABLED )
69+ .setWorkflowTypes (QueryFailureWorkflowImpl .class )
70+ .build ();
5771
5872 @ Test
5973 public void workflowStartTooLarge () {
@@ -120,7 +134,7 @@ public void queryResultTooLarge() {
120134 assertNotNull (e .getCause ());
121135 // The exception will not contain the original failure object, so instead of type check we're
122136 // checking the message to ensure the correct error is being sent.
123- assertTrue (e .getCause ().getMessage ().contains (QUERY_ERROR_MESSAGE ));
137+ assertTrue (e .getCause ().getMessage ().contains (TOO_BIG_ERR_MESSAGE ));
124138 }
125139
126140 @ Test
@@ -132,7 +146,7 @@ public void queryErrorTooLarge() {
132146 WorkflowQueryException e = assertThrows (WorkflowQueryException .class , workflow ::query );
133147
134148 assertNotNull (e .getCause ());
135- assertTrue (e .getCause ().getMessage ().contains (QUERY_ERROR_MESSAGE ));
149+ assertTrue (e .getCause ().getMessage ().contains (TOO_BIG_ERR_MESSAGE ));
136150 }
137151
138152 private static <T > T createWorkflowStub (Class <T > clazz , SDKTestWorkflowRule workflowRule ) {
0 commit comments