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

🔨 disk-usage pytest plugin #6196

Merged
merged 8 commits into from
Aug 16, 2024

Conversation

pcrespov
Copy link
Member

@pcrespov pcrespov commented Aug 15, 2024

What do these changes do?

After running out of space in the gh-action machines the CI stops with messages as

       XMinioStorageFull: Storage backend has reached its minimum free drive threshold. Please delete a few objects to proceed.

This PR implements an optional plugin to monitor disk usage during test execution, identifying tests that do not properly clean up resources. This helps prevent potential issues when running continuous integration (CI) pipelines on external systems, such as GitHub Actions.

The plugin is activated by using the --disk-usage option, and it can be configured with a custom threshold using the --disk-usage-threshold option.

Warnings are generated if disk usage increases beyond the specified threshold, allowing for targeted investigation of resource management in specific tests, modules, or the entire test session.

Currently, ONLY activated in integration tests for

Related issue/s

  • @sanderegg, @matusdrobuliak66 and me agreed that it would be good to have some fixtures to assist finding which tests are not cleaning up artifacts behind them.

How to test

  • In simcore-sdk/tests add test_foo.py
import random

def test_it():
    with open(f"/tmp/test_{random.random()}_file.txt", "wb") as f:
        f.write(b"\0" * 1024 * 1024)
  • then pytest --disk-usage --disk-usage-threshold=1 --log-cli-level=WARNING tests/unit/test_foo.py
    image

Example

in this CI failure

image

@pcrespov pcrespov changed the title Mai/pytest disk usage 🔨 disk-usage pytest plugin Aug 15, 2024
@pcrespov pcrespov self-assigned this Aug 15, 2024
@pcrespov pcrespov added the t:maintenance Some planned maintenance work label Aug 15, 2024
@pcrespov pcrespov added this to the Eisbock milestone Aug 15, 2024
Copy link

codecov bot commented Aug 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.1%. Comparing base (cafbf96) to head (d4cc986).
Report is 442 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #6196      +/-   ##
=========================================
+ Coverage    84.5%   88.1%    +3.5%     
=========================================
  Files          10    1463    +1453     
  Lines         214   60731   +60517     
  Branches       25    1484    +1459     
=========================================
+ Hits          181   53547   +53366     
- Misses         23    6871    +6848     
- Partials       10     313     +303     
Flag Coverage Δ
integrationtests 64.8% <ø> (?)
unittests 86.1% <ø> (+1.5%) ⬆️

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

see 1418 files with indirect coverage changes

@pcrespov pcrespov marked this pull request as ready for review August 15, 2024 17:57
@pcrespov pcrespov requested a review from sanderegg as a code owner August 15, 2024 17:57
@pcrespov
Copy link
Member Author

pcrespov commented Aug 15, 2024

I think the culprit is here https://github.com/ITISFoundation/osparc-simcore/actions/runs/10408869816/job/28827529734?pr=6196#step:13:241

This test-suite (i.e. test_node_data_manager) seems to accumulate a lot of data after the test
image

Check all the modules and tests in the CI log starting with WARNING Disk usage increased

Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

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

very nice addition! thanks!

Copy link

@pcrespov pcrespov enabled auto-merge (squash) August 16, 2024 14:31
@pcrespov pcrespov disabled auto-merge August 16, 2024 15:00
@pcrespov pcrespov merged commit 423efb3 into ITISFoundation:master Aug 16, 2024
57 checks passed
@pcrespov pcrespov deleted the mai/pytest-disk-usage branch August 16, 2024 15:01
giancarloromeo pushed a commit to giancarloromeo/osparc-simcore that referenced this pull request Aug 19, 2024
@matusdrobuliak66 matusdrobuliak66 mentioned this pull request Aug 21, 2024
67 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t:maintenance Some planned maintenance work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants