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

Confirmation of duplicate workflow ID behavior while running #574

Merged
merged 1 commit into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
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
39 changes: 39 additions & 0 deletions test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,45 @@ func (ts *IntegrationTestSuite) TestWorkflowIDReuseAllowDuplicate() {
ts.Equal("HELLOWORLD", result)
}

func (ts *IntegrationTestSuite) TestWorkflowIDReuseIgnoreDuplicateWhileRunning() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

// Start two workflows with the same ID but different params
opts := ts.startWorkflowOptions("test-workflow-id-reuse-ignore-dupes-" + uuid.New())
run1, err := ts.client.ExecuteWorkflow(ctx, opts, ts.workflows.WaitSignalReturnParam, "run1")
ts.NoError(err)
run2, err := ts.client.ExecuteWorkflow(ctx, opts, ts.workflows.WaitSignalReturnParam, "run2")
ts.NoError(err)

// Confirm both runs have the same ID and run ID since the first one wasn't
// done when we tried the second
ts.Equal(run1.GetID(), run2.GetID())
ts.Equal(run1.GetRunID(), run2.GetRunID())

// Send signal to each (though in practice they both have the same ID and run
// ID, so it's really just two signals)
err = ts.client.SignalWorkflow(ctx, run1.GetID(), run1.GetRunID(), "done-signal", true)
ts.NoError(err)
err = ts.client.SignalWorkflow(ctx, run2.GetID(), run2.GetRunID(), "done-signal", true)
ts.NoError(err)

// Wait for responses and confirm they are the same "run1" which is the first
// param
var result string
ts.NoError(run1.Get(ctx, &result))
ts.Equal("run1", result)
ts.NoError(run2.Get(ctx, &result))
ts.Equal("run1", result)

// Now start a third and confirm it is a new run ID because the other two are
// done
run3, err := ts.client.ExecuteWorkflow(ctx, opts, ts.workflows.WaitSignalReturnParam, "run1")
ts.NoError(err)
ts.Equal(run1.GetID(), run3.GetID())
ts.NotEqual(run1.GetRunID(), run3.GetRunID())
}

func (ts *IntegrationTestSuite) TestChildWFRetryOnError() {
err := ts.executeWorkflow("test-childwf-retry-on-error", ts.workflows.ChildWorkflowRetryOnError, nil)
ts.Error(err)
Expand Down
14 changes: 14 additions & 0 deletions test/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,19 @@ func (w *Workflows) CancelTimerConcurrentWithOtherCommandWorkflow(ctx workflow.C
return result, nil
}

func (w *Workflows) WaitSignalReturnParam(ctx workflow.Context, v interface{}) (interface{}, error) {
// Wait for signal before returning
s := workflow.NewSelector(ctx)
signalCh := workflow.GetSignalChannel(ctx, "done-signal")
s.AddReceive(signalCh, func(c workflow.ReceiveChannel, more bool) {
var ignore bool
c.Receive(ctx, &ignore)
workflow.GetLogger(ctx).Info("Received signal")
})
s.Select(ctx)
return v, nil
}

func (w *Workflows) register(worker worker.Worker) {
worker.RegisterWorkflow(w.ActivityCancelRepro)
worker.RegisterWorkflow(w.ActivityCompletionUsingID)
Expand Down Expand Up @@ -1287,6 +1300,7 @@ func (w *Workflows) register(worker worker.Worker) {
worker.RegisterWorkflow(w.LongRunningActivityWithHB)
worker.RegisterWorkflow(w.RetryTimeoutStableErrorWorkflow)
worker.RegisterWorkflow(w.SimplestWorkflow)
worker.RegisterWorkflow(w.WaitSignalReturnParam)
worker.RegisterWorkflow(w.WorkflowWithLocalActivityCtxPropagation)
worker.RegisterWorkflow(w.WorkflowWithParallelLongLocalActivityAndHeartbeat)
worker.RegisterWorkflow(w.WorkflowWithLocalActivityRetries)
Expand Down