Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky reset test #713

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Changes from all commits
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
19 changes: 5 additions & 14 deletions temporalcli/commands.workflow_reset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,21 +600,11 @@ func (t *WorkflowResetTest) startWorkflowAndSendTwoSignalsAndTwoUpdates(searchAt
)
s.NoError(err)

// Wait for the workflow to start before sending signals/updates.
// This has to be done, as batch reset with type `FirstWorkflowTask`, will reset to first workflow task completed, so the first signal
// sent before the workflow starts, will be reapplied, as the reset point is later in the history.
// The same would happen with single reset to eventId 4.
s.Eventually(func() bool {
resp, err := s.Client.ListWorkflow(s.Context, &workflowservice.ListWorkflowExecutionsRequest{
Query: "CustomKeywordField = '" + searchAttr + "'",
})
s.NoError(err)
return len(resp.Executions) > 0
}, 3*time.Second, 100*time.Millisecond, "Workflow failed to start")
Copy link
Contributor Author

@dandavison dandavison Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was waiting for the workflow to exist, whereas we needed to wait for the workflow task to be complete.


// before sending signals, we wait for the workflow to execute the activity
// We send the updates before the signals in order to ensure that no signal
// enters history before the first WorkflowTaskCompleted. This is necessary
// because there are tests that reset to FirstWorkflowTask, and assume that
// all signals are received after that event.
for i := 1; i <= 2; i++ {
s.NoError(s.Client.SignalWorkflow(s.Context, run.GetID(), run.GetRunID(), "mySignal", fmt.Sprintf("%d", i)))
updateHandle, err := s.Client.UpdateWorkflow(s.Context, client.UpdateWorkflowOptions{
WorkflowID: run.GetID(),
RunID: run.GetRunID(),
Expand All @@ -623,6 +613,7 @@ func (t *WorkflowResetTest) startWorkflowAndSendTwoSignalsAndTwoUpdates(searchAt
})
s.NoError(err)
s.NoError(updateHandle.Get(s.Context, nil))
s.NoError(s.Client.SignalWorkflow(s.Context, run.GetID(), run.GetRunID(), "mySignal", fmt.Sprintf("%d", i)))
}
s.NoError(run.Get(s.Context, nil))
return run
Expand Down
Loading