-
Notifications
You must be signed in to change notification settings - Fork 213
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
Dedup duplicate update IDs for test environment #1695
base: master
Are you sure you want to change the base?
Conversation
internal/workflow_testsuite_test.go
Outdated
require.Equal(t, 0, intResult) | ||
} | ||
}, | ||
env: env, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current solution requires env
to be passed to updateCallback, not ideal, but struggling to come up with an alternate solution
internal/internal_workflow_test.go
Outdated
@@ -1417,6 +1418,10 @@ func (uc *updateCallback) Reject(err error) { | |||
} | |||
|
|||
func (uc *updateCallback) Complete(success interface{}, err error) { | |||
// cache update result so we can dedup duplicate update IDs | |||
if uc.env.impl.updateMap != nil { | |||
uc.env.impl.updateMap[uc.env.impl.currentUpdateId] = success |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error would also need to be cached if we want to go with the caching approach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the error here represents the users error they returned from the update handler
@@ -229,6 +235,8 @@ type ( | |||
|
|||
workflowFunctionExecuting bool | |||
bufferedUpdateRequests map[string][]func() | |||
|
|||
currentUpdateId string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if there are multiple concurrent updates sent to the workflow? It looks like those would be lost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, good point
reject: func(err error) { | ||
err := env.UpdateWorkflowByID("my-workflow-id", "update", updateID, newUpdateCallback( | ||
env, | ||
updateID, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Quinn-With-Two-Ns how do you feel about solution? It doesn't feel ideal that we have to pass updateID
in 2 places, but I can't think of any other way to handle async updates. updateCallback
needs to know what the updateID to cache its result to env
is, and this seems like the only way to accomplish that.
@@ -1406,6 +1406,19 @@ type updateCallback struct { | |||
accept func() | |||
reject func(error) | |||
complete func(interface{}, error) | |||
env *TestWorkflowEnvironment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm so this class is not for users, this whole file is for testing since it is post-fixed with *_test.go
. The logic can't be in the updateCallback as we take an impl. from user. The logic needs to be in (env *testWorkflowEnvironmentImpl) updateWorkflow
. We could potentially add a wrapper around the user interface. Does that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is user
in this context referring to the user of the test suite?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this whole file is for testing since it is post-fixed with *_test.go. The logic can't be in the updateCallback as we take an impl. from user
And would it be accurate to rephrase this as "we need to implement this within the test suite, not the individual test logic. updateCallback
is a test specific implementation"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could potentially add a wrapper around the user interface.
What interface are you referring to here? updateWorkflow
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is user in this context referring to the user of the test suite?
Yeah
And would it be accurate to rephrase this as "we need to implement this within the test suite, not the individual test logic. updateCallback is a test specific implementation"?
yeah, exactly
What interface are you referring to here?
UpdateCallbacks
What was changed
Added functionality in test environment to cache update
Why?
Match non-test behavior
Checklist
Closes Workflow Update in Test Environment should dedup updates by ID #1638
How was this tested:
new test written
Any docs updates needed?