Skip to content

Commit 1c40a68

Browse files
authored
Test error on long poll token with incorrect namespace (temporalio#8933)
## What changed? Add test of error on long poll token with incorrect namespace ## Why? Add test coverage for standalone activity ## How did you test it? - [x] added new functional test(s)
1 parent 7fe39fc commit 1c40a68

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

tests/standalone_activity_test.go

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

22982336
func (s *standaloneActivityTestSuite) TestHeartbeat() {

0 commit comments

Comments
 (0)