From 86a404d7ce805a25762cd66c310b1ad9e3a2a779 Mon Sep 17 00:00:00 2001 From: Sahina Bose Date: Thu, 10 Apr 2014 15:48:32 +0530 Subject: plugins: Enhanced volume status with quota status Added an optional parameter to query quota status Added command to nrpe.cfg Change-Id: I9f60ed1a98cb2ca59b799cf9c09e3621b7bd8c0c Signed-off-by: Sahina Bose --- tests/Makefile.am | 1 + tests/test_check_volume_status.py | 35 ++++++++++++++++++++++------------- 2 files changed, 23 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 5f82370..e8ab026 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -19,6 +19,7 @@ # test_modules = \ + test_check_volume_status.py \ test_cpu.py \ test_cpu_dataFile.py \ test_memory.py \ diff --git a/tests/test_check_volume_status.py b/tests/test_check_volume_status.py index a18cc1c..6b0be67 100644 --- a/tests/test_check_volume_status.py +++ b/tests/test_check_volume_status.py @@ -17,18 +17,20 @@ # # Refer to the README and COPYING files for full details of the license # -import argparse - import mock from testrunner import PluginsTestCase as TestCaseBase from plugins import check_volume_status from glusternagios import utils +from glusternagios import glustercli + class ArgParseMock(object): - def __init__(self, cluster, volume): - self.cluster = cluster - self.volume = volume + def __init__(self, cluster, volume, type="info"): + self.cluster = cluster + self.volume = volume + self.type = type + class TestCheckVolumeStatus(TestCaseBase): @@ -50,20 +52,27 @@ class TestCheckVolumeStatus(TestCaseBase): .getVolumeStatus(args)) assert exitStatusCode == utils.PluginStatusCode.CRITICAL + @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') + exitStatusCode, exitStatusMsg = (check_volume_status + .getVolumeQuotaStatus(args)) + assert exitStatusCode == utils.PluginStatusCode.WARNING def _getVolume(): vol = {'test-vol': {'brickCount': 2, - 'bricks': ['server1:/path1', 'server2:/path2'], - 'options': {'option':'val'}, - 'transportType': ['tcp'], - 'uuid': '0000-0000-0000-1111', - 'volumeName': 'test-vol', - 'volumeStatus': 'ONLINE', - 'volumeType': 'DISTRIBUTED'}} + 'bricks': ['server1:/path1', 'server2:/path2'], + 'options': {'option': 'val'}, + 'transportType': ['tcp'], + 'uuid': '0000-0000-0000-1111', + 'volumeName': 'test-vol', + 'volumeStatus': 'ONLINE', + 'volumeType': 'DISTRIBUTED'}} return vol def _getEmptyVolume(): return {} - -- cgit