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:24:23 UTC

[GitHub] [cloudstack] Codegass opened a new pull request, #6882: Simplify Test Case ApplicationLoadBalancerTest.searchForNonExistingLoadBalancer

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

   ### Description
   
   Fix: #6660 
   
   This PR Simplify the test case [`ApplicationLoadBalancerTest.searchForNonExistingLoadBalancer`](https://github.com/apache/cloudstack/blob/ddb11b1b966cc2b3443ef4d2eeb55c1d64ff3fb9/server/src/test/java/org/apache/cloudstack/network/lb/ApplicationLoadBalancerTest.java#L189-L205) and try to imporve its readability.
   
   The test case checks that when retrieving a non-existing lb, an InvalidParameterValueException should be raised. However, the intention is not explicit in the current implementation of the test case. See below the current implementation:
   
   **Before Refactoring**
   ```java
           try {
               rule = _appLbSvc.getApplicationLoadBalancer(nonExistingLbId);
               if (rule != null) {
                   notFound = false;
               }
           } catch (InvalidParameterValueException ex) {
               notFound = true;
           }
   
           assertTrue("Found non-existing load balancer; no invalid parameter value exception was thrown", notFound);
   ```
   The test case relies on a parameter named notFound, being asserted in line [204](https://github.com/apache/cloudstack/blob/ddb11b1b966cc2b3443ef4d2eeb55c1d64ff3fb9/server/src/test/java/org/apache/cloudstack/network/lb/ApplicationLoadBalancerTest.java#L204), and a try-catch block with if condition between lines [195 to 204](https://github.com/apache/cloudstack/blob/ddb11b1b966cc2b3443ef4d2eeb55c1d64ff3fb9/server/src/test/java/org/apache/cloudstack/network/lb/ApplicationLoadBalancerTest.java#L195-#L204) to achieve the testing goal. It can be simplified to 4 lines with a more explicit intention for easy understanding, as follows:
   
   **After refactoring**
   ```java
   @Test(expected=InvalidParameterValueException.class)
    //Negative test - try to retrieve non-existing lb
   public void searchForNonExistingLoadBalancer() {
      _appLbSvc.getApplicationLoadBalancer(nonExistingLbId));
     }
   ```
   For more description details, please refer to the issue #6660.
   <!--- 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)
   - [ ] Enhancement (improves an existing feature and functionality)
   - [x] 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] DaanHoogland merged pull request #6882: Simplify Test Case ApplicationLoadBalancerTest.searchForNonExistingLoadBalancer

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


-- 
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 #6882: Simplify Test Case ApplicationLoadBalancerTest.searchForNonExistingLoadBalancer

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

   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=6882)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6882&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=6882&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6882&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=6882&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=6882&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6882&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=6882&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=6882&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=6882&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=6882&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=6882&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6882&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=6882&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=6882&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6882&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] codecov[bot] commented on pull request #6882: Simplify Test Case ApplicationLoadBalancerTest.searchForNonExistingLoadBalancer

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

   # [Codecov](https://codecov.io/gh/apache/cloudstack/pull/6882?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 [#6882](https://codecov.io/gh/apache/cloudstack/pull/6882?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (c017b8a) 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 **decrease** coverage by `0.00%`.
   > The diff coverage is `n/a`.
   
   ```diff
   @@             Coverage Diff              @@
   ##               main    #6882      +/-   ##
   ============================================
   - Coverage     10.84%   10.84%   -0.01%     
   + Complexity     7105     7103       -2     
   ============================================
     Files          2485     2485              
     Lines        245417   245417              
     Branches      38326    38326              
   ============================================
   - Hits          26622    26618       -4     
   - Misses       215526   215530       +4     
     Partials       3269     3269              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/cloudstack/pull/6882?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...dstack/network/contrail/model/ModelObjectBase.java](https://codecov.io/gh/apache/cloudstack/pull/6882/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==) | `21.15% <0.00%> (-7.70%)` | :arrow_down: |
   | [...om/cloud/hypervisor/kvm/resource/LibvirtVMDef.java](https://codecov.io/gh/apache/cloudstack/pull/6882/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-cGx1Z2lucy9oeXBlcnZpc29ycy9rdm0vc3JjL21haW4vamF2YS9jb20vY2xvdWQvaHlwZXJ2aXNvci9rdm0vcmVzb3VyY2UvTGlidmlydFZNRGVmLmphdmE=) | `67.04% <0.00%> (ø)` | |
   
   :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