@@ -2557,7 +2557,7 @@ public void testTimerCallbackBlocked() {
2557
2557
public interface ITestChild {
2558
2558
2559
2559
@ WorkflowMethod
2560
- String execute (String arg );
2560
+ String execute (String arg , int delay );
2561
2561
}
2562
2562
2563
2563
public interface ITestNamedChild {
@@ -2581,17 +2581,39 @@ public TestParentWorkflow() {
2581
2581
2582
2582
@ Override
2583
2583
public String execute (String taskList ) {
2584
- Promise <String > r1 = Async .function (child1 ::execute , "Hello " );
2584
+ Promise <String > r1 = Async .function (child1 ::execute , "Hello " , 0 );
2585
2585
String r2 = child2 .execute ("World!" );
2586
2586
assertEquals (child2Id , Workflow .getWorkflowExecution (child2 ).get ().getWorkflowId ());
2587
2587
return r1 .get () + r2 ;
2588
2588
}
2589
2589
}
2590
2590
2591
+ public static class TestParentWorkflowWithChildTimeout implements TestWorkflow1 {
2592
+
2593
+ private final ITestChild child ;
2594
+
2595
+ public TestParentWorkflowWithChildTimeout () {
2596
+ ChildWorkflowOptions .Builder options = new ChildWorkflowOptions .Builder ();
2597
+ options .setExecutionStartToCloseTimeout (Duration .ofSeconds (1 ));
2598
+ child = Workflow .newChildWorkflowStub (ITestChild .class , options .build ());
2599
+ }
2600
+
2601
+ @ Override
2602
+ public String execute (String taskList ) {
2603
+ try {
2604
+ child .execute ("Hello " , (int ) Duration .ofDays (1 ).toMillis ());
2605
+ } catch (Exception e ) {
2606
+ return e .getClass ().getSimpleName ();
2607
+ }
2608
+ throw new RuntimeException ("not reachable" );
2609
+ }
2610
+ }
2611
+
2591
2612
public static class TestChild implements ITestChild {
2592
2613
2593
2614
@ Override
2594
- public String execute (String arg ) {
2615
+ public String execute (String arg , int delay ) {
2616
+ Workflow .sleep (delay );
2595
2617
return arg .toUpperCase ();
2596
2618
}
2597
2619
}
@@ -2617,6 +2639,19 @@ public void testChildWorkflow() {
2617
2639
assertEquals ("HELLO WORLD!" , client .execute (taskList ));
2618
2640
}
2619
2641
2642
+ @ Test
2643
+ public void testChildWorkflowTimeout () {
2644
+ child2Id = UUID .randomUUID ().toString ();
2645
+ startWorkerFor (TestParentWorkflowWithChildTimeout .class , TestChild .class );
2646
+
2647
+ WorkflowOptions .Builder options = new WorkflowOptions .Builder ();
2648
+ options .setExecutionStartToCloseTimeout (Duration .ofSeconds (200 ));
2649
+ options .setTaskStartToCloseTimeout (Duration .ofSeconds (60 ));
2650
+ options .setTaskList (taskList );
2651
+ TestWorkflow1 client = workflowClient .newWorkflowStub (TestWorkflow1 .class , options .build ());
2652
+ assertEquals ("ChildWorkflowTimedOutException" , client .execute (taskList ));
2653
+ }
2654
+
2620
2655
private static String childReexecuteId = UUID .randomUUID ().toString ();
2621
2656
2622
2657
public interface WorkflowIdReusePolicyParent {
@@ -2726,7 +2761,7 @@ public String execute(String taskList) {
2726
2761
.build ();
2727
2762
child = Workflow .newChildWorkflowStub (ITestChild .class , options );
2728
2763
2729
- return child .execute (taskList );
2764
+ return child .execute (taskList , 0 );
2730
2765
}
2731
2766
}
2732
2767
@@ -2753,7 +2788,7 @@ public long getInvocationCount() {
2753
2788
public static class AngryChild implements ITestChild {
2754
2789
2755
2790
@ Override
2756
- public String execute (String taskList ) {
2791
+ public String execute (String taskList , int delay ) {
2757
2792
AngryChildActivity activity =
2758
2793
Workflow .newActivityStub (
2759
2794
AngryChildActivity .class ,
@@ -3007,7 +3042,7 @@ public String execute(String taskList) {
3007
3042
.build ())
3008
3043
.build ();
3009
3044
child = Workflow .newChildWorkflowStub (ITestChild .class , options );
3010
- return Async .function (child ::execute , taskList ).get ();
3045
+ return Async .function (child ::execute , taskList , 0 ).get ();
3011
3046
}
3012
3047
}
3013
3048
0 commit comments