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

Support conflict options for starting Nexus operations in test framework #1828

Merged
merged 7 commits into from
Feb 24, 2025

Conversation

rodrigozhou
Copy link
Contributor

What was changed

Support OnConflictOptions when starting Nexus operation in test framework.

Why?

Checklist

  1. Closes

  2. How was this tested:

  1. Any docs updates needed?

@rodrigozhou rodrigozhou requested a review from a team as a code owner February 14, 2025 22:56
@@ -216,6 +216,7 @@ type (
WaitForCancellation bool
WorkflowIDReusePolicy enumspb.WorkflowIdReusePolicy
WorkflowIDConflictPolicy enumspb.WorkflowIdConflictPolicy
OnConflictOptions *OnConflictOptions
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm adding this WorkflowOptions, but not sure if I should. I need because the Nexus handler workflow is executed in the test framework as a child workflow, and I need this to resolve workflow ID conflict, ie., starting the same operation multiple times.

I can see this is used in certain operations. For example, I saw WorkflowOptions is built for ExecuteChildWorkflow, and OnConflictOptions is not an options for executing child workflow.

Btw, WorkflowIDConflictPolicy was added here a while ago, but I didn't see any usage of this field anywhere... I'm using it now here though.

cc: @Quinn-With-Two-Ns @cretz

Copy link
Contributor

Choose a reason for hiding this comment

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

WorkflowIDConflictPolicy is not supported for child workflows temporalio/temporal#6799 so yeah it probably shouldn't have been added here.

Is it reasonable to refactor the Nexus handler workflow to not be a "child" in the test framework?

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, we shouldn't add an unused field here (even if there happens to be another unused field here)

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 Rodrigo is saying it is no longer an unused field, but I guess it is unused when executing outside the test enviorment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, WorkflowIDConflictPolicy is unused since it was added in #1563, but I need it now with this PR.

As for not being a child workflow, I'm not sure how we would be able to run the Nexus workflow without it since the test environment only allows to run one main/root workflow at a time. cc: @bergundy

Copy link
Member

Choose a reason for hiding this comment

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

Oh, my mistake, I thought this was user-facing child workflow options or something. If this is an internal only thing I have no opinion/preference, will defer to Quinn.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

WorkflowOptions is somewhat user facing, isn't it? The user could get it from the workflow context.
The two fields I mentioned, it's only used in the test environment. Maybe I could just make them unexported?

Copy link
Contributor

Choose a reason for hiding this comment

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

How can users get WorkflowOptions from the workflow context?

Copy link
Contributor Author

@rodrigozhou rodrigozhou Feb 18, 2025

Choose a reason for hiding this comment

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

Well, it's not exported, but technically, the user could write directly ctx.Value("wfEnvOptions").
Otherwise, it seems it's only for internal.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think the only reason the type is even exported anyway is for the nexus test environment and maybe the PHP SDK

@rodrigozhou rodrigozhou force-pushed the rodrigozhou/nexus-conflict-options branch from 1ee8bda to 1210104 Compare February 14, 2025 23:07
@rodrigozhou rodrigozhou force-pushed the rodrigozhou/nexus-conflict-options-test branch from b357b6a to 61ba3ed Compare February 14, 2025 23:07
@rodrigozhou rodrigozhou force-pushed the rodrigozhou/nexus-conflict-options branch from 1210104 to 45f6370 Compare February 15, 2025 00:30
@@ -1264,6 +1265,137 @@ func TestWorkflowTestSuite_WorkflowRunOperation_WithCancel(t *testing.T) {
}
}

func TestWorkflowTestSuite_WorkflowRunOperation_MultipleCallers_NoAttachCallback(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Need to wait for this test to pass before merging this or #1797

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was a bug in the Nexus error handling that caused the issue. I fixed in this PR.

@rodrigozhou rodrigozhou force-pushed the rodrigozhou/nexus-conflict-options branch from 45f6370 to ffadd11 Compare February 18, 2025 23:59
@rodrigozhou rodrigozhou force-pushed the rodrigozhou/nexus-conflict-options-test branch from 61ba3ed to 25c0d55 Compare February 18, 2025 23:59
@rodrigozhou rodrigozhou requested a review from cretz February 19, 2025 04:38
@cretz
Copy link
Member

cretz commented Feb 19, 2025

Approved but still need @Quinn-With-Two-Ns approval

@rodrigozhou rodrigozhou force-pushed the rodrigozhou/nexus-conflict-options branch from ffadd11 to 8ceb55c Compare February 20, 2025 20:25
@rodrigozhou rodrigozhou force-pushed the rodrigozhou/nexus-conflict-options-test branch 2 times, most recently from f1c62f7 to 46de52d Compare February 20, 2025 21:10
@Quinn-With-Two-Ns
Copy link
Contributor

Quinn-With-Two-Ns commented Feb 20, 2025

Oh sorry not this PR, the other one 🤦

@rodrigozhou rodrigozhou force-pushed the rodrigozhou/nexus-conflict-options-test branch from a2f83e1 to c1e2dab Compare February 21, 2025 19:36
@rodrigozhou rodrigozhou force-pushed the rodrigozhou/nexus-conflict-options branch from 8ceb55c to 66dc27e Compare February 24, 2025 17:16
Base automatically changed from rodrigozhou/nexus-conflict-options to master February 24, 2025 19:02
@rodrigozhou rodrigozhou force-pushed the rodrigozhou/nexus-conflict-options-test branch from c1e2dab to e7c005b Compare February 24, 2025 19:07
@rodrigozhou rodrigozhou enabled auto-merge (squash) February 24, 2025 19:07
@rodrigozhou rodrigozhou merged commit 2449502 into master Feb 24, 2025
15 checks passed
@rodrigozhou rodrigozhou deleted the rodrigozhou/nexus-conflict-options-test branch February 24, 2025 19:59
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.

4 participants