88 "testing"
99 "time"
1010
11+ "github.com/google/uuid"
1112 "github.com/nexus-rpc/sdk-go/nexus"
1213 "github.com/stretchr/testify/assert"
1314 "github.com/stretchr/testify/require"
@@ -19,6 +20,10 @@ import (
1920 "go.temporal.io/api/serviceerror"
2021 taskqueuepb "go.temporal.io/api/taskqueue/v1"
2122 "go.temporal.io/api/workflowservice/v1"
23+ "go.temporal.io/sdk/client"
24+ "go.temporal.io/sdk/temporalnexus"
25+ "go.temporal.io/sdk/worker"
26+ "go.temporal.io/sdk/workflow"
2227 persistencespb "go.temporal.io/server/api/persistence/v1"
2328 "go.temporal.io/server/chasm/lib/nexusoperation"
2429 "go.temporal.io/server/common/dynamicconfig"
@@ -2123,6 +2128,52 @@ func (s *NexusStandaloneTestSuite) TestStandaloneNexusOperationPoll() {
21232128 })
21242129}
21252130
2131+ // Verifies that CHASM-backed Standalone Nexus is compatible with HSM-backed callbacks.
2132+ func (s * NexusStandaloneTestSuite ) TestAsyncCompletionAgainstWorkflowHandler () {
2133+ env := s .newTestEnv (testcore .WithDynamicConfig (dynamicconfig .EnableCHASMCallbacks , false ))
2134+ ctx := env .Context ()
2135+
2136+ handlerTaskQueue := testcore .RandomizeStr (s .T ().Name ())
2137+ endpointName := env .createNexusEndpoint (ctx , s .T (), testcore .RandomizedNexusEndpoint (s .T ().Name ()), handlerTaskQueue ).GetSpec ().GetName ()
2138+
2139+ handlerWF := func (workflow.Context , nexus.NoValue ) (string , error ) {
2140+ return "ok" , nil
2141+ }
2142+
2143+ svc := nexus .NewService ("test-service" )
2144+ nexusOp := temporalnexus .NewWorkflowRunOperation ("test-operation" , handlerWF ,
2145+ func (_ context.Context , _ nexus.NoValue , _ nexus.StartOperationOptions ) (client.StartWorkflowOptions , error ) {
2146+ return client.StartWorkflowOptions {
2147+ ID : "handler-wf-" + uuid .NewString (),
2148+ TaskQueue : handlerTaskQueue ,
2149+ }, nil
2150+ })
2151+ svc .MustRegister (nexusOp )
2152+
2153+ w := worker .New (env .SdkClient (), handlerTaskQueue , worker.Options {})
2154+ w .RegisterWorkflow (handlerWF )
2155+ w .RegisterNexusService (svc )
2156+ s .NoError (w .Start ())
2157+ defer w .Stop ()
2158+
2159+ startResp , err := s .startNexusOperation (env , & workflowservice.StartNexusOperationExecutionRequest {
2160+ OperationId : "test-op" ,
2161+ Endpoint : endpointName ,
2162+ })
2163+ s .NoError (err )
2164+
2165+ s .EventuallyWithT (func (t * assert.CollectT ) {
2166+ descResp , err := env .FrontendClient ().DescribeNexusOperationExecution (ctx , & workflowservice.DescribeNexusOperationExecutionRequest {
2167+ Namespace : env .Namespace ().String (),
2168+ OperationId : "test-op" ,
2169+ RunId : startResp .RunId ,
2170+ IncludeOutcome : true ,
2171+ })
2172+ require .NoError (t , err )
2173+ require .Equal (t , enumspb .NEXUS_OPERATION_EXECUTION_STATUS_COMPLETED , descResp .GetInfo ().GetStatus ())
2174+ }, 30 * time .Second , 200 * time .Millisecond )
2175+ }
2176+
21262177func (s * NexusStandaloneTestSuite ) TestAsyncCompletionIgnoresTransitionFieldsInCallbackToken () {
21272178 env := s .newTestEnv ()
21282179 handlerLink := & commonpb.Link_WorkflowEvent {
0 commit comments