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

[Improvement] Add deregister Test on Master moudle #16142

Closed
wants to merge 1 commit into from
Closed

[Improvement] Add deregister Test on Master moudle #16142

wants to merge 1 commit into from

Conversation

caicancai
Copy link
Member

@caicancai caicancai commented Jun 12, 2024

Purpose of the pull request

Add deregistryTest on Master moudle

Brief change log

Verify this pull request

This pull request is code cleanup without any test coverage.

(or)

This pull request is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(or)

If your pull request contain incompatible change, you should also add it to docs/docs/en/guide/upgrede/incompatible.md

@caicancai caicancai changed the title [Improvement] Add deregistryTest on Master moudle [Improvement] Add deregister Test on Master moudle Jun 12, 2024
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 40.71%. Comparing base (a13eacd) to head (f7e9849).

Current head f7e9849 differs from pull request most recent head ac3875b

Please upload reports for the commit ac3875b to get more accurate results.

Additional details and impacted files
@@             Coverage Diff              @@
##                dev   #16142      +/-   ##
============================================
- Coverage     40.73%   40.71%   -0.02%     
+ Complexity     5250     5246       -4     
============================================
  Files          1385     1385              
  Lines         46109    46076      -33     
  Branches       4923     4899      -24     
============================================
- Hits          18781    18759      -22     
+ Misses        25401    25389      -12     
- Partials       1927     1928       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

sonarcloud bot commented Jun 12, 2024

Quality Gate Passed Quality Gate passed

Issues
2 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Member

@EricGao888 EricGao888 left a comment

Choose a reason for hiding this comment

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

public void deregister() {
try {
registryClient.remove(masterConfig.getMasterRegistryPath());
log.info("Master node : {} unRegistry to register center.", masterConfig.getMasterAddress());
if (masterHeartBeatTask != null) {
masterHeartBeatTask.shutdown();
}
registryClient.close();
} catch (Exception e) {
log.error("MasterServer remove registry path exception ", e);
}
}

IMHO at least you need to verify the behavior of injected registryClient mock after calling masterRegistryClient.deregister(). To make things fully covered, you may also test the exception handling block, which is no necessary in this case though. Simply calling masterRegistryClient.deregister() is not a meaningful test case.

@caicancai
Copy link
Member Author

public void deregister() {
try {
registryClient.remove(masterConfig.getMasterRegistryPath());
log.info("Master node : {} unRegistry to register center.", masterConfig.getMasterAddress());
if (masterHeartBeatTask != null) {
masterHeartBeatTask.shutdown();
}
registryClient.close();
} catch (Exception e) {
log.error("MasterServer remove registry path exception ", e);
}
}

IMHO at least you need to verify the behavior of injected registryClient mock after calling masterRegistryClient.deregister(). To make things fully covered, you may also test the exception handling block, which is no necessary in this case though. Simply calling masterRegistryClient.deregister() is not a meaningful test case.

Thanks, I will close this pr and see if there is any way to improve it later

@caicancai caicancai closed this Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants