Skip to content

Commit 75c73c8

Browse files
Add better support for wait timeout with subStatus (#177)
1 parent 0a15f76 commit 75c73c8

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

iwf-idl

src/test/java/io/iworkflow/integ/WorkflowUncompletedTest.java

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package io.iworkflow.integ;
22

3-
import io.iworkflow.core.Client;
4-
import io.iworkflow.core.ClientOptions;
5-
import io.iworkflow.core.ImmutableStopWorkflowOptions;
6-
import io.iworkflow.core.WorkflowUncompletedException;
3+
import io.iworkflow.core.*;
4+
import io.iworkflow.gen.models.ErrorSubStatus;
75
import io.iworkflow.gen.models.WorkflowErrorType;
86
import io.iworkflow.gen.models.WorkflowStatus;
97
import io.iworkflow.gen.models.WorkflowStopType;
@@ -28,6 +26,34 @@ public void setup() throws ExecutionException, InterruptedException {
2826
TestSingletonWorkerService.startWorkerIfNotUp();
2927
}
3028

29+
@Test
30+
public void testWorkflowWaitTimeout() throws InterruptedException {
31+
final Client client = new Client(WorkflowRegistry.registry, ClientOptions.localDefault);
32+
final String wfId = "testWorkflowTimeout" + System.currentTimeMillis() / 1000;
33+
final Integer input = 1;
34+
35+
36+
client.startWorkflow(BasicSignalWorkflow.class, wfId, 100, input);
37+
38+
39+
long startMs = System.currentTimeMillis();
40+
long elapsedMs;
41+
try {
42+
client.getSimpleWorkflowResultWithWait(Integer.class, wfId);
43+
} catch (ClientSideException e) {
44+
Assertions.assertEquals(ErrorSubStatus.LONG_POLL_TIME_OUT_SUB_STATUS, e.getErrorSubStatus());
45+
Assertions.assertEquals(420, e.getStatusCode());
46+
47+
elapsedMs = (System.currentTimeMillis() - startMs) / 1000;
48+
// NOTE: because the default poll timeout is 60-2 = 28s in iWF service
49+
Assertions.assertTrue(elapsedMs >= 55 && elapsedMs <= 62, "expect to poll for 58 seconds, actual is %d " + elapsedMs);
50+
return;
51+
} catch (Exception e) {
52+
Assertions.fail("expected to catch ClientSideException");
53+
}
54+
Assertions.fail("expected to catch ClientSideException");
55+
}
56+
3157
@Test
3258
public void testWorkflowTimeout() throws InterruptedException {
3359
final Client client = new Client(WorkflowRegistry.registry, ClientOptions.localDefault);

0 commit comments

Comments
 (0)