diff options
author | Sahina Bose <sabose@redhat.com> | 2014-05-27 12:21:29 +0530 |
---|---|---|
committer | Sahina Bose <sabose@redhat.com> | 2014-05-28 23:04:13 -0700 |
commit | 12171f154d5c6d2ee5fd23b7439770f0b51d39fb (patch) | |
tree | 14ede74eeb9a9e1e3329d837e6a28e5d2b10da9b /tests | |
parent | 2b35b6649b5af2d4d4296612f1c711bddcdf7930 (diff) |
nagios-common: Enhanced geo rep status parsing
Enhanced the gluster cli - geo rep status- parsing
to consider other node states like stopped
and to combine it with volume topology.
Change-Id: I21876339f82a0137c41f7ec7ccc0672815590e88
Bug-Url: https://bugzilla.redhat.com/1101218
Signed-off-by: Sahina Bose <sabose@redhat.com>
Reviewed-on: http://review.gluster.org/7888
Reviewed-by: Ramesh N <rnachimu@redhat.com>
Reviewed-by: Aravinda VK <avishwan@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_glustercli.py | 98 |
1 files changed, 77 insertions, 21 deletions
diff --git a/tests/test_glustercli.py b/tests/test_glustercli.py index ebaeac4..e10a11f 100644 --- a/tests/test_glustercli.py +++ b/tests/test_glustercli.py @@ -1135,38 +1135,80 @@ class GlusterCliTests(TestCaseBase): @mock.patch('glusternagios.utils.execCmd') @mock.patch('glusternagios.glustercli._getGlusterVolCmd') - def test_getVolumeGeoRepStatus(self, mock_glusterVolCmd, + @mock.patch('glusternagios.glustercli.volumeInfo') + def test_getVolumeGeoRepStatus(self, + mock_volumeInfo, + mock_glusterVolCmd, mock_execCmd,): mock_glusterVolCmd.return_value = ["gluster", "volume"] mock_execCmd.return_value = (0, self.__getGlusterGeoRepStatusResult(), None) + mock_volumeInfo.return_value = {'test-vol': + {'volumeType': 'REPLICATE', + 'replicaCount': 2, + 'brickCount': 2 + } + } expectedOut = {'test-vol': - {'status': gcli.GeoRepStatus.FAULTY, - 'detail': "10.70.43.68::slave-vol - " - "rhs3.novalocal - FAULTY;" - "10.70.43.68::slave-vol - " - "rhs3-2.novalocal - FAULTY;"}} + {'slaves': {'10.70.43.68::slave-vol': + {'faulty': 2, + 'nodecount': 2, + 'notstarted': 0, + 'stopped': 0, + 'passive': 0, + 'detail': 'rhs3.novalocal:' + '/bricks/b3 - FAULTY;' + 'rhs3-2.novalocal:' + '/bricks/b3 - FAULTY;', + 'status': gcli.GeoRepStatus.FAULTY} + }}} status = gcli.volumeGeoRepStatus("test-vol") print(status) self.assertEquals(status, expectedOut) @mock.patch('glusternagios.utils.execCmd') @mock.patch('glusternagios.glustercli._getGlusterVolCmd') - def test_getVolumeGeoRepStatusMuliSlave(self, mock_glusterVolCmd, - mock_execCmd,): + @mock.patch('glusternagios.glustercli.volumeInfo') + def test_getVolumeGeoRepStatusMultiSlave(self, + mock_volumeInfo, + mock_glusterVolCmd, + mock_execCmd,): mock_glusterVolCmd.return_value = ["gluster", "volume"] mock_execCmd.return_value = (0, self.__getGlusterGeoRepStatusResult2(), None) + mock_volumeInfo.return_value = {'test-vol': + {'volumeType': 'REPLICATE', + 'replicaCount': 2, + 'brickCount': 2 + } + } expectedOut = {'test-vol': - {'status': gcli.GeoRepStatus.PARTIAL_FAULTY, - 'detail': "10.70.43.68::slave-vol - " - "rhs3-2.novalocal - FAULTY;" - "10.70.43.68::slave-vol2 - " - "rhs3.novalocal - NOT_STARTED;" - "10.70.43.68::slave-vol2 - " - "rhs3-2.novalocal - NOT_STARTED;"}} + {'slaves': + {'10.70.43.68::slave-vol': + {'faulty': 1, + 'nodecount': 2, + 'notstarted': 0, + 'stopped': 0, + 'passive': 1, + 'detail': 'rhs3.novalocal:/bricks/b3 ' + '- PASSIVE;' + 'rhs3-2.novalocal:/bricks/b3 ' + '- FAULTY;', + 'status': gcli.GeoRepStatus.FAULTY}, + '10.70.43.68::slave-vol2': + {'faulty': 0, + 'nodecount': 2, + 'notstarted': 2, + 'stopped': 0, + 'passive': 0, + 'detail': 'rhs3.novalocal:/bricks/b3 ' + '- NOT_STARTED;' + 'rhs3-2.novalocal:/bricks/b3 ' + '- NOT_STARTED;', + 'status': gcli.GeoRepStatus.NOT_STARTED} + }}} status = gcli.volumeGeoRepStatus("test-vol") print(status) self.assertEquals(status, expectedOut) @@ -1174,9 +1216,20 @@ class GlusterCliTests(TestCaseBase): self.__getGlusterGeoRepStatusResult3(), None) expectedOut = {'test-vol': - {'status': gcli.GeoRepStatus.NOT_STARTED, - 'detail': "10.70.43.68::slave-vol - " - "rhs3-2.novalocal - NOT_STARTED;"}} + {'slaves': + {'10.70.43.68::slave-vol': + {'faulty': 0, + 'nodecount': 2, + 'notstarted': 1, + 'stopped': 0, + 'passive': 1, + 'detail': 'rhs3.novalocal:/bricks/b3 ' + '- PASSIVE;' + 'rhs3-2.novalocal:' + '/bricks/b3 ' + '- NOT_STARTED;', + 'status': gcli.GeoRepStatus.NOT_STARTED + }}}} status = gcli.volumeGeoRepStatus("test-vol") print(status) self.assertEquals(status, expectedOut) @@ -1214,7 +1267,8 @@ class GlusterCliTests(TestCaseBase): "/dir.7/file.4"] def __getGlusterGeoRepStatusResult(self): - return ["MASTER NODE MASTER VOL MASTER BRICK " + return [" ", + "MASTER NODE MASTER VOL MASTER BRICK " "SLAVE STATUS CHECKPOINT STATUS " "CRAWL STATUS", "--------------------------------------------------------" @@ -1228,7 +1282,8 @@ class GlusterCliTests(TestCaseBase): "N/A N/A "] def __getGlusterGeoRepStatusResult2(self): - return ["MASTER NODE MASTER VOL MASTER BRICK " + return [" ", + "MASTER NODE MASTER VOL MASTER BRICK " "SLAVE STATUS CHECKPOINT STATUS " "CRAWL STATUS", "--------------------------------------------------------" @@ -1248,7 +1303,8 @@ class GlusterCliTests(TestCaseBase): "N/A N/A "] def __getGlusterGeoRepStatusResult3(self): - return ["MASTER NODE MASTER VOL MASTER BRICK " + return [" ", + "MASTER NODE MASTER VOL MASTER BRICK " "SLAVE STATUS CHECKPOINT STATUS " "CRAWL STATUS", "--------------------------------------------------------" |