11package 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 ;
75import io .iworkflow .gen .models .WorkflowErrorType ;
86import io .iworkflow .gen .models .WorkflowStatus ;
97import 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