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

Conversation

lichunzhu
Copy link
Contributor

What problem does this PR solve?

#2868
Add UT part 1.

What is changed and how does it work?

Add unit tests for dm cluster CRD, discovery service, dm-master/dm-worker member manager.
Also fix some small bugs.

Check List

Tests

  • Unit test
  • E2E test
  • Stability test

Code changes

  • Has Go code change

Does this PR introduce a user-facing change?:

NONE

@lichunzhu lichunzhu added the status/PTAL PR needs to be reviewed label Sep 24, 2020
@codecov-commenter
Copy link

codecov-commenter commented Sep 24, 2020

Codecov Report

Merging #3310 into master will increase coverage by 6.51%.
The diff coverage is 83.78%.

@@            Coverage Diff             @@
##           master    #3310      +/-   ##
==========================================
+ Coverage   41.89%   48.41%   +6.51%     
==========================================
  Files         159      159              
  Lines       16690    16730      +40     
==========================================
+ Hits         6992     8099    +1107     
+ Misses       9045     7863    -1182     
- Partials      653      768     +115     
Flag Coverage Δ
#unittest 48.41% <83.78%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

@lichunzhu
Copy link
Contributor Author

/test pull-e2e-kind

@lichunzhu
Copy link
Contributor Author

/test pull-e2e-kind

@@ -539,7 +542,10 @@ func getNewMasterSetForDMCluster(dc *v1alpha1.DMCluster, cm *corev1.ConfigMap) (
dcName := dc.Name
baseMasterSpec := dc.BaseMasterSpec()
instanceName := dc.GetInstanceName()
masterConfigMap := cm.Name
masterConfigMap := ""
if cm != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if cm is nil here, should we return error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's unnecessary🤔

@@ -360,7 +360,10 @@ func getNewWorkerSetForDMCluster(dc *v1alpha1.DMCluster, cm *corev1.ConfigMap) (
dcName := dc.Name
baseWorkerSpec := dc.BaseWorkerSpec()
instanceName := dc.GetInstanceName()
workerConfigMap := cm.Name
workerConfigMap := ""
if cm != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@@ -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.

@DanielZhangQD
Copy link
Contributor

/test pull-e2e-kind

Copy link
Contributor

@DanielZhangQD DanielZhangQD left a comment

Choose a reason for hiding this comment

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

LGTM

@lichunzhu lichunzhu merged commit 506fb36 into pingcap:master Sep 27, 2020
@lichunzhu lichunzhu deleted the addUTForDMCluster branch September 27, 2020 12:19
cvvz pushed a commit to cvvz/tidb-operator that referenced this pull request Oct 18, 2020
…rker member manager (pingcap#3310)

* add UT for dmcluster configurations, dmapi and dm-master/dm-worker member manager
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/LGT2 status/PTAL PR needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants