diff --git a/common/persistence/data_manager_interfaces_test.go b/common/persistence/data_manager_interfaces_test.go index d3b9cd7ac59..c6bfdbf1c5c 100644 --- a/common/persistence/data_manager_interfaces_test.go +++ b/common/persistence/data_manager_interfaces_test.go @@ -69,7 +69,7 @@ func TestIsTimeoutError(t *testing.T) { func TestTaskCommonMethods(t *testing.T) { timeNow := time.Now() - tasks := []interface{}{ + tasks := []Task{ &ActivityTask{Version: 1, TaskID: 1, VisibilityTimestamp: timeNow}, &DecisionTask{Version: 1, TaskID: 1, VisibilityTimestamp: timeNow}, &RecordWorkflowStartedTask{Version: 1, TaskID: 1, VisibilityTimestamp: timeNow}, @@ -79,6 +79,19 @@ func TestTaskCommonMethods(t *testing.T) { &DecisionTimeoutTask{Version: 1, TaskID: 1, VisibilityTimestamp: timeNow}, &ActivityTimeoutTask{Version: 1, TaskID: 1, VisibilityTimestamp: timeNow}, &UserTimerTask{Version: 1, TaskID: 1, VisibilityTimestamp: timeNow}, + &ActivityRetryTimerTask{Version: 1, TaskID: 1, VisibilityTimestamp: timeNow}, + &WorkflowBackoffTimerTask{Version: 1, TaskID: 1, VisibilityTimestamp: timeNow}, + &WorkflowTimeoutTask{Version: 1, TaskID: 1, VisibilityTimestamp: timeNow}, + &CancelExecutionTask{Version: 1, TaskID: 1, VisibilityTimestamp: timeNow}, + &SignalExecutionTask{Version: 1, TaskID: 1, VisibilityTimestamp: timeNow}, + &RecordChildExecutionCompletedTask{Version: 1, TaskID: 1, VisibilityTimestamp: timeNow}, + &ApplyParentClosePolicyTask{Version: 1, TaskID: 1, VisibilityTimestamp: timeNow}, + &UpsertWorkflowSearchAttributesTask{Version: 1, TaskID: 1, VisibilityTimestamp: timeNow}, + &StartChildExecutionTask{Version: 1, TaskID: 1, VisibilityTimestamp: timeNow}, + &RecordWorkflowClosedTask{Version: 1, TaskID: 1, VisibilityTimestamp: timeNow}, + &HistoryReplicationTask{Version: 1, TaskID: 1, VisibilityTimestamp: timeNow}, + &SyncActivityTask{Version: 1, TaskID: 1, VisibilityTimestamp: timeNow}, + &FailoverMarkerTask{Version: 1, TaskID: 1, VisibilityTimestamp: timeNow}, } for _, task := range tasks { @@ -101,24 +114,77 @@ func TestTaskCommonMethods(t *testing.T) { assert.Equal(t, TaskTypeActivityTimeout, ty.GetType()) case *UserTimerTask: assert.Equal(t, TaskTypeUserTimer, ty.GetType()) + case *ActivityRetryTimerTask: + assert.Equal(t, TaskTypeActivityRetryTimer, ty.GetType()) + case *WorkflowBackoffTimerTask: + assert.Equal(t, TaskTypeWorkflowBackoffTimer, ty.GetType()) + case *WorkflowTimeoutTask: + assert.Equal(t, TaskTypeWorkflowTimeout, ty.GetType()) + case *CancelExecutionTask: + assert.Equal(t, TransferTaskTypeCancelExecution, ty.GetType()) + case *SignalExecutionTask: + assert.Equal(t, TransferTaskTypeSignalExecution, ty.GetType()) + case *RecordChildExecutionCompletedTask: + assert.Equal(t, TransferTaskTypeRecordChildExecutionCompleted, ty.GetType()) + case *ApplyParentClosePolicyTask: + assert.Equal(t, TransferTaskTypeApplyParentClosePolicy, ty.GetType()) + case *UpsertWorkflowSearchAttributesTask: + assert.Equal(t, TransferTaskTypeUpsertWorkflowSearchAttributes, ty.GetType()) + case *StartChildExecutionTask: + assert.Equal(t, TransferTaskTypeStartChildExecution, ty.GetType()) + case *RecordWorkflowClosedTask: + assert.Equal(t, TransferTaskTypeRecordWorkflowClosed, ty.GetType()) + case *HistoryReplicationTask: + assert.Equal(t, ReplicationTaskTypeHistory, ty.GetType()) + case *SyncActivityTask: + assert.Equal(t, ReplicationTaskTypeSyncActivity, ty.GetType()) + case *FailoverMarkerTask: + assert.Equal(t, ReplicationTaskTypeFailoverMarker, ty.GetType()) default: t.Fatalf("Unhandled task type: %T", t) } // Test version methods - assert.Equal(t, int64(1), task.(Task).GetVersion()) - task.(Task).SetVersion(2) - assert.Equal(t, int64(2), task.(Task).GetVersion()) + assert.Equal(t, int64(1), task.GetVersion()) + task.SetVersion(2) + assert.Equal(t, int64(2), task.GetVersion()) // Test TaskID methods - assert.Equal(t, int64(1), task.(Task).GetTaskID()) - task.(Task).SetTaskID(2) - assert.Equal(t, int64(2), task.(Task).GetTaskID()) + assert.Equal(t, int64(1), task.GetTaskID()) + task.SetTaskID(2) + assert.Equal(t, int64(2), task.GetTaskID()) // Test VisibilityTimestamp methods - assert.Equal(t, timeNow, task.(Task).GetVisibilityTimestamp()) + assert.Equal(t, timeNow, task.GetVisibilityTimestamp()) newTime := timeNow.Add(time.Second) - task.(Task).SetVisibilityTimestamp(newTime) - assert.Equal(t, newTime, task.(Task).GetVisibilityTimestamp()) + task.SetVisibilityTimestamp(newTime) + assert.Equal(t, newTime, task.GetVisibilityTimestamp()) + } +} + +func TestOnlyGetTypeTask(t *testing.T) { + tasks := []Task{ + &CrossClusterStartChildExecutionTask{}, + &CrossClusterCancelExecutionTask{}, + &CrossClusterSignalExecutionTask{}, + &CrossClusterRecordChildExecutionCompletedTask{}, + &CrossClusterApplyParentClosePolicyTask{}, + } + + for _, task := range tasks { + switch ty := task.(type) { + case *CrossClusterStartChildExecutionTask: + assert.Equal(t, CrossClusterTaskTypeStartChildExecution, ty.GetType()) + case *CrossClusterCancelExecutionTask: + assert.Equal(t, CrossClusterTaskTypeCancelExecution, ty.GetType()) + case *CrossClusterSignalExecutionTask: + assert.Equal(t, CrossClusterTaskTypeSignalExecution, ty.GetType()) + case *CrossClusterRecordChildExecutionCompletedTask: + assert.Equal(t, CrossClusterTaskTypeRecordChildExeuctionCompleted, ty.GetType()) + case *CrossClusterApplyParentClosePolicyTask: + assert.Equal(t, CrossClusterTaskTypeApplyParentClosePolicy, ty.GetType()) + default: + t.Fatalf("Unhandled task type: %T", t) + } } }