-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #368 from alphagov/shw-add-disk-space-status-check
Add disk space check for healthcheck
- Loading branch information
Showing
3 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ | |
import flask_featureflags # noqa | ||
|
||
|
||
__version__ = '34.5.0' | ||
__version__ = '34.6.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from collections import namedtuple | ||
|
||
import mock | ||
import pytest | ||
|
||
from dmutils.status import get_disk_space_status | ||
|
||
|
||
def statvfs_fixture(total_blocks, free_blocks): | ||
statvfs = namedtuple('statvfs', 'f_blocks f_bfree') | ||
return statvfs(total_blocks, free_blocks) | ||
|
||
|
||
@mock.patch('dmutils.status.os.statvfs') | ||
@pytest.mark.parametrize('kwargs, total_blocks, free_blocks, expected_status', | ||
( | ||
({}, 1024, 0, ('OK', 100)), | ||
({}, 1024, 512, ('OK', 50)), | ||
({}, 1024, 920, ('OK', 10)), | ||
({}, 1024, 1000, ('LOW', 2)), | ||
({}, 1024, 1024, ('LOW', 0)), | ||
({'low_disk_percent_threshold': 10}, 1024, 950, ('LOW', 7)), | ||
({'low_disk_percent_threshold': 20}, 1024, 920, ('LOW', 10)), | ||
({'low_disk_percent_threshold': 75}, 1024, 512, ('LOW', 50)), | ||
)) | ||
def test_disk_space_status(disk_usage, kwargs, total_blocks, free_blocks, expected_status): | ||
disk_usage.return_value = statvfs_fixture(total_blocks, free_blocks) | ||
|
||
assert get_disk_space_status(**kwargs) == expected_status |