Skip to content
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
36 changes: 20 additions & 16 deletions features/reset/reset_and_delete/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"time"

"github.com/stretchr/testify/assert"
"github.com/temporalio/features/harness/go/harness"
"go.temporal.io/api/common/v1"
"go.temporal.io/api/enums/v1"
Expand Down Expand Up @@ -104,10 +105,7 @@ func CheckResult(ctx context.Context, r *harness.Runner, run client.WorkflowRun)
err = r.DoUntilEventually(ctx, 1*time.Second, 3*time.Minute, func() bool {
_, err := r.Client.DescribeWorkflowExecution(ctx, run.GetID(), run.GetRunID())
var notFoundErr *serviceerror.NotFound
if errors.As(err, &notFoundErr) {
return true
}
return false
return errors.As(err, &notFoundErr)
})
if err != nil {
return err
Expand All @@ -127,18 +125,24 @@ func CheckResult(ctx context.Context, r *harness.Runner, run client.WorkflowRun)
if next.GetEventType() != enums.EVENT_TYPE_WORKFLOW_EXECUTION_TERMINATED {
return errors.New("expected last event to be terminated")
}
// Ensure original run is findable via visibility & has correct status
resp, err := r.Client.ListWorkflow(ctx, &workflowservice.ListWorkflowExecutionsRequest{
Namespace: r.Namespace,
Query: "WorkflowId = '" + origRun.GetID() + "'",
})
if err != nil {
return err
}
r.Require.Equal(1, len(resp.GetExecutions()))
r.Require.Equal(enums.WORKFLOW_EXECUTION_STATUS_TERMINATED, resp.GetExecutions()[0].Status)

return err
// Use eventually since visibility is eventually consistent.
r.Require.EventuallyWithT(func(t *assert.CollectT) {
// Ensure original run is findable via visibility & has correct status
resp, err := r.Client.ListWorkflow(ctx, &workflowservice.ListWorkflowExecutionsRequest{
Namespace: r.Namespace,
Query: "WorkflowId = '" + origRun.GetID() + "'",
})
assert.NoError(t, err)
if err != nil {
return
}
assert.Len(t, resp.GetExecutions(), 1)
if len(resp.GetExecutions()) != 1 {
return
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we check this again and why is it OK to return without error here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh I think I see -- if it's != 1 then the previous assert.Len failed and this tick is not clean, and we don't want a panic on the next line. (Would be nice to have a cleaner way!)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, EventuallyWithT is notoriously hard to use. assert expressions don't break out of the function and require breaks the retry loop. So you're stuck with evaluating certain conditions twice.

}
assert.Equal(t, enums.WORKFLOW_EXECUTION_STATUS_TERMINATED, resp.GetExecutions()[0].Status)
}, 1*time.Minute, 200*time.Millisecond)
return nil
}

// Workflow waits for a single signal and returns the data contained therein
Expand Down