From cbfd13c455f89043d8782f86ae7c1832fe84e0b5 Mon Sep 17 00:00:00 2001 From: Sahina Bose Date: Wed, 23 Apr 2014 15:46:37 +0530 Subject: glustercli: Added geo-rep status Added method to parse gluster cli output of "gluster volume geo-rep status" and provide output in the format {volumename : {'status': STATUS, 'detail': message string}} Temporarily parsing string output till cli xml output is available for geo-rep (https://bugzilla.redhat.com/show_bug.cgi?id=1090910) Change-Id: Ie12cfcd8bb0d3bf0b3d9c13567e40d9014c47f59 Signed-off-by: Sahina Bose Reviewed-on: http://review.gluster.org/7590 Reviewed-by: Aravinda VK Reviewed-by: Bala FA --- tests/test_glustercli.py | 96 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) (limited to 'tests') diff --git a/tests/test_glustercli.py b/tests/test_glustercli.py index 1d7d517..8f271a3 100644 --- a/tests/test_glustercli.py +++ b/tests/test_glustercli.py @@ -1125,6 +1125,54 @@ class GlusterCliTests(TestCaseBase): print(status) self.assertEquals(status, expectedOut) + @mock.patch('glusternagios.utils.execCmd') + @mock.patch('glusternagios.glustercli._getGlusterVolCmd') + def test_getVolumeGeoRepStatus(self, mock_glusterVolCmd, + mock_execCmd,): + mock_glusterVolCmd.return_value = ["gluster", "volume"] + mock_execCmd.return_value = (0, + self.__getGlusterGeoRepStatusResult(), + None) + 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;"}} + 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_glusterVolCmd.return_value = ["gluster", "volume"] + mock_execCmd.return_value = (0, + self.__getGlusterGeoRepStatusResult2(), + None) + 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;"}} + status = gcli.volumeGeoRepStatus("test-vol") + print(status) + self.assertEquals(status, expectedOut) + mock_execCmd.return_value = (0, + self.__getGlusterGeoRepStatusResult3(), + None) + expectedOut = {'test-vol': + {'status': gcli.GeoRepStatus.NOT_STARTED, + 'detail': "10.70.43.68::slave-vol - " + "rhs3-2.novalocal - NOT_STARTED;"}} + status = gcli.volumeGeoRepStatus("test-vol") + print(status) + self.assertEquals(status, expectedOut) + def __getQuotaOut(self): return \ [" Path Hard-limit Soft-limit" @@ -1156,3 +1204,51 @@ class GlusterCliTests(TestCaseBase): "/dir.7/file.2", "/dir.10/file.2", "/dir.7/file.4"] + + def __getGlusterGeoRepStatusResult(self): + return ["MASTER NODE MASTER VOL MASTER BRICK " + "SLAVE STATUS CHECKPOINT STATUS " + "CRAWL STATUS", + "--------------------------------------------------------" + "--------------------------------------------------------" + "----------------", + "rhs3.novalocal rep /bricks/b3 " + "10.70.43.68::slave-vol faulty " + "N/A N/A", + "rhs3-2.novalocal rep /bricks/b3 " + "10.70.43.68::slave-vol faulty " + "N/A N/A "] + + def __getGlusterGeoRepStatusResult2(self): + return ["MASTER NODE MASTER VOL MASTER BRICK " + "SLAVE STATUS CHECKPOINT STATUS " + "CRAWL STATUS", + "--------------------------------------------------------" + "--------------------------------------------------------" + "----------------", + "rhs3.novalocal rep /bricks/b3 " + "10.70.43.68::slave-vol Passive " + "N/A N/A", + "rhs3-2.novalocal rep /bricks/b3 " + "10.70.43.68::slave-vol faulty " + "N/A N/A ", + "rhs3.novalocal rep /bricks/b3 " + "10.70.43.68::slave-vol2 Not Started " + "N/A N/A", + "rhs3-2.novalocal rep /bricks/b3 " + "10.70.43.68::slave-vol2 Not Started " + "N/A N/A "] + + def __getGlusterGeoRepStatusResult3(self): + return ["MASTER NODE MASTER VOL MASTER BRICK " + "SLAVE STATUS CHECKPOINT STATUS " + "CRAWL STATUS", + "--------------------------------------------------------" + "--------------------------------------------------------" + "----------------", + "rhs3.novalocal rep /bricks/b3 " + "10.70.43.68::slave-vol Passive " + "N/A N/A", + "rhs3-2.novalocal rep /bricks/b3 " + "10.70.43.68::slave-vol Not Started " + "N/A N/A "] -- cgit