Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions host/continueasnew_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (
taskqueuepb "go.temporal.io/api/taskqueue/v1"
"go.temporal.io/api/workflowservice/v1"

"go.temporal.io/server/common"
"go.temporal.io/server/common/log/tag"
"go.temporal.io/server/common/payloads"
)
Expand Down Expand Up @@ -316,7 +317,8 @@ func (s *integrationSuite) TestContinueAsNewWorkflow_Timeout() {
s.False(workflowComplete)

GetHistoryLoop:
for i := 0; i < 200; i++ {
for i := 0; i < 25; i++ {
s.Logger.Info(fmt.Sprintf("Running Iteration `%v` for Making ContinueAsNew Command", i))
historyResponse, err := s.engine.GetWorkflowExecutionHistory(NewContext(), &workflowservice.GetWorkflowExecutionHistoryRequest{
Namespace: s.namespace,
Execution: &commonpb.WorkflowExecution{
Expand All @@ -333,16 +335,24 @@ GetHistoryLoop:
// Ensure that timeout is not caused by runTimeout
s.True(time.Duration(lastEvent.Timestamp-firstEvent.Timestamp) < 5*time.Second)
}
s.Logger.Warn(fmt.Sprintf("Execution not timed out yet. Last event is %v", lastEvent))
time.Sleep(200 * time.Millisecond)
_, err := poller.PollAndProcessWorkflowTask(true, false)
s.Logger.Info("PollAndProcessWorkflowTask", tag.Error(err))
if err != matching.ErrNoTasks {
s.NoError(err)

// Only PollForWorkflowTask if the last event is WorkflowTaskScheduled
if lastEvent.GetEventType() == enumspb.EVENT_TYPE_WORKFLOW_TASK_SCHEDULED {
s.Logger.Info(fmt.Sprintf("Execution not timed out yet. PollForWorkflowTask. Last event is %v", lastEvent))
_, err := poller.PollAndProcessWorkflowTaskWithoutRetry(true, false)
s.Logger.Info("PollAndProcessWorkflowTask", tag.Error(err))
if err != matching.ErrNoTasks {
s.NoError(err)
}
}

time.Sleep(200 * time.Millisecond)
continue GetHistoryLoop
}

s.Logger.Info("Workflow execution timedout. Printing history for last run:")
common.PrettyPrintHistory(history, s.Logger)

s.True(firstEvent.GetWorkflowExecutionStartedEventAttributes().GetWorkflowRunTimeoutSeconds() < 5)
workflowComplete = true
break GetHistoryLoop
Expand Down