Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit tests for dm cluster CRD, discovery service, dm-master/dm-worker member manager #3310

Merged
merged 11 commits into from
Sep 27, 2020
6 changes: 3 additions & 3 deletions pkg/manager/member/dm_master_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,10 +542,10 @@ func getNewMasterSetForDMCluster(dc *v1alpha1.DMCluster, cm *corev1.ConfigMap) (
dcName := dc.Name
baseMasterSpec := dc.BaseMasterSpec()
instanceName := dc.GetInstanceName()
masterConfigMap := ""
if cm != nil {
masterConfigMap = cm.Name
if cm == nil {
return nil, fmt.Errorf("config map for dm-master is not found, dmcluster %s/%s", dc.Namespace, dc.Name)
}
masterConfigMap := cm.Name

annMount, annVolume := annotationsMountVolume()
volMounts := []corev1.VolumeMount{
Expand Down
2 changes: 1 addition & 1 deletion pkg/manager/member/dm_master_member_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ func TestGetNewMasterSetForDMCluster(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
sts, err := getNewMasterSetForDMCluster(&tt.dc, nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a case to cover the nil cm case.

sts, err := getNewMasterSetForDMCluster(&tt.dc, &corev1.ConfigMap{})
if (err != nil) != tt.wantErr {
t.Fatalf("error %v, wantErr %v", err, tt.wantErr)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/manager/member/dm_worker_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,10 @@ func getNewWorkerSetForDMCluster(dc *v1alpha1.DMCluster, cm *corev1.ConfigMap) (
dcName := dc.Name
baseWorkerSpec := dc.BaseWorkerSpec()
instanceName := dc.GetInstanceName()
workerConfigMap := ""
if cm != nil {
workerConfigMap = cm.Name
if cm == nil {
return nil, fmt.Errorf("config map for dm-worker is not found, dmcluster %s/%s", dc.Namespace, dc.Name)
}
workerConfigMap := cm.Name

annMount, annVolume := annotationsMountVolume()
volMounts := []corev1.VolumeMount{
Expand Down
2 changes: 1 addition & 1 deletion pkg/manager/member/dm_worker_member_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ func TestGetNewWorkerSetForDMCluster(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
sts, err := getNewWorkerSetForDMCluster(&tt.dc, nil)
sts, err := getNewWorkerSetForDMCluster(&tt.dc, &corev1.ConfigMap{})
if (err != nil) != tt.wantErr {
t.Fatalf("error %v, wantErr %v", err, tt.wantErr)
}
Expand Down