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

CP-48198: Fix running pytest on tests/integration in GitHub CI (with coverage) #105

Conversation

bernhardkaindl
Copy link
Collaborator

@bernhardkaindl bernhardkaindl commented Mar 29, 2024

This PR includes a number of fixes / improvements for the tests:

Improve tests so that tests/integration/*.py can contribute to covering xen-bugtool

  • .github/workflows/main.yml:
    • Fix running tests/integration in GitHub CI which use /opt/hostedtoolcache to provide Python.
    • Therefore, tests/integration needs to use /opt/xensource as mount point for the dom0 template files in /opt/xensource.
  • tests/integration/utils.py: Use runpy.run_path(bugtool_script, run_name="__main__") to get coverage if the script
  • tests/integration/conftest.py: Add mocks to sys.path so the mocks are found during runpy.run_path()
  • .coveragerc: Update to no longer limit coverage to tests/unit but also include tests/integration.

Support running tests independent of the starting directory

  • Fix places where os.getcwd() was used to get relative paths to be based on __file__.
  • Pass path names to functions wherever this is feasible

Other changes

Copy link

codecov bot commented Mar 29, 2024

Codecov Report

Merging #105 (ce8002f) into master (d0e569d) will increase coverage by 3%.
Report is 19 commits behind head on master.
The diff coverage is 100%.

Additional details and impacted files
@@          Coverage Diff           @@
##           master   #105    +/-   ##
======================================
+ Coverage      88%    91%    +3%     
======================================
  Files          18     19     +1     
  Lines        2196   2242    +46     
======================================
+ Hits         1939   2058   +119     
+ Misses        257    184    -73     
Files Coverage Δ
tests/conftest.py 100% <100%> (ø)
tests/integration/conftest.py 100% <100%> (ø)
tests/integration/test_system_load.py 100% <100%> (ø)
tests/integration/test_xenserver_config.py 100% <100%> (ø)
tests/integration/utils.py 87% <100%> (+2%) ⬆️
tests/unit/conftest.py 100% <ø> (ø)
tests/unit/test_main.py 100% <100%> (ø)
tests/unit/test_output.py 100% <100%> (ø)

... and 2 files with indirect coverage changes

Flag Coverage Δ
python2.7 96% <100%> (+10%) ⬆️
python3.10.13 ?
python3.10.14 91% <100%> (?)

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

@bernhardkaindl bernhardkaindl force-pushed the CP-48198/cover-integration-tests-cwd-independent branch 2 times, most recently from 225d58d to e63ac32 Compare March 29, 2024 04:18
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
@bernhardkaindl bernhardkaindl force-pushed the CP-48198/cover-integration-tests-cwd-independent branch from e63ac32 to 117d1d7 Compare March 29, 2024 04:43
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
@bernhardkaindl bernhardkaindl force-pushed the CP-48198/cover-integration-tests-cwd-independent branch from 92e0db9 to ce8002f Compare March 29, 2024 06:22
@coveralls
Copy link

Pull Request Test Coverage Report for Build 8477989884

Details

  • 44 of 44 (100.0%) changed or added relevant lines in 7 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+1.8%) to 92.254%

Totals Coverage Status
Change from base Build 8474976295: 1.8%
Covered Lines: 2132
Relevant Lines: 2311

💛 - Coveralls

@bernhardkaindl bernhardkaindl changed the title CP-48198: Cover integration tests by using runpy, tests independent of cwd CP-48198: Fix running pytest on tests/integration in GitHub CI (with coverage) Mar 29, 2024
@bernhardkaindl bernhardkaindl merged commit b50d199 into xenserver:master Apr 4, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants