summaryrefslogtreecommitdiffstats
path: root/tests/test_check_remote_host.py
diff options
context:
space:
mode:
authorShubhendu Tripathi <shtripat@redhat.com>2014-03-14 12:56:53 +0530
committerBala.FA <barumuga@redhat.com>2014-04-29 10:21:36 +0530
commit795fc58ef57127f257ea06c8c77ff8fba0662a4e (patch)
treeb3fd7e1ccfb670961257a51249f66d413f998e04 /tests/test_check_remote_host.py
parentad004f45088ee81723b2a2420b3bce01f0bd845b (diff)
nagios-server-addons: Check remote host plugin
Plugins to ckeck the remote host status based on various services. Change-Id: I1e260829901aa8dd831f0ca1d58609addb9bcf1b Signed-off-by: Shubhendu Tripathi <shtripat@redhat.com> Reviewed-on: https://cuckoo.blr.redhat.com:8443/9 Reviewed-by: Sahina Bose <sabose@redhat.com> Tested-by: Sahina Bose <sabose@redhat.com>
Diffstat (limited to 'tests/test_check_remote_host.py')
-rw-r--r--tests/test_check_remote_host.py47
1 files changed, 13 insertions, 34 deletions
diff --git a/tests/test_check_remote_host.py b/tests/test_check_remote_host.py
index c5c602d..f7965f3 100644
--- a/tests/test_check_remote_host.py
+++ b/tests/test_check_remote_host.py
@@ -19,49 +19,28 @@
#
import mock
+import socket
+import plugins
from testrunner import PluginsTestCase as TestCaseBase
-from plugins.check_remote_host import *
-class TestHello(TestCaseBase):
- # Method to test the execCmd() method
- @mock.patch('check_remote_host.subprocess.Popen')
- def testExecCmd(self, mock_popen):
- reference = subprocess.Popen('any command', close_fds=True,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- out = "sample output"
- err = ""
- reference.communicate.return_value = (out, err)
- self.assertTrue(reference.communicate, "communicate called")
-
- # Method to test the getPingStatus() method
- @mock.patch('check_remote_host.execCmd')
- def testGetPingStatus(self, mock_execCmd):
- rc = 0
- out = "sample output"
- err = ""
- mock_execCmd.return_value = (rc, out, err)
- getPingStatus('dummy host')
- mock_execCmd.assert_called_with([
- '/usr/lib64/nagios/plugins/check_ping', '-H', 'dummy', 'host',
- '-w', '3000.0,80%', '-c', '5000.0,100%'])
- self.assertRaises(OSError, execCmd,
- ['/usr/lib64/nagios/plugins/check_ping', '-H',
- 'dummy', 'host', '-w', '3000.0,80%', '-c',
- '5000.0,100%'])
-
+class TestCheckRemoteHost(TestCaseBase):
# Method to test the checkLiveStatus() method
- @mock.patch('check_remote_host.socket.socket')
+ @mock.patch('plugins.check_remote_host.livestatus.socket.socket')
def testCheckLiveStatus(self, mock_socket):
reference = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.assertTrue(mock_socket, "called")
reference.recv.return_value = "0\n"
- checkLiveStatus("dummy host", "dummy srvc")
- reference.connect.assert_called_with('/var/spool/nagios/cmd/live')
+ plugins.check_remote_host.checkLiveStatus("dummy host", "dummy srvc")
+ reference.connect.assert_called_with("${localstatedir}/"
+ "spool/nagios/cmd/live")
reference.send.assert_called_with("GET services\nColumns: state\n"
"Filter: description = dummy srvc\n"
"Filter: host_address = "
- "dummy host\n")
- self.assertEquals(0, checkLiveStatus("dummy host", "dummy srvc"))
+ "dummy host\n"
+ "Separators: 10 124 44 59")
+ self.assertEquals(0,
+ plugins.
+ check_remote_host.
+ checkLiveStatus("dummy host", "dummy srvc"))