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

Rewrite app/checks/disk-space to python, change the syntax #3

Merged
merged 4 commits into from
May 12, 2019
Merged

Conversation

p00rt
Copy link

@p00rt p00rt commented May 9, 2019

Rewrite of disk-space health check. Uses sys.statvfs (unix system call) now, also the syntax has changed from using env variables to using argv as a means to get dir and required space.

@codecov-io
Copy link

Codecov Report

Merging #3 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master      #3   +/-   ##
======================================
  Coverage    80.1%   80.1%           
======================================
  Files           8       8           
  Lines         196     196           
  Branches       22      22           
======================================
  Hits          157     157           
  Misses         35      35           
  Partials        4       4
Flag Coverage Δ
#python 80.1% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 76a9c65...3382409. Read the comment docs.

@codecov-io
Copy link

codecov-io commented May 9, 2019

Codecov Report

Merging #3 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master      #3   +/-   ##
======================================
  Coverage    80.1%   80.1%           
======================================
  Files           8       8           
  Lines         196     196           
  Branches       22      22           
======================================
  Hits          157     157           
  Misses         35      35           
  Partials        4       4
Flag Coverage Δ
#python 80.1% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 76a9c65...1bf5a6e. Read the comment docs.

@p00rt p00rt closed this May 9, 2019
@p00rt p00rt reopened this May 9, 2019
@blackandred
Copy link
Contributor

Thanks for the pull request. The test is failing because the mocking no longer works. You can rewrite the test also to Python if you would like to use Python unittest's mock.

@p00rt
Copy link
Author

p00rt commented May 10, 2019

i'm pretty sure that the test is broken since it wants to assert that 4GB is enough when 4.5GB is the defined minimum. This commit fixes it and also makes check/disk-space work properly with mock values.

if free_space >= req_space:
print("There is {0:.1f}{1} disk space at {2}, nothing to worry about, defined minimum is {3}{1}".format(free_space, unit, mntpoint, req_space))
return 0
else:
Copy link
Contributor

Choose a reason for hiding this comment

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

You do not need the else there. This practice is called early return.

if free_space >= req_space:
    print("There is {0:.1f}{1} disk space at {2}, nothing to worry about, defined minimum is {3}{1}".format(free_space, unit, mntpoint, req_space))
    return 0

print("Failed asserting that {0:.1f}{1} is at least {2}{1} at {3}".format(free_space, unit, req_space, mntpoint))
return 1

😉

@blackandred
Copy link
Contributor

Approved, one non-critical comment left. Can be merged, and the improvement can be applied with a next PR 😉

@blackandred blackandred merged commit 46cb9d2 into riotkit-org:master May 12, 2019
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.

3 participants