@@ -28,6 +28,7 @@ import (
28
28
"github.com/stretchr/testify/mock"
29
29
"github.com/stretchr/testify/suite"
30
30
31
+ "github.com/pborman/uuid"
31
32
"github.com/uber-common/bark"
32
33
m "github.com/uber/cadence/.gen/go/matching"
33
34
workflow "github.com/uber/cadence/.gen/go/shared"
@@ -424,6 +425,108 @@ workerPump:
424
425
}
425
426
}
426
427
428
+ func (s * transferQueueProcessorSuite ) TestStartChildExecutionTransferTasks () {
429
+ domain := "start-child-execution-transfer-tasks-test-domain"
430
+ domainID := "b7f71853-0a8c-4eb1-af6b-c4e71dae50a1"
431
+ workflowID := "start-child-execution-transfertasks-test"
432
+ runID := "67ad6d62-79c6-4c8a-a27a-1fb7a10ae789"
433
+ workflowExecution := workflow.WorkflowExecution {
434
+ WorkflowId : common .StringPtr (workflowID ),
435
+ RunId : common .StringPtr (runID ),
436
+ }
437
+ taskList := "start-child-execution-transfertasks-queue"
438
+ identity := "start-child-execution-transfertasks-test"
439
+
440
+ tasksCh := s .createChildExecutionState (domain , domainID , workflowExecution , taskList , identity )
441
+ childRunID := "d3f9164e-b696-4350-8409-9a6cf670f4f2"
442
+ workerPump:
443
+ for {
444
+ select {
445
+ case task := <- tasksCh :
446
+ if task .TaskType == persistence .TransferTaskTypeStartChildExecution {
447
+ s .mockHistoryClient .On ("StartWorkflowExecution" , mock .Anything , mock .Anything ).Once ().Return (
448
+ & workflow.StartWorkflowExecutionResponse {
449
+ RunId : common .StringPtr (childRunID ),
450
+ }, nil )
451
+ s .mockHistoryClient .On ("ScheduleDecisionTask" , mock .Anything , mock .Anything ).Once ().Return (nil )
452
+ }
453
+ s .processor .processTransferTask (task )
454
+ default :
455
+ break workerPump
456
+ }
457
+ }
458
+ }
459
+
460
+ func (s * transferQueueProcessorSuite ) TestStartChildExecutionTransferTasksChildCompleted () {
461
+ domain := "start-child-execution-transfer-tasks-child-completed-test-domain"
462
+ domainID := "8bf7aaf8-810a-4778-a549-d7913d2a5b82"
463
+ workflowID := "start-child-execution-transfertasks-child-completed-test"
464
+ runID := "a627ea38-7e5e-41cc-9a32-4c7979b93ae2"
465
+ workflowExecution := workflow.WorkflowExecution {
466
+ WorkflowId : common .StringPtr (workflowID ),
467
+ RunId : common .StringPtr (runID ),
468
+ }
469
+ taskList := "start-child-execution-transfertasks-child-completed-queue"
470
+ identity := "start-child-execution-transfertasks-child-completed-test"
471
+
472
+ tasksCh := s .createChildExecutionState (domain , domainID , workflowExecution , taskList , identity )
473
+ childRunID := "66825b60-5ae2-4ff3-8da6-cbb286b4a7e6"
474
+ workerPump:
475
+ for {
476
+ select {
477
+ case task := <- tasksCh :
478
+ if task .TaskType == persistence .TransferTaskTypeStartChildExecution {
479
+ s .mockHistoryClient .On ("StartWorkflowExecution" , mock .Anything , mock .Anything ).Once ().Return (
480
+ & workflow.StartWorkflowExecutionResponse {
481
+ RunId : common .StringPtr (childRunID ),
482
+ }, nil )
483
+ s .mockHistoryClient .On ("ScheduleDecisionTask" , mock .Anything , mock .Anything ).Once ().Return (
484
+ & workflow.EntityNotExistsError {})
485
+ }
486
+ s .processor .processTransferTask (task )
487
+ default :
488
+ break workerPump
489
+ }
490
+ }
491
+ }
492
+
493
+ func (s * transferQueueProcessorSuite ) createChildExecutionState (domain , domainID string ,
494
+ workflowExecution workflow.WorkflowExecution , taskList , identity string ) chan * persistence.TransferTaskInfo {
495
+ _ , err0 := s .CreateWorkflowExecution (domainID , workflowExecution , taskList , "wType" , 10 , nil , 3 , 0 , 2 , nil )
496
+ s .Nil (err0 , "No error expected." )
497
+ s .mockMatching .On ("AddDecisionTask" , mock .Anything , mock .Anything ).Once ().Return (nil )
498
+ s .mockVisibilityMgr .On ("RecordWorkflowExecutionStarted" , mock .Anything ).Once ().Return (nil )
499
+
500
+ builder := newMutableStateBuilder (s .ShardContext .GetConfig (), s .logger )
501
+ info1 , _ := s .GetWorkflowExecutionInfo (domainID , workflowExecution )
502
+ builder .Load (info1 )
503
+ startedEvent := addDecisionTaskStartedEvent (builder , int64 (2 ), taskList , identity )
504
+ completedEvent := addDecisionTaskCompletedEvent (builder , int64 (2 ), startedEvent .GetEventId (), nil , identity )
505
+
506
+ transferTasks := []persistence.Task {}
507
+ createRequestID := uuid .New ()
508
+
509
+ childWorkflowID := "start-child-execution-transfertasks-test-child-workflow-id"
510
+ childWorkflowType := "child-workflow-type"
511
+ _ , ci := addStartChildWorkflowExecutionInitiatedEvent (builder , completedEvent .GetEventId (), createRequestID ,
512
+ domain , childWorkflowID , childWorkflowType , taskList , nil , int32 (100 ), int32 (10 ))
513
+ transferTasks = append (transferTasks , & persistence.StartChildExecutionTask {
514
+ TargetDomainID : domainID ,
515
+ TargetWorkflowID : childWorkflowID ,
516
+ InitiatedID : ci .InitiatedID ,
517
+ })
518
+
519
+ updatedInfo := copyWorkflowExecutionInfo (builder .executionInfo )
520
+ err1 := s .UpdateWorkflowExecutionForChildExecutionsInitiated (updatedInfo , int64 (3 ), transferTasks ,
521
+ builder .updateChildExecutionInfos )
522
+ s .Nil (err1 , "No error expected." )
523
+
524
+ tasksCh := make (chan * persistence.TransferTaskInfo , 10 )
525
+ s .processor .processTransferTasks (tasksCh )
526
+
527
+ return tasksCh
528
+ }
529
+
427
530
func createAddRequestFromTask (task * persistence.TransferTaskInfo , scheduleToStartTimeout int32 ) interface {} {
428
531
var res interface {}
429
532
domainID := task .DomainID
0 commit comments