Skip to content

Commit 8c58841

Browse files
committed
Test current_retry_interval is nil after dispatch to Matching
Covers the SCHEDULED branch where the retry has already been dispatched to Matching (now >= scheduledTime): both NextAttemptScheduleTime and CurrentRetryInterval must be nil. Run: go test ./service/history/workflow/ -run 'TestActivitySuite/TestGetPendingActivityInfoRetryDispatchedToMatching' -count=1
1 parent 93907ca commit 8c58841

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

service/history/workflow/activity_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,36 @@ func (s *activitySuite) TestGetPendingActivityInfoHasRetryPolicy() {
294294
s.Equal(ai.RetryMaximumAttempts, pi.ActivityOptions.RetryPolicy.MaximumAttempts)
295295
}
296296

297+
func (s *activitySuite) TestGetPendingActivityInfoNextAttemptScheduleTimeAndCurrentRetryInterval() {
298+
now := s.mockShard.GetTimeSource().Now().UTC()
299+
activityType := commonpb.ActivityType{
300+
Name: "activityType",
301+
}
302+
ai := &persistencespb.ActivityInfo{
303+
StartedEventId: common.EmptyEventID,
304+
LastAttemptCompleteTime: timestamppb.New(now),
305+
HasRetryPolicy: true,
306+
}
307+
s.mockMutableState.EXPECT().GetActivityType(gomock.Any(), gomock.Any()).Return(&activityType, nil).Times(2)
308+
309+
// Before dispatch to Matching: waiting for the retry, so we report when the next attempt is
310+
// scheduled and the interval until then.
311+
ai.ScheduledTime = timestamppb.New(now.Add(5 * time.Second))
312+
pi, err := GetPendingActivityInfo(context.Background(), s.mockShard, s.mockMutableState, ai)
313+
s.NoError(err)
314+
s.Equal(enumspb.PENDING_ACTIVITY_STATE_SCHEDULED, pi.State)
315+
s.Equal(ai.ScheduledTime, pi.NextAttemptScheduleTime)
316+
s.Equal(durationpb.New(5*time.Second), pi.CurrentRetryInterval)
317+
318+
// After dispatch to Matching: no next attempt schedule time or current retry interval.
319+
ai.ScheduledTime = timestamppb.New(now.Add(-1 * time.Minute))
320+
pi, err = GetPendingActivityInfo(context.Background(), s.mockShard, s.mockMutableState, ai)
321+
s.NoError(err)
322+
s.Equal(enumspb.PENDING_ACTIVITY_STATE_SCHEDULED, pi.State)
323+
s.Nil(pi.NextAttemptScheduleTime)
324+
s.Nil(pi.CurrentRetryInterval)
325+
}
326+
297327
func (s *activitySuite) AddActivityInfo() *persistencespb.ActivityInfo {
298328
activityId := "activity-id"
299329
activityScheduledEvent := &historypb.HistoryEvent{

0 commit comments

Comments
 (0)