Skip to content

Commit

Permalink
Include Domain in GRPC UpdateDomainIsolationGroupsRequest (uber#6114)
Browse files Browse the repository at this point in the history
  • Loading branch information
natemort authored and timl3136 committed Jun 6, 2024
1 parent 58bb0cc commit 5bbe89c
Show file tree
Hide file tree
Showing 7 changed files with 243 additions and 16 deletions.
9 changes: 2 additions & 7 deletions common/types/mapper/proto/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -1180,9 +1180,6 @@ func FromAdminUpdateGlobalIsolationGroupsRequest(t *types.UpdateGlobalIsolationG
if t == nil {
return nil
}
if t.IsolationGroups == nil {
return &adminv1.UpdateGlobalIsolationGroupsRequest{}
}
return &adminv1.UpdateGlobalIsolationGroupsRequest{
IsolationGroups: FromIsolationGroupConfig(&t.IsolationGroups),
}
Expand All @@ -1192,10 +1189,8 @@ func FromAdminUpdateDomainIsolationGroupsRequest(t *types.UpdateDomainIsolationG
if t == nil {
return nil
}
if t.IsolationGroups == nil {
return &adminv1.UpdateDomainIsolationGroupsRequest{}
}
return &adminv1.UpdateDomainIsolationGroupsRequest{
Domain: t.Domain,
IsolationGroups: FromIsolationGroupConfig(&t.IsolationGroups),
}
}
Expand Down Expand Up @@ -1324,7 +1319,7 @@ func ToAdminUpdateDomainIsolationGroupsRequest(t *adminv1.UpdateDomainIsolationG
}

func FromIsolationGroupConfig(in *types.IsolationGroupConfiguration) *apiv1.IsolationGroupConfiguration {
if in == nil {
if in == nil || *in == nil {
return nil
}
var out []*apiv1.IsolationGroupPartition
Expand Down
102 changes: 102 additions & 0 deletions common/types/mapper/proto/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ func TestAdminCloseShardRequest(t *testing.T) {
assert.Equal(t, item, ToAdminCloseShardRequest(FromAdminCloseShardRequest(item)))
}
}
func TestAdminDeleteWorkflowRequest(t *testing.T) {
for _, item := range []*types.AdminDeleteWorkflowRequest{nil, {}, &testdata.AdminDeleteWorkflowRequest} {
assert.Equal(t, item, ToAdminDeleteWorkflowRequest(FromAdminDeleteWorkflowRequest(item)))
}
}
func TestAdminDeleteWorkflowResponse(t *testing.T) {
for _, item := range []*types.AdminDeleteWorkflowResponse{nil, {}, &testdata.AdminDeleteWorkflowResponse} {
assert.Equal(t, item, ToAdminDeleteWorkflowResponse(FromAdminDeleteWorkflowResponse(item)))
}
}
func TestAdminDescribeClusterResponse(t *testing.T) {
for _, item := range []*types.DescribeClusterResponse{nil, {}, &testdata.AdminDescribeClusterResponse} {
assert.Equal(t, item, ToAdminDescribeClusterResponse(FromAdminDescribeClusterResponse(item)))
Expand Down Expand Up @@ -74,6 +84,16 @@ func TestAdminDescribeQueueResponse(t *testing.T) {
assert.Equal(t, item, ToAdminDescribeQueueResponse(FromAdminDescribeQueueResponse(item)))
}
}
func TestAdminDescribeShardDistributionRequest(t *testing.T) {
for _, item := range []*types.DescribeShardDistributionRequest{nil, {}, &testdata.AdminDescribeShardDistributionRequest} {
assert.Equal(t, item, ToAdminDescribeShardDistributionRequest(FromAdminDescribeShardDistributionRequest(item)))
}
}
func TestAdminDescribeShardDistributionResponse(t *testing.T) {
for _, item := range []*types.DescribeShardDistributionResponse{nil, {}, &testdata.AdminDescribeShardDistributionResponse} {
assert.Equal(t, item, ToAdminDescribeShardDistributionResponse(FromAdminDescribeShardDistributionResponse(item)))
}
}
func TestAdminDescribeWorkflowExecutionRequest(t *testing.T) {
for _, item := range []*types.AdminDescribeWorkflowExecutionRequest{nil, {}, &testdata.AdminDescribeWorkflowExecutionRequest} {
assert.Equal(t, item, ToAdminDescribeWorkflowExecutionRequest(FromAdminDescribeWorkflowExecutionRequest(item)))
Expand All @@ -94,6 +114,16 @@ func TestAdminGetDLQReplicationMessagesResponse(t *testing.T) {
assert.Equal(t, item, ToAdminGetDLQReplicationMessagesResponse(FromAdminGetDLQReplicationMessagesResponse(item)))
}
}
func TestAdminGetDomainIsolationGroupsRequest(t *testing.T) {
for _, item := range []*types.GetDomainIsolationGroupsRequest{nil, {}, &testdata.AdminGetDomainIsolationGroupsRequest} {
assert.Equal(t, item, ToAdminGetDomainIsolationGroupsRequest(FromAdminGetDomainIsolationGroupsRequest(item)))
}
}
func TestAdminGetDomainIsolationGroupsResponse(t *testing.T) {
for _, item := range []*types.GetDomainIsolationGroupsResponse{nil, {}, &testdata.AdminGetDomainIsolationGroupsResponse} {
assert.Equal(t, item, ToAdminGetDomainIsolationGroupsResponse(FromAdminGetDomainIsolationGroupsResponse(item)))
}
}
func TestAdminGetDomainReplicationMessagesRequest(t *testing.T) {
for _, item := range []*types.GetDomainReplicationMessagesRequest{nil, {}, &testdata.AdminGetDomainReplicationMessagesRequest} {
assert.Equal(t, item, ToAdminGetDomainReplicationMessagesRequest(FromAdminGetDomainReplicationMessagesRequest(item)))
Expand All @@ -104,6 +134,21 @@ func TestAdminGetDomainReplicationMessagesResponse(t *testing.T) {
assert.Equal(t, item, ToAdminGetDomainReplicationMessagesResponse(FromAdminGetDomainReplicationMessagesResponse(item)))
}
}
func TestAdminGetDynamicConfigRequest(t *testing.T) {
for _, item := range []*types.GetDynamicConfigRequest{nil, {}, &testdata.AdminGetDynamicConfigRequest} {
assert.Equal(t, item, ToAdminGetDynamicConfigRequest(FromAdminGetDynamicConfigRequest(item)))
}
}
func TestAdminGetDynamicConfigResponse(t *testing.T) {
for _, item := range []*types.GetDynamicConfigResponse{nil, {}, &testdata.AdminGetDynamicConfigResponse} {
assert.Equal(t, item, ToAdminGetDynamicConfigResponse(FromAdminGetDynamicConfigResponse(item)))
}
}
func TestAdminGetGlobalIsolationGroupsRequest(t *testing.T) {
for _, item := range []*types.GetGlobalIsolationGroupsRequest{nil, {}, &testdata.AdminGetGlobalIsolationGroupsRequest} {
assert.Equal(t, item, ToAdminGetGlobalIsolationGroupsRequest(FromAdminGetGlobalIsolationGroupsRequest(item)))
}
}
func TestAdminGetReplicationMessagesRequest(t *testing.T) {
for _, item := range []*types.GetReplicationMessagesRequest{nil, {}, &testdata.AdminGetReplicationMessagesRequest} {
assert.Equal(t, item, ToAdminGetReplicationMessagesRequest(FromAdminGetReplicationMessagesRequest(item)))
Expand Down Expand Up @@ -134,6 +179,26 @@ func TestAdminCountDLQMessagesResponse(t *testing.T) {
assert.Equal(t, item, ToAdminCountDLQMessagesResponse(FromAdminCountDLQMessagesResponse(item)))
}
}
func TestAdminListDynamicConfigRequest(t *testing.T) {
for _, item := range []*types.ListDynamicConfigRequest{nil, {}, &testdata.AdminListDynamicConfigRequest} {
assert.Equal(t, item, ToAdminListDynamicConfigRequest(FromAdminListDynamicConfigRequest(item)))
}
}
func TestAdminListDynamicConfigResponse(t *testing.T) {
for _, item := range []*types.ListDynamicConfigResponse{nil, {}, &testdata.AdminListDynamicConfigResponse} {
assert.Equal(t, item, ToAdminListDynamicConfigResponse(FromAdminListDynamicConfigResponse(item)))
}
}
func TestAdminMaintainCorruptWorkflowRequest(t *testing.T) {
for _, item := range []*types.AdminMaintainWorkflowRequest{nil, {}, &testdata.AdminMaintainCorruptWorkflowRequest} {
assert.Equal(t, item, ToAdminMaintainCorruptWorkflowRequest(FromAdminMaintainCorruptWorkflowRequest(item)))
}
}
func TestAdminMaintainCorruptWorkflowResponse(t *testing.T) {
for _, item := range []*types.AdminMaintainWorkflowResponse{nil, {}, &testdata.AdminMaintainCorruptWorkflowResponse} {
assert.Equal(t, item, ToAdminMaintainCorruptWorkflowResponse(FromAdminMaintainCorruptWorkflowResponse(item)))
}
}
func TestAdminMergeDLQMessagesRequest(t *testing.T) {
for _, item := range []*types.MergeDLQMessagesRequest{nil, {}, &testdata.AdminMergeDLQMessagesRequest} {
assert.Equal(t, item, ToAdminMergeDLQMessagesRequest(FromAdminMergeDLQMessagesRequest(item)))
Expand Down Expand Up @@ -208,6 +273,31 @@ func TestAdminRespondCrossClusterTasksCompletedResponse(t *testing.T) {
assert.Equal(t, item, ToAdminRespondCrossClusterTasksCompletedResponse(FromAdminRespondCrossClusterTasksCompletedResponse(item)))
}
}
func TestAdminUpdateDomainIsolationGroupsRequest(t *testing.T) {
for _, item := range []*types.UpdateDomainIsolationGroupsRequest{nil, {}, &testdata.AdminUpdateDomainIsolationGroupsRequest} {
assert.Equal(t, item, ToAdminUpdateDomainIsolationGroupsRequest(FromAdminUpdateDomainIsolationGroupsRequest(item)))
}
}
func TestAdminUpdateDomainIsolationGroupsResponse(t *testing.T) {
for _, item := range []*types.UpdateDomainIsolationGroupsResponse{nil, {}, &testdata.AdminUpdateDomainIsolationGroupsResponse} {
assert.Equal(t, item, ToAdminUpdateDomainIsolationGroupsResponse(FromAdminUpdateDomainIsolationGroupsResponse(item)))
}
}
func TestAdminRestoreDynamicConfigRequest(t *testing.T) {
for _, item := range []*types.RestoreDynamicConfigRequest{nil, {}, &testdata.AdminRestoreDynamicConfigRequest} {
assert.Equal(t, item, ToAdminRestoreDynamicConfigRequest(FromAdminRestoreDynamicConfigRequest(item)))
}
}
func TestAdminUpdateDynamicConfigRequest(t *testing.T) {
for _, item := range []*types.UpdateDynamicConfigRequest{nil, {}, &testdata.AdminUpdateDynamicConfigRequest} {
assert.Equal(t, item, ToAdminUpdateDynamicConfigRequest(FromAdminUpdateDynamicConfigRequest(item)))
}
}
func TestAdminUpdateGlobalIsolationGroupsResponse(t *testing.T) {
for _, item := range []*types.UpdateGlobalIsolationGroupsResponse{nil, {}, &testdata.AdminUpdateGlobalIsolationGroupsResponse} {
assert.Equal(t, item, ToAdminUpdateGlobalIsolationGroupsResponse(FromAdminUpdateGlobalIsolationGroupsResponse(item)))
}
}

func TestFromAdminGetGlobalIsolationGroupsResponse(t *testing.T) {
tests := map[string]struct {
Expand Down Expand Up @@ -253,6 +343,14 @@ func TestFromAdminGetGlobalIsolationGroupsResponse(t *testing.T) {
"nil - 2": {
expected: nil,
},
"nil - 3": {
in: &types.GetGlobalIsolationGroupsResponse{
IsolationGroups: nil,
},
expected: &adminv1.GetGlobalIsolationGroupsResponse{
IsolationGroups: nil,
},
},
}

for name, td := range tests {
Expand Down Expand Up @@ -281,6 +379,10 @@ func TestToAdminGetGlobalIsolationGroupsRequest(t *testing.T) {
in: &adminv1.GetGlobalIsolationGroupsRequest{},
expected: &types.GetGlobalIsolationGroupsRequest{},
},
"nil": {
in: nil,
expected: nil,
},
}

for name, td := range tests {
Expand Down
15 changes: 15 additions & 0 deletions common/types/mapper/proto/enum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,21 @@ func TestContinueAsNewInitiator(t *testing.T) {
assert.Panics(t, func() { ToContinueAsNewInitiator(apiv1.ContinueAsNewInitiator(UnknownValue)) })
assert.Panics(t, func() { FromContinueAsNewInitiator(types.ContinueAsNewInitiator(UnknownValue).Ptr()) })
}
func TestCrossClusterTaskFailedCause(t *testing.T) {
for _, item := range []*types.CrossClusterTaskFailedCause{
nil,
types.CrossClusterTaskFailedCauseDomainNotActive.Ptr(),
types.CrossClusterTaskFailedCauseDomainNotExists.Ptr(),
types.CrossClusterTaskFailedCauseWorkflowAlreadyRunning.Ptr(),
types.CrossClusterTaskFailedCauseWorkflowNotExists.Ptr(),
types.CrossClusterTaskFailedCauseWorkflowAlreadyCompleted.Ptr(),
types.CrossClusterTaskFailedCauseUncategorized.Ptr(),
} {
assert.Equal(t, item, ToCrossClusterTaskFailedCause(FromCrossClusterTaskFailedCause(item)))
}
assert.Panics(t, func() { ToCrossClusterTaskFailedCause(adminv1.CrossClusterTaskFailedCause(UnknownValue)) })
assert.Panics(t, func() { FromCrossClusterTaskFailedCause(types.CrossClusterTaskFailedCause(UnknownValue).Ptr()) })
}
func TestDecisionTaskFailedCause(t *testing.T) {
for _, item := range []*types.DecisionTaskFailedCause{
nil,
Expand Down
10 changes: 10 additions & 0 deletions common/types/testdata/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,16 @@ var (
IndexedValueTypeMap = map[string]types.IndexedValueType{
"IndexedValueType1": IndexedValueType,
}
IsolationGroupConfiguration = types.IsolationGroupConfiguration{
IsolationGroup: {
Name: IsolationGroup,
State: types.IsolationGroupStateHealthy,
},
"zone 1": {
Name: "zone 1",
State: types.IsolationGroupStateDrained,
},
}
ParentExecutionInfo = types.ParentExecutionInfo{
DomainUUID: DomainID,
Domain: DomainName,
Expand Down
18 changes: 10 additions & 8 deletions common/types/testdata/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,18 @@ var (
StartChildExecutionAttributes: &CrossClusterStartChildExecutionResponseAttributes,
}
CrossClusterTaskResponseCancelExecution = types.CrossClusterTaskResponse{
TaskID: TaskID,
TaskType: types.CrossClusterTaskTypeCancelExecution.Ptr(),
TaskState: 3,
FailedCause: types.CrossClusterTaskFailedCauseDomainNotActive.Ptr(),
TaskID: TaskID,
TaskType: types.CrossClusterTaskTypeCancelExecution.Ptr(),
TaskState: 3,
FailedCause: types.CrossClusterTaskFailedCauseDomainNotActive.Ptr(),
CancelExecutionAttributes: &types.CrossClusterCancelExecutionResponseAttributes{},
}
CrossClusterTaskResponseSignalExecution = types.CrossClusterTaskResponse{
TaskID: TaskID,
TaskType: types.CrossClusterTaskTypeSignalExecution.Ptr(),
TaskState: 3,
FailedCause: types.CrossClusterTaskFailedCauseWorkflowNotExists.Ptr(),
TaskID: TaskID,
TaskType: types.CrossClusterTaskTypeSignalExecution.Ptr(),
TaskState: 3,
FailedCause: types.CrossClusterTaskFailedCauseWorkflowNotExists.Ptr(),
SignalExecutionAttributes: &types.CrossClusterSignalExecutionResponseAttributes{},
}
CrossClusterTaskResponseRecordChildExecutionComplete = types.CrossClusterTaskResponse{
TaskID: TaskID,
Expand Down
22 changes: 22 additions & 0 deletions common/types/testdata/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,28 @@ var (
FailoverMarkerAttributesArray = []*types.FailoverMarkerAttributes{
&FailoverMarkerAttributes,
}
PersistenceFeatures = []*types.PersistenceFeature{
{
Key: "PersistenceFeature",
Enabled: true,
},
nil,
}
PersistenceSettings = []*types.PersistenceSetting{
{
Key: "PersistenceKey",
Value: "PersistenceValue",
},
nil,
}
PersistenceInfoMap = map[string]*types.PersistenceInfo{
"Backend": {
Backend: "Backend",
Settings: PersistenceSettings,
Features: PersistenceFeatures,
},
"Invalid": nil,
}
GetDomainReplicationMessagesRequest = types.GetDomainReplicationMessagesRequest{
LastRetrievedMessageID: common.Int64Ptr(MessageID1),
LastProcessedMessageID: common.Int64Ptr(MessageID2),
Expand Down
Loading

0 comments on commit 5bbe89c

Please sign in to comment.