Skip to content

Commit 6ad4364

Browse files
committed
Unit tests + status
1 parent 06b2b9c commit 6ad4364

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed

pkg/apis/deployment/v1/deployment_status.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ type DeploymentStatus struct {
103103
Coordinators *ServerGroupStatus `json:"coordinators,omitempty"`
104104
SyncMasters *ServerGroupStatus `json:"syncmasters,omitempty"`
105105
SyncWorkers *ServerGroupStatus `json:"syncworkers,omitempty"`
106+
Gateways *ServerGroupStatus `json:"gateways,omitempty"`
106107
}
107108

108109
// Equal checks for equality
@@ -174,6 +175,8 @@ func (ds DeploymentStatus) getServerGroupStatus(group ServerGroup) *ServerGroupS
174175
return ds.SyncMasters.DeepCopy()
175176
case ServerGroupSyncWorkers:
176177
return ds.SyncWorkers.DeepCopy()
178+
case ServerGroupGateways:
179+
return ds.Gateways.DeepCopy()
177180
default:
178181
return nil
179182
}
@@ -195,5 +198,7 @@ func (ds *DeploymentStatus) UpdateServerGroupStatus(group ServerGroup, gspec Ser
195198
ds.SyncMasters = &gspec
196199
case ServerGroupSyncWorkers:
197200
ds.SyncWorkers = &gspec
201+
case ServerGroupGateways:
202+
ds.Gateways = &gspec
198203
}
199204
}

pkg/apis/deployment/v1/deployment_status_members_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func newMemberList() DeploymentStatusMembers {
3434
Coordinators: MemberStatusList{{ID: ServerGroupCoordinators.AsRole()}},
3535
SyncMasters: MemberStatusList{{ID: ServerGroupSyncMasters.AsRole()}},
3636
SyncWorkers: MemberStatusList{{ID: ServerGroupSyncWorkers.AsRole()}},
37+
Gateways: MemberStatusList{{ID: ServerGroupGateways.AsRole()}},
3738
}
3839
}
3940

pkg/apis/deployment/v1/server_group_spec_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func TestServerGroupSpecValidateCount(t *testing.T) {
4646
assert.Nil(t, ServerGroupSpec{Count: util.NewType[int](2)}.New().WithGroup(ServerGroupCoordinators).New().Validate(ServerGroupCoordinators, true, DeploymentModeCluster, EnvironmentProduction))
4747
assert.Nil(t, ServerGroupSpec{Count: util.NewType[int](2)}.New().WithGroup(ServerGroupSyncMasters).New().Validate(ServerGroupSyncMasters, true, DeploymentModeCluster, EnvironmentProduction))
4848
assert.Nil(t, ServerGroupSpec{Count: util.NewType[int](2)}.New().WithGroup(ServerGroupSyncWorkers).New().Validate(ServerGroupSyncWorkers, true, DeploymentModeCluster, EnvironmentProduction))
49+
assert.Nil(t, ServerGroupSpec{Count: util.NewType[int](2)}.New().WithGroup(ServerGroupGateways).New().Validate(ServerGroupGateways, true, DeploymentModeCluster, EnvironmentProduction))
4950

5051
assert.Nil(t, ServerGroupSpec{Count: util.NewType[int](2), MinCount: util.NewType[int](2), MaxCount: util.NewType[int](5)}.New().WithGroup(ServerGroupCoordinators).New().Validate(ServerGroupCoordinators, true, DeploymentModeCluster, EnvironmentDevelopment))
5152
assert.Nil(t, ServerGroupSpec{Count: util.NewType[int](1), MaxCount: util.NewType[int](5)}.New().WithGroup(ServerGroupCoordinators).New().Validate(ServerGroupCoordinators, true, DeploymentModeCluster, EnvironmentDevelopment))
@@ -112,6 +113,10 @@ func TestServerGroupSpecDefault(t *testing.T) {
112113
assert.Equal(t, 0, def(ServerGroupSpec{}, ServerGroupSyncWorkers, false, DeploymentModeActiveFailover).New().GetCount())
113114
assert.Equal(t, 3, def(ServerGroupSpec{}, ServerGroupSyncWorkers, true, DeploymentModeCluster).New().GetCount())
114115

116+
assert.Equal(t, 0, def(ServerGroupSpec{}, ServerGroupGateways, false, DeploymentModeSingle).New().GetCount())
117+
assert.Equal(t, 0, def(ServerGroupSpec{}, ServerGroupGateways, false, DeploymentModeActiveFailover).New().GetCount())
118+
assert.Equal(t, 3, def(ServerGroupSpec{}, ServerGroupGateways, true, DeploymentModeCluster).New().GetCount())
119+
115120
for _, g := range AllServerGroups {
116121
assert.Equal(t, 0, len(def(ServerGroupSpec{}, g, true, DeploymentModeSingle).Args))
117122
assert.Equal(t, "", def(ServerGroupSpec{}, g, true, DeploymentModeSingle).New().GetStorageClassName())

pkg/apis/deployment/v1/server_group_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func TestServerGroupAsRole(t *testing.T) {
3333
assert.Equal(t, "coordinator", ServerGroupCoordinators.AsRole())
3434
assert.Equal(t, "syncmaster", ServerGroupSyncMasters.AsRole())
3535
assert.Equal(t, "syncworker", ServerGroupSyncWorkers.AsRole())
36+
assert.Equal(t, "gateways", ServerGroupGateways.AsRole())
3637
}
3738

3839
func TestServerGroupAsRoleAbbreviated(t *testing.T) {
@@ -42,6 +43,7 @@ func TestServerGroupAsRoleAbbreviated(t *testing.T) {
4243
assert.Equal(t, "crdn", ServerGroupCoordinators.AsRoleAbbreviated())
4344
assert.Equal(t, "syma", ServerGroupSyncMasters.AsRoleAbbreviated())
4445
assert.Equal(t, "sywo", ServerGroupSyncWorkers.AsRoleAbbreviated())
46+
assert.Equal(t, "gway", ServerGroupGateways.AsRoleAbbreviated())
4547
}
4648

4749
func TestServerGroupIsArangod(t *testing.T) {
@@ -51,6 +53,7 @@ func TestServerGroupIsArangod(t *testing.T) {
5153
assert.True(t, ServerGroupCoordinators.IsArangod())
5254
assert.False(t, ServerGroupSyncMasters.IsArangod())
5355
assert.False(t, ServerGroupSyncWorkers.IsArangod())
56+
assert.False(t, ServerGroupGateways.IsArangod())
5457
}
5558

5659
func TestServerGroupIsArangosync(t *testing.T) {
@@ -60,6 +63,7 @@ func TestServerGroupIsArangosync(t *testing.T) {
6063
assert.False(t, ServerGroupCoordinators.IsArangosync())
6164
assert.True(t, ServerGroupSyncMasters.IsArangosync())
6265
assert.True(t, ServerGroupSyncWorkers.IsArangosync())
66+
assert.False(t, ServerGroupGateways.IsArangosync())
6367
}
6468

6569
func TestServerGroupType(t *testing.T) {

pkg/deployment/reconcile/plan_builder_rotate_upgrade.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ var (
4949
api.ServerGroupDBServers,
5050
api.ServerGroupSyncMasters,
5151
api.ServerGroupSyncWorkers,
52+
api.ServerGroupGateways,
5253
}
5354
)
5455

0 commit comments

Comments
 (0)