You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2022/11/09 05:57:21 UTC

[GitHub] [cloudstack] Codegass opened a new pull request, #6883: Bring in the JUnit Assume Feature to `CABackgroundTaskTest`

Codegass opened a new pull request, #6883:
URL: https://github.com/apache/cloudstack/pull/6883

   ### Description
   
   Fix: #6203 
   
   This PR introduces JUnit Assume API to the five test cases of `CABackgroundTaskTest`:
   [`testNullCert`](https://github.com/apache/cloudstack/blob/4c5a2ba3a6eb6399390c2f8963cb26e0e35fc058/server/src/test/java/org/apache/cloudstack/ca/CABackgroundTaskTest.java#L94-L99), [`testNullHost`](https://github.com/apache/cloudstack/blob/4c5a2ba3a6eb6399390c2f8963cb26e0e35fc058/server/src/test/java/org/apache/cloudstack/ca/CABackgroundTaskTest.java#L102-L108), [`testAutoRenewalEnabledWithExceptionsOnProvisioning`](https://github.com/apache/cloudstack/blob/main/server/src/test/java/org/apache/cloudstack/ca/CABackgroundTaskTest.java#L122), [`testAutoRenewalEnabledWithNoExceptionsOnProvisioning`](https://github.com/apache/cloudstack/blob/main/server/src/test/java/org/apache/cloudstack/ca/CABackgroundTaskTest.java#L111) , and [`testAutoRenewalDisabled`](https://github.com/apache/cloudstack/blob/main/server/src/test/java/org/apache/cloudstack/ca/CABackgroundTaskTest.java#L134).
   
   Take [`testAutoRenewalDisabled`](https://github.com/apache/cloudstack/blob/main/server/src/test/java/org/apache/cloudstack/ca/CABackgroundTaskTest.java#L134) as a example:
   
   Right now this case is asserting `certMap.size() == 1` before the actual testing target(`task.runInContext()`) is executed. 
   
   ```java
   certMap.put(hostIp, expiredCertificate);
   Assert.assertTrue(certMap.size() == 1);
   ```
   Since the test case `testAutoRenewalDisabled` contains 2 assertions, it may fail due to 2 reasons:
   
     * The functions related to the `certMap` have bugs.(Here is the `Assert.assertTrue(certMap.size() == 1)`)
     * The function `task.runInContext()` have bugs.(What we actually want to check with this test)
   
   Here I suggest replacing the `assertTrue` function with the `assumeThat` function, so when the precondition fails, JUnit can skip it instead of report a failurel.  This can help us to focus on failure that is raised by the target testing function.
   
   
   **Before refactoring**
   ```java
   certMap.put(hostIp, expiredCertificate);
   Assert.assertTrue(certMap.size() == 1);
   ```
   
   **After refactoring**
   ```java
   certMap.put(hostIp, expiredCertificate);
   Assume.assumeThat(icertMap.size() == 1, is(true));
   ```
   
   #### Brief changelog
   Replace `Assert.assertTrue(certMap.size() == 1);` with `Assume.assumeThat(icertMap.size() == 1, is(true));` for better code comprehension.
   <!--- Describe your changes in DETAIL - And how has behaviour functionally changed. -->
   
   <!-- For new features, provide link to FS, dev ML discussion etc. -->
   <!-- In case of bug fix, the expected and actual behaviours, steps to reproduce. -->
   
   <!-- When "Fixes: #<id>" is specified, the issue/PR will automatically be closed when this PR gets merged -->
   <!-- For addressing multiple issues/PRs, use multiple "Fixes: #<id>" -->
   <!-- Fixes: # -->
   
   <!--- ********************************************************************************* -->
   <!--- NOTE: AUTOMATATION USES THE DESCRIPTIONS TO SET LABELS AND PRODUCE DOCUMENTATION. -->
   <!--- PLEASE PUT AN 'X' in only **ONE** box -->
   <!--- ********************************************************************************* -->
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [ ] Bug fix (non-breaking change which fixes an issue)
   - [X] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   
   - [ ] Major
   - [X] Minor
   
   
   ### How Has This Been Tested?
   <!-- Please describe in detail how you tested your changes. -->
   <!-- Include details of your testing environment, and the tests you ran to -->
   <!-- see how your change affects other areas of the code, etc. -->
   The local cluster environment (KVM, UBUNTU 18.04) runs the test suite.
   
   <!-- Please read the [CONTRIBUTING](https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md) document -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] codecov[bot] commented on pull request #6883: Bring in the JUnit Assume Feature to `CABackgroundTaskTest`

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #6883:
URL: https://github.com/apache/cloudstack/pull/6883#issuecomment-1308286280

   # [Codecov](https://codecov.io/gh/apache/cloudstack/pull/6883?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#6883](https://codecov.io/gh/apache/cloudstack/pull/6883?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (585ef43) into [main](https://codecov.io/gh/apache/cloudstack/commit/4c5a2ba3a6eb6399390c2f8963cb26e0e35fc058?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (4c5a2ba) will **increase** coverage by `0.00%`.
   > The diff coverage is `n/a`.
   
   ```diff
   @@            Coverage Diff            @@
   ##               main    #6883   +/-   ##
   =========================================
     Coverage     10.84%   10.85%           
   - Complexity     7105     7108    +3     
   =========================================
     Files          2485     2485           
     Lines        245417   245417           
     Branches      38326    38326           
   =========================================
   + Hits          26622    26633   +11     
   + Misses       215526   215514   -12     
   - Partials       3269     3270    +1     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/cloudstack/pull/6883?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...cloudstack/network/contrail/model/ModelObject.java](https://codecov.io/gh/apache/cloudstack/pull/6883/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGx1Z2lucy9uZXR3b3JrLWVsZW1lbnRzL2p1bmlwZXItY29udHJhaWwvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2Nsb3Vkc3RhY2svbmV0d29yay9jb250cmFpbC9tb2RlbC9Nb2RlbE9iamVjdC5qYXZh) | `33.33% <0.00%> (+4.16%)` | :arrow_up: |
   | [...dstack/network/contrail/model/ModelObjectBase.java](https://codecov.io/gh/apache/cloudstack/pull/6883/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGx1Z2lucy9uZXR3b3JrLWVsZW1lbnRzL2p1bmlwZXItY29udHJhaWwvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2Nsb3Vkc3RhY2svbmV0d29yay9jb250cmFpbC9tb2RlbC9Nb2RlbE9iamVjdEJhc2UuamF2YQ==) | `48.07% <0.00%> (+19.23%)` | :arrow_up: |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] sonarcloud[bot] commented on pull request #6883: Bring in the JUnit Assume Feature to `CABackgroundTaskTest`

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #6883:
URL: https://github.com/apache/cloudstack/pull/6883#issuecomment-1308295852

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_cloudstack&pullRequest=6883)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6883&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6883&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6883&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6883&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6883&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6883&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=6883&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=6883&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=6883&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6883&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6883&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6883&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6883&metric=coverage&view=list) No Coverage information  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6883&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6883&metric=new_duplicated_lines_density&view=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] DaanHoogland merged pull request #6883: Bring in the JUnit Assume Feature to `CABackgroundTaskTest`

Posted by GitBox <gi...@apache.org>.
DaanHoogland merged PR #6883:
URL: https://github.com/apache/cloudstack/pull/6883


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org