From 255dbf79a9c987d354c5d27ea6af88dacfa54427 Mon Sep 17 00:00:00 2001 From: Sahina Bose Date: Mon, 5 May 2014 17:32:05 +0530 Subject: plugins: Enhanced volume quota status plugin Quota status plugin enhanced to return soft-limit as well as hard-limit exceeded messages along with the directories that it's exceeded on. Change-Id: I77a8686e2742e2174c9f5ebdade8f017a1ffad4e Signed-off-by: Sahina Bose Reviewed-on: http://review.gluster.org/7672 Reviewed-by: Kanagaraj M --- tests/test_check_volume_status.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/test_check_volume_status.py b/tests/test_check_volume_status.py index 4d4f940..ad43587 100644 --- a/tests/test_check_volume_status.py +++ b/tests/test_check_volume_status.py @@ -56,12 +56,18 @@ class TestCheckVolumeStatus(TestCaseBase): @mock.patch('glusternagios.glustercli.volumeQuotaStatus') def test_checkVolumeQuotaStatus(self, mock_volumeQuotaStatus): - mock_volumeQuotaStatus.return_value = glustercli.\ - VolumeQuotaStatus.EXCEEDED args = ArgParseMock('test-cluster', 'test-vol', 'quota') + mock_volumeQuotaStatus.return_value = _getQuotaStatusHardLimit() exitStatusCode, exitStatusMsg = (check_volume_status .getVolumeQuotaStatus(args)) - assert exitStatusCode == utils.PluginStatusCode.WARNING + assert exitStatusCode == utils.PluginStatusCode.CRITICAL + self.assertEqual("QUOTA:hard limit exceeded on dir1, dir2; " + "soft limit exceeded on dir3", exitStatusMsg) + mock_volumeQuotaStatus.return_value = _getQuotaStatusOk() + exitStatusCode, exitStatusMsg = (check_volume_status + .getVolumeQuotaStatus(args)) + assert exitStatusCode == utils.PluginStatusCode.OK + self.assertEqual("QUOTA: OK", exitStatusMsg) @mock.patch('glusternagios.glustercli.volumeGeoRepStatus') def test_checkVolumeGeoRepStatus(self, mock_GeoRepStatus): @@ -103,6 +109,18 @@ def _getEmptyVolume(): return {} +def _getQuotaStatusHardLimit(): + return {'status': 'HARD_LIMIT_EXCEEDED', + 'hard_ex_dirs': ['dir1', 'dir2'], + 'soft_ex_dirs': ['dir3']} + + +def _getQuotaStatusOk(): + return {'status': 'OK', + 'hard_ex_dirs': [], + 'soft_ex_dirs': []} + + def _getGeoRepStatus(status): return {'test-vol': {'status': status, 'detail': "rhs3-2.novalocal - faulty;"}} -- cgit