Skip to content

Update Nexus tests to use parallelsuite#9768

Merged
long-nt-tran merged 4 commits intotemporalio:mainfrom
long-nt-tran:migrate-nexus-tests
Apr 7, 2026
Merged

Update Nexus tests to use parallelsuite#9768
long-nt-tran merged 4 commits intotemporalio:mainfrom
long-nt-tran:migrate-nexus-tests

Conversation

@long-nt-tran
Copy link
Copy Markdown
Contributor

@long-nt-tran long-nt-tran commented Apr 1, 2026

What changed?

  • Migrate the NexusTestBaseSuite to extend a lower-level *testcore.TestEnv instead of testcore.FunctionalTestBase, and rename NexusTestBaseSuite to a more aptly-named NexusTestEnv
  • Migrated all tests that uses the base to parallelsuite which required edits of the following types:
    • Change calls like s.GetTestCluster() to env.GetTestCluster(), because now these things are provided by the NexusTestEnv environment rather than the suite as before
    • A lot of tests needed testcore.WithDedicatedCluster() for isolation, otherwise tests using capture to assert on metrics would get polluted
    • s.Eventually(...) (or some other s.Assertion(...) type calls) --> require.Eventually(t, ...), so the failures are reported at the right test rather than at suite level. Previously tests were not ran in parallel so this may not have been an issue
    • s.GetTestCluster().FrontendClient()... --> env.FrontendClient()...
    • Creating dedicated cluster env inside subtests instead of outside
    • Misc. changes -- I've commented inline

Why?

Migrate to the latest and greatest, and make clearer the division between what's provided by the suite vs. env. This PR also enables parallel runs of tests, which sped up test runtime (see bottom of PR for rudimentary benchmarks).

How did you test it?

  • built
  • run locally and tested manually
  • covered by existing tests
  • added new unit test(s)
  • added new functional test(s)

Test runtimes

nexus_api_test.go
Before:

$ go test ./tests/ -run 'TestNexusApiTestSuite' -count=1
ok      go.temporal.io/server/tests     7.588s

After:

$ go test ./tests/ -run 'TestNexusApiTestSuite' -count=1
ok      go.temporal.io/server/tests     2.799s

nexus_api_validation_test.go
Before:

$ go test ./tests/ -run 'TestNexusAPIValidationTestSuite' -count=1
ok      go.temporal.io/server/tests     2.309s

After:

$ go test ./tests/ -run 'TestNexusAPIValidationTestSuite' -count=1
ok      go.temporal.io/server/tests     1.384s

nexus_workflow_test.go
Before:

$ go test ./tests/ -run 'TestNexusWorkflowTestSuite' -count=1
ok      go.temporal.io/server/tests     11.083s

After:

$ go test ./tests/ -run 'TestNexusWorkflowTestSuite' -count=1
ok      go.temporal.io/server/tests     3.709s

@long-nt-tran long-nt-tran force-pushed the migrate-nexus-tests branch from 80aa537 to c4b319a Compare April 1, 2026 19:04
Comment thread tests/nexus_api_test.go Outdated
@long-nt-tran long-nt-tran force-pushed the migrate-nexus-tests branch 5 times, most recently from 5181ec8 to 04a24f0 Compare April 6, 2026 17:35
Comment thread tests/testcore/test_env.go Outdated
Comment thread tests/nexus_api_test.go Outdated
@long-nt-tran long-nt-tran force-pushed the migrate-nexus-tests branch 2 times, most recently from ef22c5f to 5a69e6c Compare April 6, 2026 18:47
@long-nt-tran long-nt-tran requested a review from stephanos April 6, 2026 19:12
@long-nt-tran long-nt-tran marked this pull request as ready for review April 6, 2026 19:12
@long-nt-tran long-nt-tran requested review from a team as code owners April 6, 2026 19:12
Comment thread tests/nexus_api_validation_test.go Outdated
Comment thread tests/nexus_api_test.go Outdated
Comment thread tests/nexus_api_test.go Outdated
Comment thread tests/nexus_api_test.go Outdated
Comment thread tests/nexus_api_test.go Outdated
Comment thread tests/nexus_api_test.go Outdated
Comment thread tests/nexus_api_test.go Outdated
Comment thread tests/testcore/test_env.go Outdated
@long-nt-tran long-nt-tran force-pushed the migrate-nexus-tests branch from 5a69e6c to 08fc335 Compare April 6, 2026 22:09
Comment thread tests/testcore/test_env.go Outdated
Comment thread tests/nexus_api_test.go Outdated
Comment thread tests/nexus_api_test.go Outdated
@long-nt-tran long-nt-tran force-pushed the migrate-nexus-tests branch from 08fc335 to 8a18d8f Compare April 6, 2026 22:28
Comment thread tests/nexus_api_test.go
Comment thread tests/testcore/test_env.go Outdated
Comment thread tests/testcore/test_env.go Outdated
Comment thread tests/nexus_api_test.go
Comment thread tests/nexus_api_validation_test.go Outdated
@long-nt-tran long-nt-tran force-pushed the migrate-nexus-tests branch from 8a18d8f to 04e3d00 Compare April 7, 2026 16:23
Comment thread tests/nexus_api_test.go
name string
outcome string
endpoint *nexuspb.Endpoint
endpointName string
Copy link
Copy Markdown
Contributor Author

@long-nt-tran long-nt-tran Apr 7, 2026

Choose a reason for hiding this comment

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

since we're creating dedicated env per subtest for isolated metric captures, the endpoint needs to be created inside the subtest itself, so just having the name as the field here so each subtest can do

env.createNexusEndpoint(testcore.RandomizeStr("test-endpoint"), testcore.RandomizeStr("task-queue")),

@long-nt-tran long-nt-tran force-pushed the migrate-nexus-tests branch 2 times, most recently from f5e4d87 to 9f7951a Compare April 7, 2026 16:39
@long-nt-tran long-nt-tran requested a review from stephanos April 7, 2026 17:07
Comment thread tests/nexus_workflow_test.go Outdated
ctx := testcore.NewContext()

s.Run("NamespaceNotFound", func() {
env.Run("NamespaceNotFound", func() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't know if I missed it before, but this needs to be s.Run (otherwise it won't run in parallel). And that will likely require env to be once in every Run to make the metric snapshots deterministic.

Comment thread tests/nexus_workflow_test.go Outdated
@@ -2690,8 +2703,8 @@ func (s *NexusWorkflowTestSuite) TestNexusAsyncOperationWithMultipleCallers() {
}

for _, tc := range testCases {
s.Run(tc.input, func() {
run, err := s.SdkClient().ExecuteWorkflow(
env.Run(tc.input, func() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here as above.

Comment thread tests/testcore/test_env.go Outdated
Comment on lines +187 to +193
// Set URL template after httpAPAddress is set, see commonnexus.RouteCompletionCallback
// We use the FunctionalTestBase.OverrideDynamicConfig(...) here so we can set this global
// setting even on dedicated cluster setup.
env.FunctionalTestBase.OverrideDynamicConfig(
nexusoperations.CallbackURLTemplate,
"http://"+env.HttpAPIAddress()+"/namespaces/{{.NamespaceName}}/nexus/callback")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is there a way to modify this config after a dedicated cluster has been allocated ( in the test)?

I commented this out and only a few tests failed.

Copy link
Copy Markdown
Contributor

@stephanos stephanos Apr 7, 2026

Choose a reason for hiding this comment

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

Note we had a previous convo around this here: #9768 (comment)

tl;dr we want to make this a default to avoid having to mark it as dedicated when this default setting works just fine as it's a global config - it should be overridable.

@long-nt-tran long-nt-tran force-pushed the migrate-nexus-tests branch 2 times, most recently from 13a41d4 to 6793cd6 Compare April 7, 2026 21:07
name string
onAuthorize func(context.Context, *authorization.Claims, *authorization.CallTarget) (authorization.Result, error)
checkFailure func(t *testing.T, handlerErr *nexus.HandlerError)
onAuthorize func(endpointName string) func(context.Context, *authorization.Claims, *authorization.CallTarget) (authorization.Result, error)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

endpoint name needs to be created in the subtest after env is created, hence needing a factory fn here

@long-nt-tran long-nt-tran force-pushed the migrate-nexus-tests branch 2 times, most recently from 44c446f to 3c63355 Compare April 7, 2026 21:44
@long-nt-tran long-nt-tran requested a review from stephanos April 7, 2026 21:48
@long-nt-tran long-nt-tran force-pushed the migrate-nexus-tests branch from 3c63355 to 96801fc Compare April 7, 2026 21:54
Copy link
Copy Markdown
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! Please address the remaining comments before you merge.

Comment thread tests/testcore/test_env.go Outdated
Comment thread tests/nexus_api_validation_test.go Outdated
Comment thread tests/nexus_api_validation_test.go Outdated
Comment thread tests/nexus_api_validation_test.go Outdated
@long-nt-tran long-nt-tran force-pushed the migrate-nexus-tests branch from 96801fc to fa17d8c Compare April 7, 2026 22:15
@long-nt-tran long-nt-tran force-pushed the migrate-nexus-tests branch from fa17d8c to 15fbf02 Compare April 7, 2026 22:27
@long-nt-tran long-nt-tran enabled auto-merge (squash) April 7, 2026 22:37
@long-nt-tran long-nt-tran merged commit 0c3969a into temporalio:main Apr 7, 2026
46 checks passed
@long-nt-tran long-nt-tran deleted the migrate-nexus-tests branch April 8, 2026 00:01
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