@@ -223,7 +223,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
223
223
},
224
224
},
225
225
{
226
- name : "SubWorkflow_Simple " ,
226
+ name : "SubWorkflow/Simple " ,
227
227
f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
228
228
swf := func (ctx workflow.Context , i int ) (int , error ) {
229
229
return i * 2 , nil
@@ -246,7 +246,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
246
246
},
247
247
},
248
248
{
249
- name : "SubWorkflow_DuplicateActiveInstanceID " ,
249
+ name : "SubWorkflow/DuplicateActiveInstanceID " ,
250
250
f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
251
251
swf := func (ctx workflow.Context , i int ) (int , error ) {
252
252
workflow .NewSignalChannel [any ](ctx , "signal" ).Receive (ctx )
@@ -285,7 +285,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
285
285
},
286
286
},
287
287
{
288
- name : "SubWorkflow_DuplicateInactiveInstanceID " ,
288
+ name : "SubWorkflow/DuplicateInactiveInstanceID " ,
289
289
f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
290
290
swf := func (ctx workflow.Context , i int ) (int , error ) {
291
291
return i * 2 , nil
@@ -319,7 +319,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
319
319
},
320
320
},
321
321
{
322
- name : "SubWorkflow_PropagateCancellation " ,
322
+ name : "SubWorkflow/PropagateCancellation " ,
323
323
f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
324
324
canceled := int32 (0 )
325
325
@@ -383,7 +383,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
383
383
},
384
384
},
385
385
{
386
- name : "SubWorkflow_CancelBeforeStarting " ,
386
+ name : "SubWorkflow/CancelBeforeStarting " ,
387
387
f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
388
388
swInstanceID := "subworkflow"
389
389
@@ -429,7 +429,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
429
429
},
430
430
},
431
431
{
432
- name : "SubWorkflow_Signal " ,
432
+ name : "SubWorkflow/Signal " ,
433
433
f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
434
434
swf := func (ctx workflow.Context , i int ) (int , error ) {
435
435
workflow .NewSignalChannel [string ](ctx , "signal" ).Receive (ctx )
@@ -463,7 +463,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
463
463
},
464
464
},
465
465
{
466
- name : "SubWorkflow_DifferentQueue " ,
466
+ name : "SubWorkflow/DifferentQueue " ,
467
467
customWorkerOptions : func (options * worker.Options ) {
468
468
options .WorkflowQueues = []core.Queue {workflow .QueueDefault , workflow .Queue ("custom" )}
469
469
},
@@ -502,7 +502,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
502
502
},
503
503
},
504
504
{
505
- name : "SubWorkflow_Signal_BeforeStarting " ,
505
+ name : "SubWorkflow/Signal_BeforeStarting " ,
506
506
f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
507
507
wf := func (ctx workflow.Context ) (int , error ) {
508
508
id , _ := workflow .SideEffect (ctx , func (ctx workflow.Context ) string {
@@ -525,157 +525,6 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
525
525
require .ErrorContains (t , err , backend .ErrInstanceNotFound .Error ())
526
526
},
527
527
},
528
- {
529
- name : "Timer_CancelWorkflowInstance" ,
530
- f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
531
- a := func (ctx context.Context ) error {
532
- return nil
533
- }
534
- wf := func (ctx workflow.Context ) error {
535
- _ , err := workflow .ScheduleTimer (ctx , time .Second * 10 ).Get (ctx )
536
- if err != nil && err != workflow .Canceled {
537
- return err
538
- }
539
-
540
- return nil
541
- }
542
- register (t , ctx , w , []interface {}{wf }, []interface {}{a })
543
-
544
- instance := runWorkflow (t , ctx , c , wf )
545
-
546
- // Allow some time for the timer to get scheduled
547
- time .Sleep (time .Millisecond * 200 )
548
-
549
- require .NoError (t , c .CancelWorkflowInstance (ctx , instance ))
550
-
551
- _ , err := client .GetWorkflowResult [any ](ctx , c , instance , time .Second * 5 )
552
- require .NoError (t , err )
553
- },
554
- },
555
- {
556
- name : "Timer_CancelBeforeStarting" ,
557
- f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
558
- a := func (ctx context.Context ) error {
559
- return nil
560
- }
561
- wf := func (ctx workflow.Context ) error {
562
- tctx , cancel := workflow .WithCancel (ctx )
563
-
564
- f := workflow .ScheduleTimer (tctx , time .Second * 10 )
565
-
566
- // Cancel before it can be started
567
- cancel ()
568
-
569
- // Force the checkpoint before continuing the execution
570
- workflow .ExecuteActivity [any ](ctx , workflow .DefaultActivityOptions , a ).Get (ctx )
571
-
572
- _ , err := f .Get (ctx )
573
- if err != nil && err != workflow .Canceled {
574
- return err
575
- }
576
-
577
- return nil
578
- }
579
- register (t , ctx , w , []interface {}{wf }, []interface {}{a })
580
-
581
- instance := runWorkflow (t , ctx , c , wf )
582
- _ , err := client .GetWorkflowResult [any ](ctx , c , instance , time .Second * 5 )
583
- require .NoError (t , err )
584
-
585
- events , err := b .GetWorkflowInstanceHistory (ctx , instance , nil )
586
- require .NoError (t , err )
587
- for _ , e := range events {
588
- if e .Type == history .EventType_TimerScheduled {
589
- require .FailNow (t , "timer should not be scheduled" )
590
- }
591
- }
592
-
593
- futureEvents , err := b .GetFutureEvents (ctx )
594
- require .NoError (t , err )
595
- require .Len (t , futureEvents , 0 , "no future events should be scheduled" )
596
- },
597
- },
598
- {
599
- name : "Timer_CancelTwice" ,
600
- f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
601
- a := func (ctx context.Context ) error {
602
- return nil
603
- }
604
- wf := func (ctx workflow.Context ) error {
605
- tctx , cancel := workflow .WithCancel (ctx )
606
- f := workflow .ScheduleTimer (tctx , time .Second * 10 )
607
-
608
- // Force the checkpoint before continuing the execution
609
- workflow .ExecuteActivity [any ](ctx , workflow .DefaultActivityOptions , a ).Get (ctx )
610
-
611
- // Cancel timer
612
- cancel ()
613
-
614
- // Force another checkpoint
615
- workflow .ExecuteActivity [any ](ctx , workflow .DefaultActivityOptions , a ).Get (ctx )
616
-
617
- cancel ()
618
-
619
- // Force another checkpoint
620
- workflow .ExecuteActivity [any ](ctx , workflow .DefaultActivityOptions , a ).Get (ctx )
621
-
622
- if _ , err := f .Get (ctx ); err != nil && err != workflow .Canceled {
623
- return err
624
- }
625
-
626
- return nil
627
- }
628
- register (t , ctx , w , []interface {}{wf }, []interface {}{a })
629
-
630
- instance := runWorkflow (t , ctx , c , wf )
631
- _ , err := client .GetWorkflowResult [any ](ctx , c , instance , time .Second * 5 )
632
- require .NoError (t , err )
633
-
634
- historyContains (ctx , t , b , instance , history .EventType_TimerScheduled , history .EventType_TimerCanceled )
635
-
636
- futureEvents , err := b .GetFutureEvents (ctx )
637
- require .NoError (t , err )
638
- require .Len (t , futureEvents , 0 , "no future events should be scheduled" )
639
- },
640
- },
641
- {
642
- name : "Timer_CancelBeforeFiringRemovesFutureEvent" ,
643
- f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
644
- a := func (ctx context.Context ) error {
645
- return nil
646
- }
647
- wf := func (ctx workflow.Context ) error {
648
- tctx , cancel := workflow .WithCancel (ctx )
649
- f := workflow .ScheduleTimer (tctx , time .Second * 10 )
650
-
651
- // Force the checkpoint before continuing the execution
652
- workflow .ExecuteActivity [any ](ctx , workflow .DefaultActivityOptions , a ).Get (ctx )
653
-
654
- // Cancel timer
655
- cancel ()
656
-
657
- // Force another checkpoint
658
- workflow .ExecuteActivity [any ](ctx , workflow .DefaultActivityOptions , a ).Get (ctx )
659
-
660
- if _ , err := f .Get (ctx ); err != nil && err != workflow .Canceled {
661
- return err
662
- }
663
-
664
- return nil
665
- }
666
- register (t , ctx , w , []interface {}{wf }, []interface {}{a })
667
-
668
- instance := runWorkflow (t , ctx , c , wf )
669
- _ , err := client .GetWorkflowResult [any ](ctx , c , instance , time .Second * 5 )
670
- require .NoError (t , err )
671
-
672
- historyContains (ctx , t , b , instance , history .EventType_TimerScheduled , history .EventType_TimerCanceled )
673
-
674
- futureEvents , err := b .GetFutureEvents (ctx )
675
- require .NoError (t , err )
676
- require .Len (t , futureEvents , 0 , "no future events should be scheduled" )
677
- },
678
- },
679
528
{
680
529
name : "NonDeterminism" ,
681
530
withoutCache : true ,
@@ -764,57 +613,6 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
764
613
require .Equal (t , "hello-23" , r )
765
614
},
766
615
},
767
- {
768
- name : "ContinueAsNew" ,
769
- f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
770
- wf := func (ctx workflow.Context , run int ) (int , error ) {
771
- run = run + 1
772
- if run < 3 {
773
- return run , workflow .ContinueAsNew (ctx , run )
774
- }
775
-
776
- return run , nil
777
- }
778
- register (t , ctx , w , []interface {}{wf }, nil )
779
-
780
- instance := runWorkflow (t , ctx , c , wf , 0 )
781
-
782
- r , err := client .GetWorkflowResult [int ](ctx , c , instance , time .Second * 10 )
783
- require .NoError (t , err )
784
- require .Equal (t , 1 , r )
785
-
786
- state , err := b .GetWorkflowInstanceState (ctx , instance )
787
- require .NoError (t , err )
788
- require .Equal (t , core .WorkflowInstanceStateContinuedAsNew , state )
789
- },
790
- },
791
- {
792
- name : "ContinueAsNew_Subworkflow" ,
793
- f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
794
- swf := func (ctx workflow.Context , run int ) (int , error ) {
795
- l := workflow .Logger (ctx )
796
-
797
- run = run + 1
798
- if run < 3 {
799
- l .Debug ("continue as new" , "run" , run )
800
- return run , workflow .ContinueAsNew (ctx , run )
801
- }
802
-
803
- return run , nil
804
- }
805
-
806
- wf := func (ctx workflow.Context , run int ) (int , error ) {
807
- return workflow .CreateSubWorkflowInstance [int ](ctx , workflow .DefaultSubWorkflowOptions , swf , run ).Get (ctx )
808
- }
809
- register (t , ctx , w , []interface {}{wf , swf }, nil )
810
-
811
- instance := runWorkflow (t , ctx , c , wf , 0 )
812
-
813
- r , err := client .GetWorkflowResult [int ](ctx , c , instance , time .Second * 20 )
814
- require .NoError (t , err )
815
- require .Equal (t , 3 , r )
816
- },
817
- },
818
616
}
819
617
820
618
tests = append (tests , e2eActivityTests ... )
0 commit comments