@@ -2292,7 +2292,45 @@ func (s *standaloneActivityTestSuite) TestDescribeActivityExecution_InvalidArgum
22922292 require .Equal (t , "long poll token does not match execution" , invalidArgErr .Message )
22932293 })
22942294
2295- // TODO(dan): add test for long poll token from non-existent execution
2295+ t .Run ("LongPollTokenFromDifferentNamespace" , func (t * testing.T ) {
2296+ // Get a valid poll token from activity in main namespace
2297+ validPollResp , err := s .FrontendClient ().DescribeActivityExecution (ctx , & workflowservice.DescribeActivityExecutionRequest {
2298+ Namespace : existingNamespace ,
2299+ ActivityId : existingActivityID ,
2300+ RunId : existingRunID ,
2301+ })
2302+ require .NoError (t , err )
2303+ require .NotEmpty (t , validPollResp .LongPollToken )
2304+
2305+ // Start an activity in a different namespace
2306+ externalNamespace := s .ExternalNamespace ().String ()
2307+ externalActivityID := s .tv .Any ().String ()
2308+ externalStartResp , err := s .FrontendClient ().StartActivityExecution (ctx , & workflowservice.StartActivityExecutionRequest {
2309+ Namespace : externalNamespace ,
2310+ ActivityId : externalActivityID ,
2311+ ActivityType : s .tv .ActivityType (),
2312+ Identity : s .tv .WorkerIdentity (),
2313+ Input : defaultInput ,
2314+ TaskQueue : & taskqueuepb.TaskQueue {
2315+ Name : tq .Name ,
2316+ },
2317+ StartToCloseTimeout : durationpb .New (defaultStartToCloseTimeout ),
2318+ RequestId : s .tv .Any ().String (),
2319+ })
2320+ require .NoError (t , err )
2321+ require .NotEmpty (t , externalStartResp .GetRunId ())
2322+
2323+ // Try to use main namespace's poll token with external namespace's activity
2324+ _ , err = s .FrontendClient ().DescribeActivityExecution (ctx , & workflowservice.DescribeActivityExecutionRequest {
2325+ Namespace : externalNamespace ,
2326+ ActivityId : externalActivityID ,
2327+ RunId : externalStartResp .GetRunId (),
2328+ LongPollToken : validPollResp .LongPollToken ,
2329+ })
2330+ var invalidArgErr * serviceerror.InvalidArgument
2331+ require .ErrorAs (t , err , & invalidArgErr )
2332+ require .Equal (t , "long poll token does not match execution" , invalidArgErr .Message )
2333+ })
22962334}
22972335
22982336func (s * standaloneActivityTestSuite ) TestHeartbeat () {
0 commit comments