cloudstack icon indicating copy to clipboard operation
cloudstack copied to clipboard

Refactor TestHttp.testHttpclient to avoid the Exception Suppression

Open Codegass opened this issue 3 years ago • 4 comments

Description

FIX #6673

This PR removes the catch block with the e.printStackTrace(), which suppressed the Exceptions to be thrown in the CI\CD's final report.

These catch blocks will only print the the Exception information and will not raise any failure in the testing process. This behavior will lead the developer harder to notice the issue in the CI\CD reports.

I suggest removing the try-catch structure and adding some additional assertion(if possible). This will improve the readability of the test cases, and avoid missing the test failure. Even if the exception does not raise by the component that we are testing here, we can still know that we need to fix the outside conditions first to make sure the test case running under stable and consistent conditions.

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?

Local cluster environment (KVM, UBUNTU 18.04) runs the test suite.

Codegass avatar Sep 12 '22 18:09 Codegass

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

sonarqubecloud[bot] avatar Sep 12 '22 19:09 sonarqubecloud[bot]

@Codegass is this test actually run? as it is in a package called org.apache.cloudstack.storage.test; and in a project called engine/storage/integration-test I doubt that it is and a cleanup would require more action.

DaanHoogland avatar Sep 13 '22 07:09 DaanHoogland

Codecov Report

Merging #6733 (f1aff02) into main (68c09f9) will increase coverage by 0.00%. The diff coverage is n/a.

@@            Coverage Diff            @@
##               main    #6733   +/-   ##
=========================================
  Coverage     10.41%   10.41%           
- Complexity     6685     6686    +1     
=========================================
  Files          2454     2454           
  Lines        242975   242975           
  Branches      38036    38036           
=========================================
+ Hits          25305    25307    +2     
+ Misses       214508   214507    -1     
+ Partials       3162     3161    -1     
Impacted Files Coverage Δ
...apache/cloudstack/alert/snmp/SnmpTrapAppender.java 58.94% <0.00%> (-2.11%) :arrow_down:
...apache/cloudstack/syslog/AlertsSyslogAppender.java 58.75% <0.00%> (+2.25%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov[bot] avatar Sep 13 '22 08:09 codecov[bot]

@Codegass is this test actually run? as it is in a package called org.apache.cloudstack.storage.test; and in a project called engine/storage/integration-test I doubt that it is and a cleanup would require more action.

@DaanHoogland Hi Daan, Thank you for the notice. You are correct, I just run the overall test suite and missed the single test of itself. Please allow me to dig a little bit.

Codegass avatar Sep 13 '22 12:09 Codegass

@blueorangutan package

rohityadavcloud avatar Oct 08 '22 06:10 rohityadavcloud

@rohityadavcloud a Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Oct 08 '22 06:10 blueorangutan

On second look, the changes are in (unit) test code and Travis has passed.

rohityadavcloud avatar Oct 08 '22 06:10 rohityadavcloud

Awesome work, congrats on your first merged pull request!

boring-cyborg[bot] avatar Oct 09 '22 09:10 boring-cyborg[bot]