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

CI: Improve unit tests to test the bugtool's main() as well #44

Merged

Conversation

bernhardkaindl
Copy link
Collaborator

This PR raises the code coverage from of the bugtool script itself
from 50% to 84% by running almost all of bugtool from a single test
module by testing the bugtool's main() function.

This allows for full testing of nearly any other fixes and changes:

Add tests/unit/test_main.py which also uses test functions which were
added for earlier tests to test the main function of bugtool to produce
the bugtool output archives for all types: zip, tar, and tar.bz2.

The main test checks the output of the bugtool application to ensure that
it matches the expected output. It compares the captured output with the
expected output and performs various assertions to validate the output.

It extracts the output files from the archive and checks that the xAPI db
and the inventory.xml.

Tested output:

  • The start and end of the collected bugtool messages from captured.out
  • The inventory.xml file is checked to be validated using its XML schema.
  • The xapi-db.xml is checked to have secrets filtered using a dummy xapi db

@bernhardkaindl bernhardkaindl force-pushed the initial_tests_for_bugtool_main branch 3 times, most recently from 0fcba23 to 4aab454 Compare January 11, 2024 12:19
@codecov-commenter
Copy link

codecov-commenter commented Jan 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (1aae840) 56.52% compared to head (0783b2f) 84.90%.
Report is 2 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master      #44       +/-   ##
===========================================
+ Coverage   56.52%   84.90%   +28.37%     
===========================================
  Files           8       15        +7     
  Lines        1647     1928      +281     
===========================================
+ Hits          931     1637      +706     
+ Misses        716      291      -425     
Flag Coverage Δ
python2.7 83.40% <93.79%> (?)
python3.10.13 83.74% <100.00%> (?)
unittest 83.74% <100.00%> (+27.21%) ⬆️

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

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

@bernhardkaindl bernhardkaindl force-pushed the initial_tests_for_bugtool_main branch 3 times, most recently from 8339b98 to 6fd8091 Compare January 11, 2024 15:27
psafont
psafont previously approved these changes Jan 11, 2024
Copy link
Member

@psafont psafont left a comment

Choose a reason for hiding this comment

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

While there's quite a bit of code being introduced, it's just in the tests and not on the deployed code.

This, along with the coverage report that ensure the new code is run, makes the PR low-risk

@bernhardkaindl
Copy link
Collaborator Author

bernhardkaindl commented Jan 11, 2024

@psafont Thank you for your review and approval!

While there's quite a bit of code being introduced, it's just in the tests and not on the deployed code.

This, along with the coverage report that ensure the new code is run, makes the PR low-risk

Exactly, fully agreed!

I just pushed the final minor fixes of the GitHub Workflow file .github/workflows/main.yml!

Could you review the changes? They are:

  • For the pytest-coverage-comment steps:

    • Ignore errors on missing permissions to make the coverage comment.
    • This can happen when PRs are opened in private repos (we need to update the GH perms for the repo)
  • For the Codecov coverage upload steps:

    • Update the tag for the Python3 version to be format("python%s", python-version) not just unittest.

psafont
psafont previously approved these changes Jan 11, 2024
Add tests/unit/test_main.py which also uses test functions which were
added for earlier tests to test the main function of bugtool to produce
the bugtool output archives for all types: zip, tar, and tar.bz2.

The main test checks the output of the bugtool application to ensure that
it matches the expected output. It compares the captured output with the
expected output and performs various assertions to validate the output.

It extracts the output files from the archive and checks that the xAPI db
and the inventory.xml.

Tested output:
- The start and end of the collected bugtool messages from captured.out
- The inventory.xml file is checked to be validated using its XML schema.
- The xapi-db.xml is checked to have secrets filtered using a dummy xapi db

Signed-off-by: Bernhard Kaindl <[email protected]>
@bernhardkaindl bernhardkaindl merged commit 5f8bafd into xenserver:master Jan 12, 2024
3 checks passed
@bernhardkaindl bernhardkaindl deleted the initial_tests_for_bugtool_main branch January 15, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants