-
Notifications
You must be signed in to change notification settings - Fork 876
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
functional tests testing queries + nexus tasks with versioning-3 #7015
Conversation
tests/versioning_3_test.go
Outdated
s.verifyWorkflowVersioning(tv, vbUnpinned, tv.Deployment(), nil, nil) | ||
if sticky { | ||
s.verifyWorkflowStickyQueue(we, tv.StickyTaskQueue()) | ||
} |
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.
Let's add a query redirect step to this test. After this line, we should change the current deployment, and query the wf and make sure the new deployment's poller receives the query.
@@ -125,9 +146,123 @@ func (p *TaskPoller) PollAndHandleWorkflowTask( | |||
// If no task is available, it returns NoTaskAvailable. | |||
func (p *workflowTaskPoller) HandleTask( |
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.
Most of the time we do not work with queries, it seems a little to much to impose the nested TaskCompletedResponse on all usages. Why not keep all these methods untouched and add a HandleQueryTask
instead:
func (p *workflowTaskPoller) HandleQueryTask(tv *testvars.TestVars,
handler func(task *workflowservice.PollWorkflowTaskQueueResponse) (*workflowservice.RespondQueryTaskCompletedResponse, error)
TaskCompletedRequest struct { | ||
WorkflowTaskCompletedRequest *workflowservice.RespondWorkflowTaskCompletedRequest | ||
QueryTaskCompletedRequest *workflowservice.RespondQueryTaskCompletedRequest | ||
} | ||
TaskCompletedResponse struct { | ||
WorkflowTaskCompletedResponse *workflowservice.RespondWorkflowTaskCompletedResponse | ||
QueryTaskCompletedResponse *workflowservice.RespondQueryTaskCompletedResponse | ||
} |
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.
Hm, I'm not sure this is the right direction. I understand that the current API doesn't work for these Queries, but 95% of the time, the task poller will probably only deal with WFTs. Right now, without thinking longer about it, I see three other directions:
- Create a dedicated, exported function just for queries.
- Change the return type to any and require type assertions.
- Hide the fact that there's a "legacy" query (AFAIU) and use the "new" query API; but inside the taskpoller do the right thing auto-magically
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.
(1) would be the easiest and clearest; let me know if that's a feasible option. I haven't worked with this Query API before.
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.
tagging you @ShahabT here as well since you had the exact concern - The main point seems to be to remove the need for TaskCompletedResponse/Request
structures.
In my earlier stab at this, I did not have any of these structures and had made one exported function inside (*workflowTaskPoller).handleTask
and had changed the return type to any
(all the places that required it). Not, that in this attempt I also intended on using Versioning3Suite.pollWftAndHandle
since it served as a nice helper function for all my needs. My train of thought was:
- That "having type assertions and changing the return type to
nil
" or having these two structures were effectively conveying the same purpose: The response can be one of two types - Query or Workflow - Having understood this, if I were reading the codebase for the first time, I realized I would appreciate knowing that the handler deals with only Queries and Workflow related tasks (which is made clear by the structure in place since it has only those two fields vs
any
would make it a bit confusing)
Hence, I took the more tedious approach and went ahead with this option - I can certainly revert back if you both feel strongly of not keeping this the way it is but would be curious to hear your thoughts
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.
Your reasoning is totally reasonable; but I strongly believe it's not the right path because it's too verbose for the majority of use cases. That was already a concern before, and is exacerbated here.
Why not keep all these methods untouched and add a HandleQueryTask instead:
To pick up Shahab's suggestion; is this feasible in your opinion? If so, it would be my preferred 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.
Will be attempting to have type assertions in place along with a separate HandleQueryTask
method ⏳
@@ -804,6 +1051,78 @@ func (s *Versioning3Suite) pollWftAndHandle( | |||
return nil, nil | |||
} | |||
|
|||
func (s *Versioning3Suite) pollWftAndHandleQueries( |
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 was the giant guy I was trying to avoid all along which made me go down the rabbit hole of making those structures which in-turn stirred up the whole thread :(
cc - @stephanos @ShahabT
@@ -262,6 +389,51 @@ func (p *workflowTaskPoller) pollTask( | |||
return resp, err | |||
} | |||
|
|||
func (p *workflowTaskPoller) HandleQueries( |
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.
I think it would be best to signal that this is only for a legacy query. Like HandleLegacyQuery
. (same for the other methods below)
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.
I think this is a good point - having said that, do we need to add in more tests for the updated/latest queries
? I ended up choosing this one (noticed the new queries only later) since I figured we only wanted to check if the functionality with routing was working or not with versioning-3 changes
cc @ShahabT
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 there anything "legacy" about these query responses? (I see that they are called legacy in this proto)
But I don't think it's a good choice of word. Maybe something like standalone query fits better because these queries and RespondQueryTaskCompleted
request/responses are normally used and they are not deprecated in any sense as one would think by seeing them described as "legacy". Unless I'm mistaken, if there is other work to do in the wf, the query will be stuffed into the anyways-needed wft. Otherwise it'll be sent as standalone query (still a wft but with less info), an in that case SDK will send a RespondQueryTaskCompletedRequest instead of a RespondWorkflowTaskCompletedRequest.
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.
I agree, it felt a bit odd for me too to be calling something legacy
but actively use it in some of my work here - maybe this is a better question for the SDK folks and I can take this up with them;
I shall keep the function names with Legacy for now to respect which proto fields we are respecting but if we do see some changes in the proto side, I will alter the tests.
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.
I'm okay with a different name.
Having said that, it seems like this name stuck now as it's in the docs and used in our internal communication, too (searched Slack). I fear a different name - even if better/more accurate - only creates confusion. But I'm not blocking.
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.
thank you for the feedback!
@@ -262,6 +389,51 @@ func (p *workflowTaskPoller) pollTask( | |||
return resp, err | |||
} | |||
|
|||
func (p *workflowTaskPoller) HandleQueries( |
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.
I think this is a good point - having said that, do we need to add in more tests for the updated/latest queries
? I ended up choosing this one (noticed the new queries only later) since I figured we only wanted to check if the functionality with routing was working or not with versioning-3 changes
cc @ShahabT
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.
👍 LGTM from taskpoller perspective. I'll defer to Shahab for the rest.
go s.idlePollWorkflow(tv, true, ver3MinPollTime, "old deployment should not receive query") | ||
// Since the current deployment has changed, task will move to the normal queue (thus, sticky=false) | ||
s.pollAndQueryWorkflow(tvB, false) | ||
|
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.
I was able to catch some flakes happening because the previous poller, with deployment set to tvB
, was still up and running when I tried to poll and process a new query. This is fixed by ensuring the first poller dies before we continue the test.
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.
LGTM
What changed?
taskPoller
to now consider query and nexus tasksWhy?
How did you test it?
Potential risks
Documentation
Is hotfix candidate?
No