summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSahina Bose <sabose@redhat.com>2014-06-09 15:11:49 +0530
committerSahina Bose <sabose@redhat.com>2015-05-31 23:54:53 -0700
commit3ce8475c3e3ace39696d83e45c249f22554d4602 (patch)
treee18a76d2a1a6116df43cbabd5fffac0eada1f2e6 /tests
parentf6f9efa7dd287803a197a38fdde961519883df62 (diff)
plugins: nrpe plugin to check volumes with server quorum
Added a plugin to check if any volume in the cluster has the server side quorum turned on Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1106421 Change-Id: I897aedd737a622832548e7470e8f3cf9fb7dbc2c Signed-off-by: Sahina Bose <sabose@redhat.com> Reviewed-on: http://review.gluster.org/8016 Reviewed-by: darshan n <dnarayan@redhat.com> Reviewed-by: Ramesh N <rnachimu@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/test_check_quorum_status.py80
2 files changed, 81 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1994d43..22ec654 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -21,6 +21,7 @@
test_modules = \
test_check_gluster_syslog.py \
test_check_volume_status.py \
+ test_check_quorum_status.py \
check_proc_test_data.py \
test_cpu.py \
test_cpu_dataFile.py \
diff --git a/tests/test_check_quorum_status.py b/tests/test_check_quorum_status.py
new file mode 100644
index 0000000..1cdc5ab
--- /dev/null
+++ b/tests/test_check_quorum_status.py
@@ -0,0 +1,80 @@
+#
+# Copyright 2014 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+import mock
+
+from testrunner import PluginsTestCase as TestCaseBase
+from plugins import check_quorum_status
+from glusternagios import utils
+
+
+class TestCheckQuorumStatus(TestCaseBase):
+
+ # Method to test quorum status when quorum not set
+ @mock.patch('glusternagios.glustercli.volumeInfo')
+ def test_checkStatusNoQuorum(self, mock_volumeInfo):
+ mock_volumeInfo.return_value = _getVolumes('none')
+ exitStatusCode, exitStatusMsg = (check_quorum_status
+ .getClusterQuorumStatus())
+ print exitStatusMsg
+ assert exitStatusMsg == "Server quorum not turned on for any volume"
+ assert exitStatusCode == utils.PluginStatusCode.UNKNOWN
+ mock_volumeInfo.return_value = _getEmptyVolume()
+ exitStatusCode, exitStatusMsg = (check_quorum_status
+ .getClusterQuorumStatus())
+ assert exitStatusMsg == "Server quorum not turned on for any volume"
+ assert exitStatusCode == utils.PluginStatusCode.UNKNOWN
+
+ # Method to test quorum status when options are turned on
+ @mock.patch('glusternagios.glustercli.volumeInfo')
+ def test_checkStatusWithQuorum(self, mock_volumeInfo):
+ mock_volumeInfo.return_value = _getVolumes('server')
+ exitStatusCode, exitStatusMsg = (check_quorum_status
+ .getClusterQuorumStatus())
+ assert exitStatusCode == utils.PluginStatusCode.OK
+ assert exitStatusMsg == "Server quorum turned on " \
+ "for test-vol,test-vol2"
+
+
+def _getVolumes(quorumVal):
+ vol = {'test-vol': {'brickCount': 2,
+ 'bricks': ['server1:/path1', 'server2:/path2'],
+ 'options': {'cluster.quorum-type': 'none',
+ 'cluster.server-quorum-type': quorumVal,
+ 'changelog.changelog': 'on'},
+ 'transportType': ['tcp'],
+ 'uuid': '0000-0000-0000-1111',
+ 'volumeName': 'test-vol',
+ 'volumeStatus': 'ONLINE',
+ 'volumeType': 'DISTRIBUTED'},
+ 'test-vol2': {'brickCount': 2,
+ 'bricks': ['server1:/path1', 'server2:/path2'],
+ 'options': {'cluster.quorum-type': 'none',
+ 'cluster.server-quorum-type': quorumVal,
+ 'changelog.changelog': 'on'},
+ 'transportType': ['tcp'],
+ 'uuid': '0000-0000-0000-1111',
+ 'volumeName': 'test-vol',
+ 'volumeStatus': 'ONLINE',
+ 'volumeType': 'DISTRIBUTED'}}
+ return vol
+
+
+def _getEmptyVolume():
+ return {}