@@ -650,6 +650,34 @@ func (t *TaskHandlersTestSuite) TestRespondsToWFTWithWorkerBinaryID() {
650
650
params .cache .getWorkflowCache ().Delete (task .WorkflowExecution .RunId )
651
651
}
652
652
653
+ func (t * TaskHandlersTestSuite ) TestStickyLegacyQueryTaskOnEvictedCache () {
654
+ taskQueue := "tq1"
655
+ testEvents := []* historypb.HistoryEvent {
656
+ createTestEventWorkflowExecutionStarted (1 , & historypb.WorkflowExecutionStartedEventAttributes {TaskQueue : & taskqueuepb.TaskQueue {Name : taskQueue }}),
657
+ createTestEventWorkflowTaskScheduled (2 , & historypb.WorkflowTaskScheduledEventAttributes {TaskQueue : & taskqueuepb.TaskQueue {Name : taskQueue }}),
658
+ createTestEventWorkflowTaskStarted (3 ),
659
+ }
660
+ task := createWorkflowTask (testEvents , 0 , "HelloWorld_Workflow" )
661
+ params := t .getTestWorkerExecutionParams ()
662
+ taskHandler := newWorkflowTaskHandler (params , nil , t .registry )
663
+ wftask := workflowTask {task : task }
664
+ wfctx := t .mustWorkflowContextImpl (& wftask , taskHandler )
665
+ wfctx .Unlock (nil )
666
+ wfctx .clearState ()
667
+ // Now make the task look like a legacy query task on the sticky queue
668
+ task .History = & historypb.History {}
669
+ task .Query = & querypb.WorkflowQuery {}
670
+ wfQueryTask := workflowTask {task : task , historyIterator : & historyIteratorImpl {
671
+ iteratorFunc : func (nextToken []byte ) (* historypb.History , []byte , error ) {
672
+ return & historypb.History {Events : testEvents }, nil , nil
673
+ },
674
+ }}
675
+ wfctx = t .mustWorkflowContextImpl (& wfQueryTask , taskHandler )
676
+ t .NotNil (wfctx )
677
+ // clean up workflow left in cache
678
+ params .cache .getWorkflowCache ().Delete (task .WorkflowExecution .RunId )
679
+ }
680
+
653
681
func (t * TaskHandlersTestSuite ) TestWorkflowTask_ActivityTaskScheduled () {
654
682
// Schedule an activity and see if we complete workflow.
655
683
taskQueue := "tq1"
0 commit comments