@@ -405,7 +405,7 @@ func (s *cassandraPersistenceSuite) TestTransferTasksThroughUpdate() {
405405 s .Nil (err0 , "No error expected." )
406406 s .NotEmpty (task0 , "Expected non empty task identifier." )
407407
408- tasks1 , err1 := s .GetTransferTasks (1 )
408+ tasks1 , err1 := s .GetTransferTasks (1 , false )
409409 s .Nil (err1 , "No error expected." )
410410 s .NotNil (tasks1 , "expected valid list of tasks." )
411411 s .Equal (1 , len (tasks1 ), "Expected 1 decision task." )
@@ -429,7 +429,7 @@ func (s *cassandraPersistenceSuite) TestTransferTasksThroughUpdate() {
429429 err2 := s .UpdateWorkflowExecution (updatedInfo , nil , []int64 {int64 (4 )}, int64 (3 ), nil , nil , nil , nil , nil , nil )
430430 s .Nil (err2 , "No error expected." )
431431
432- tasks2 , err1 := s .GetTransferTasks (1 )
432+ tasks2 , err1 := s .GetTransferTasks (1 , false )
433433 s .Nil (err1 , "No error expected." )
434434 s .NotNil (tasks2 , "expected valid list of tasks." )
435435 s .Equal (1 , len (tasks2 ), "Expected 1 decision task." )
@@ -461,7 +461,7 @@ func (s *cassandraPersistenceSuite) TestTransferTasksThroughUpdate() {
461461 s .Nil (err6 )
462462 s .Equal (* workflowExecution .RunId , runID6 )
463463
464- tasks3 , err7 := s .GetTransferTasks (1 )
464+ tasks3 , err7 := s .GetTransferTasks (1 , false )
465465 s .Nil (err7 , "No error expected." )
466466 s .NotNil (tasks3 , "expected valid list of tasks." )
467467 s .Equal (1 , len (tasks3 ), "Expected 1 decision task." )
@@ -493,7 +493,7 @@ func (s *cassandraPersistenceSuite) TestCancelTransferTaskTasks() {
493493 s .Nil (err , "No error expected." )
494494 s .NotEmpty (task0 , "Expected non empty task identifier." )
495495
496- taskD , err := s .GetTransferTasks (1 )
496+ taskD , err := s .GetTransferTasks (1 , false )
497497 s .Equal (1 , len (taskD ), "Expected 1 decision task." )
498498 err = s .CompleteTransferTask (taskD [0 ].TaskID )
499499 s .Nil (err )
@@ -519,7 +519,7 @@ func (s *cassandraPersistenceSuite) TestCancelTransferTaskTasks() {
519519 err = s .UpdateWorkflowExecutionWithTransferTasks (updatedInfo1 , int64 (3 ), transferTasks , nil )
520520 s .Nil (err , "No error expected." )
521521
522- tasks1 , err := s .GetTransferTasks (1 )
522+ tasks1 , err := s .GetTransferTasks (1 , false )
523523 s .Nil (err , "No error expected." )
524524 s .NotNil (tasks1 , "expected valid list of tasks." )
525525 s .Equal (1 , len (tasks1 ), "Expected 1 cancel task." )
@@ -558,7 +558,7 @@ func (s *cassandraPersistenceSuite) TestCancelTransferTaskTasks() {
558558 err = s .UpdateWorkflowExecutionWithTransferTasks (updatedInfo2 , int64 (3 ), transferTasks , nil )
559559 s .Nil (err , "No error expected." )
560560
561- tasks2 , err := s .GetTransferTasks (1 )
561+ tasks2 , err := s .GetTransferTasks (1 , false )
562562 s .Nil (err , "No error expected." )
563563 s .NotNil (tasks2 , "expected valid list of tasks." )
564564 s .Equal (1 , len (tasks2 ), "Expected 1 cancel task." )
@@ -587,7 +587,7 @@ func (s *cassandraPersistenceSuite) TestSignalTransferTaskTasks() {
587587 s .Nil (err , "No error expected." )
588588 s .NotEmpty (task0 , "Expected non empty task identifier." )
589589
590- taskD , err := s .GetTransferTasks (1 )
590+ taskD , err := s .GetTransferTasks (1 , false )
591591 s .Equal (1 , len (taskD ), "Expected 1 decision task." )
592592 err = s .CompleteTransferTask (taskD [0 ].TaskID )
593593 s .Nil (err )
@@ -613,7 +613,7 @@ func (s *cassandraPersistenceSuite) TestSignalTransferTaskTasks() {
613613 err = s .UpdateWorkflowExecutionWithTransferTasks (updatedInfo1 , int64 (3 ), transferTasks , nil )
614614 s .Nil (err , "No error expected." )
615615
616- tasks1 , err := s .GetTransferTasks (1 )
616+ tasks1 , err := s .GetTransferTasks (1 , false )
617617 s .Nil (err , "No error expected." )
618618 s .NotNil (tasks1 , "expected valid list of tasks." )
619619 s .Equal (1 , len (tasks1 ), "Expected 1 cancel task." )
@@ -652,7 +652,7 @@ func (s *cassandraPersistenceSuite) TestSignalTransferTaskTasks() {
652652 err = s .UpdateWorkflowExecutionWithTransferTasks (updatedInfo2 , int64 (3 ), transferTasks , nil )
653653 s .Nil (err , "No error expected." )
654654
655- tasks2 , err := s .GetTransferTasks (1 )
655+ tasks2 , err := s .GetTransferTasks (1 , false )
656656 s .Nil (err , "No error expected." )
657657 s .NotNil (tasks2 , "expected valid list of tasks." )
658658 s .Equal (1 , len (tasks2 ), "Expected 1 cancel task." )
@@ -826,6 +826,70 @@ func (s *cassandraPersistenceSuite) TestLeaseAndUpdateTaskList_Sticky() {
826826 s .NoError (err ) // because update with ttl doesn't check rangeID
827827}
828828
829+ func (s * cassandraPersistenceSuite ) TestReplicationTasks () {
830+ domainID := "2466d7de-6602-4ad8-b939-fb8f8c36c711"
831+ workflowExecution := gen.WorkflowExecution {
832+ WorkflowId : common .StringPtr ("get-replication-tasks-test" ),
833+ RunId : common .StringPtr ("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" ),
834+ }
835+
836+ task0 , err := s .CreateWorkflowExecution (domainID , workflowExecution , "queue1" , "wType" , 20 , 13 , nil , 3 , 0 , 2 , nil )
837+ s .Nil (err , "No error expected." )
838+ s .NotEmpty (task0 , "Expected non empty task identifier." )
839+ taskD , err := s .GetTransferTasks (1 , false )
840+ s .Equal (1 , len (taskD ), "Expected 1 decision task." )
841+ err = s .CompleteTransferTask (taskD [0 ].TaskID )
842+ s .Nil (err )
843+
844+ state1 , err := s .GetWorkflowExecutionInfo (domainID , workflowExecution )
845+ s .Nil (err , "No error expected." )
846+ info1 := state1 .ExecutionInfo
847+ s .NotNil (info1 , "Valid Workflow info expected." )
848+ updatedInfo1 := copyWorkflowExecutionInfo (info1 )
849+
850+ replicationTasks := []Task {
851+ & HistoryReplicationTask {
852+ TaskID : s .GetNextSequenceNumber (),
853+ FirstEventID : int64 (1 ),
854+ NextEventID : int64 (3 ),
855+ Version : 123 ,
856+ LastReplicationInfo : map [string ]* ReplicationInfo {
857+ "dc1" : & ReplicationInfo {
858+ Version : int64 (3 ),
859+ LastEventID : int64 (1 ),
860+ },
861+ },
862+ },
863+ & HistoryReplicationTask {
864+ TaskID : s .GetNextSequenceNumber (),
865+ FirstEventID : int64 (1 ),
866+ NextEventID : int64 (3 ),
867+ Version : 456 ,
868+ LastReplicationInfo : map [string ]* ReplicationInfo {
869+ "dc1" : & ReplicationInfo {
870+ Version : int64 (3 ),
871+ LastEventID : int64 (1 ),
872+ },
873+ },
874+ },
875+ }
876+ err = s .UpdateWorklowStateAndReplication (updatedInfo1 , nil , nil , nil , int64 (3 ), replicationTasks )
877+ s .Nil (err , "No error expected." )
878+
879+ repTasks , err := s .GetReplicationTasks (1 , true )
880+ s .Nil (err )
881+ s .Equal (len (replicationTasks ), len (repTasks ))
882+
883+ for index := range replicationTasks {
884+ s .Equal (replicationTasks [index ].GetTaskID (), repTasks [index ].GetTaskID ())
885+ s .Equal (replicationTasks [index ].GetType (), repTasks [index ].GetTaskType ())
886+ s .Equal (replicationTasks [index ].GetVersion (), repTasks [index ].GetVersion ())
887+
888+ err = s .CompleteReplicationTask (repTasks [index ].GetTaskID ())
889+ s .Nil (err , "No error expected." )
890+ }
891+ }
892+
829893func (s * cassandraPersistenceSuite ) TestTransferTasks () {
830894 domainID := "8bfb47be-5b57-4d55-9109-5fb35e20b1d7"
831895 workflowExecution := gen.WorkflowExecution {
@@ -838,7 +902,7 @@ func (s *cassandraPersistenceSuite) TestTransferTasks() {
838902 s .Nil (err0 , "No error expected." )
839903 s .NotEmpty (task0 , "Expected non empty task identifier." )
840904
841- tasks1 , err1 := s .GetTransferTasks (1 )
905+ tasks1 , err1 := s .GetTransferTasks (1 , false )
842906 s .Nil (err1 , "No error expected." )
843907 s .NotNil (tasks1 , "expected valid list of tasks." )
844908 s .Equal (1 , len (tasks1 ), "Expected 1 decision task." )
@@ -878,7 +942,7 @@ func (s *cassandraPersistenceSuite) TestTransferTasks() {
878942 err2 := s .UpdateWorklowStateAndReplication (updatedInfo , nil , nil , nil , int64 (3 ), tasks )
879943 s .Nil (err2 , "No error expected." )
880944
881- txTasks , err1 := s .GetTransferTasks (100 )
945+ txTasks , err1 := s .GetTransferTasks (1 , true ) // use page size one to force pagination
882946 s .Nil (err1 , "No error expected." )
883947 s .NotNil (txTasks , "expected valid list of tasks." )
884948 s .Equal (len (tasks ), len (txTasks ))
@@ -913,7 +977,7 @@ func (s *cassandraPersistenceSuite) TestTransferTasks() {
913977 err2 = s .CompleteTransferTask (txTasks [5 ].TaskID )
914978 s .Nil (err2 , "No error expected." )
915979
916- txTasks , err2 = s .GetTransferTasks (100 )
980+ txTasks , err2 = s .GetTransferTasks (100 , false )
917981 s .Nil (err2 , "No error expected." )
918982 s .Empty (txTasks , "expected empty task list." )
919983}
@@ -947,7 +1011,7 @@ func (s *cassandraPersistenceSuite) TestTimerTasks() {
9471011 err2 := s .UpdateWorkflowExecution (updatedInfo , []int64 {int64 (4 )}, nil , int64 (3 ), tasks , nil , nil , nil , nil , nil )
9481012 s .Nil (err2 , "No error expected." )
9491013
950- timerTasks , err1 := s .GetTimerIndexTasks ()
1014+ timerTasks , err1 := s .GetTimerIndexTasks (1 , true ) // use page size one to force pagination
9511015 s .Nil (err1 , "No error expected." )
9521016 s .NotNil (timerTasks , "expected valid list of tasks." )
9531017 s .Equal (len (tasks ), len (timerTasks ))
@@ -978,7 +1042,7 @@ func (s *cassandraPersistenceSuite) TestTimerTasks() {
9781042 err2 = s .CompleteTimerTask (timerTasks [4 ].VisibilityTimestamp , timerTasks [4 ].TaskID )
9791043 s .Nil (err2 , "No error expected." )
9801044
981- timerTasks2 , err2 := s .GetTimerIndexTasks ()
1045+ timerTasks2 , err2 := s .GetTimerIndexTasks (100 , false )
9821046 s .Nil (err2 , "No error expected." )
9831047 s .Empty (timerTasks2 , "expected empty task list." )
9841048}
@@ -1590,7 +1654,7 @@ func (s *cassandraPersistenceSuite) TestReplicationTransferTaskTasks() {
15901654 s .Nil (err , "No error expected." )
15911655 s .NotEmpty (task0 , "Expected non empty task identifier." )
15921656
1593- taskD , err := s .GetTransferTasks (1 )
1657+ taskD , err := s .GetTransferTasks (1 , false )
15941658 s .Equal (1 , len (taskD ), "Expected 1 decision task." )
15951659 err = s .CompleteTransferTask (taskD [0 ].TaskID )
15961660 s .Nil (err )
@@ -1620,7 +1684,7 @@ func (s *cassandraPersistenceSuite) TestReplicationTransferTaskTasks() {
16201684 err = s .UpdateWorklowStateAndReplication (updatedInfo1 , nil , nil , nil , int64 (3 ), replicationTasks )
16211685 s .Nil (err , "No error expected." )
16221686
1623- tasks1 , err := s .GetReplicationTasks (1 )
1687+ tasks1 , err := s .GetReplicationTasks (1 , false )
16241688 s .Nil (err , "No error expected." )
16251689 s .NotNil (tasks1 , "expected valid list of tasks." )
16261690 s .Equal (1 , len (tasks1 ), "Expected 1 replication task." )
@@ -1696,13 +1760,13 @@ func (s *cassandraPersistenceSuite) TestWorkflowReplicationState() {
16961760 s .Nil (err0 , "No error expected." )
16971761 s .NotEmpty (task0 , "Expected non empty task identifier." )
16981762
1699- taskD , err := s .GetTransferTasks (2 )
1763+ taskD , err := s .GetTransferTasks (2 , false )
17001764 s .Equal (1 , len (taskD ), "Expected 1 decision task." )
17011765 s .Equal (TransferTaskTypeDecisionTask , taskD [0 ].TaskType )
17021766 err = s .CompleteTransferTask (taskD [0 ].TaskID )
17031767 s .Nil (err )
17041768
1705- taskR , err := s .GetReplicationTasks (1 )
1769+ taskR , err := s .GetReplicationTasks (1 , false )
17061770 s .Equal (1 , len (taskR ), "Expected 1 replication task." )
17071771 tsk := taskR [0 ]
17081772 s .Equal (ReplicationTaskTypeHistory , tsk .TaskType )
@@ -1791,7 +1855,7 @@ func (s *cassandraPersistenceSuite) TestWorkflowReplicationState() {
17911855 err2 := s .UpdateWorklowStateAndReplication (updatedInfo , updatedReplicationState , nil , nil , int64 (3 ), replicationTasks1 )
17921856 s .Nil (err2 , "No error expected." )
17931857
1794- taskR1 , err := s .GetReplicationTasks (1 )
1858+ taskR1 , err := s .GetReplicationTasks (1 , false )
17951859 s .Equal (1 , len (taskR1 ), "Expected 1 replication task." )
17961860 tsk1 := taskR1 [0 ]
17971861 s .Equal (ReplicationTaskTypeHistory , tsk1 .TaskType )
0 commit comments