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

functional tests testing queries + nexus tasks with versioning-3 #7015

Merged
merged 19 commits into from
Jan 8, 2025

Conversation

Shivs11
Copy link
Member

@Shivs11 Shivs11 commented Dec 19, 2024

What changed?

  • various functional tests (sticky, no-sticky) testing Query + Nexus tasks routing with versioning-3
  • refactored taskPoller to now consider query and nexus tasks

Why?

  • more testing

How did you test it?

  • no feature related line changes so N/A

Potential risks

  • none: shall reduce risks if not for anything

Documentation

Is hotfix candidate?

No

@Shivs11 Shivs11 requested a review from a team as a code owner December 19, 2024 19:09
@Shivs11 Shivs11 requested review from ShahabT, carlydf and dnr and removed request for carlydf December 19, 2024 19:09
@Shivs11 Shivs11 changed the title Added functional tests testing queries for versioning-3 functional tests testing queries + nexus tasks with versioning-3 Dec 20, 2024
common/testing/taskpoller/taskpoller.go Show resolved Hide resolved
s.verifyWorkflowVersioning(tv, vbUnpinned, tv.Deployment(), nil, nil)
if sticky {
s.verifyWorkflowStickyQueue(we, tv.StickyTaskQueue())
}
Copy link
Collaborator

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(
Copy link
Collaborator

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)

Comment on lines 70 to 77
TaskCompletedRequest struct {
WorkflowTaskCompletedRequest *workflowservice.RespondWorkflowTaskCompletedRequest
QueryTaskCompletedRequest *workflowservice.RespondQueryTaskCompletedRequest
}
TaskCompletedResponse struct {
WorkflowTaskCompletedResponse *workflowservice.RespondWorkflowTaskCompletedResponse
QueryTaskCompletedResponse *workflowservice.RespondQueryTaskCompletedResponse
}
Copy link
Contributor

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:

  1. Create a dedicated, exported function just for queries.
  2. Change the return type to any and require type assertions.
  3. 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

Copy link
Contributor

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.

Copy link
Member Author

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

Copy link
Contributor

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.

Copy link
Member Author

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 ⏳

common/testing/taskpoller/taskpoller.go Show resolved Hide resolved
common/testing/taskpoller/taskpoller.go Show resolved Hide resolved
@@ -804,6 +1051,78 @@ func (s *Versioning3Suite) pollWftAndHandle(
return nil, nil
}

func (s *Versioning3Suite) pollWftAndHandleQueries(
Copy link
Member Author

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

tests/versioning_3_test.go Outdated Show resolved Hide resolved
@Shivs11 Shivs11 requested review from ShahabT and stephanos January 6, 2025 22:01
tests/versioning_3_test.go Outdated Show resolved Hide resolved
tests/versioning_3_test.go Outdated Show resolved Hide resolved
tests/versioning_3_test.go Outdated Show resolved Hide resolved
common/testing/taskpoller/taskpoller.go Outdated Show resolved Hide resolved
common/testing/taskpoller/taskpoller.go Outdated Show resolved Hide resolved
common/testing/taskpoller/taskpoller.go Outdated Show resolved Hide resolved
common/testing/taskpoller/taskpoller.go Show resolved Hide resolved
tests/versioning_3_test.go Outdated Show resolved Hide resolved
tests/versioning_3_test.go Outdated Show resolved Hide resolved
common/testing/taskpoller/taskpoller.go Outdated Show resolved Hide resolved
@@ -262,6 +389,51 @@ func (p *workflowTaskPoller) pollTask(
return resp, err
}

func (p *workflowTaskPoller) HandleQueries(
Copy link
Contributor

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)

Copy link
Member Author

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

Copy link
Collaborator

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.

Copy link
Member Author

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.

Copy link
Contributor

@stephanos stephanos Jan 8, 2025

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.

common/testing/taskpoller/taskpoller.go Show resolved Hide resolved
Copy link
Member Author

@Shivs11 Shivs11 left a 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!

tests/versioning_3_test.go Outdated Show resolved Hide resolved
@@ -262,6 +389,51 @@ func (p *workflowTaskPoller) pollTask(
return resp, err
}

func (p *workflowTaskPoller) HandleQueries(
Copy link
Member Author

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

common/testing/taskpoller/taskpoller.go Show resolved Hide resolved
common/testing/taskpoller/taskpoller.go Outdated Show resolved Hide resolved
common/testing/taskpoller/taskpoller.go Show resolved Hide resolved
common/testing/taskpoller/taskpoller.go Outdated Show resolved Hide resolved
tests/versioning_3_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@stephanos stephanos left a 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)

Copy link
Member Author

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.

Copy link
Collaborator

@ShahabT ShahabT left a comment

Choose a reason for hiding this comment

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

LGTM

@Shivs11 Shivs11 merged commit 7d95a34 into main Jan 8, 2025
49 checks passed
@Shivs11 Shivs11 deleted the shivam/query-versioning3-func-tests branch January 8, 2025 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants