本文整理汇总了Python中ambari_agent.HostInfo.HostInfo.checkLiveServices方法的典型用法代码示例。如果您正苦于以下问题:Python HostInfo.checkLiveServices方法的具体用法?Python HostInfo.checkLiveServices怎么用?Python HostInfo.checkLiveServices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ambari_agent.HostInfo.HostInfo
的用法示例。
在下文中一共展示了HostInfo.checkLiveServices方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_checkLiveServices
# 需要导入模块: from ambari_agent.HostInfo import HostInfo [as 别名]
# 或者: from ambari_agent.HostInfo.HostInfo import checkLiveServices [as 别名]
def test_checkLiveServices(self, subproc_popen, get_os_type_method):
hostInfo = HostInfo()
p = MagicMock()
p.returncode = 0
p.communicate.return_value = ("", "err")
subproc_popen.return_value = p
result = []
get_os_type_method.return_value = "redhat"
hostInfo.checkLiveServices(["service1"], result)
self.assertEquals(result[0]["status"], "Healthy")
self.assertEquals(result[0]["name"], "service1")
self.assertEquals(result[0]["desc"], "")
self.assertEquals(
str(subproc_popen.call_args_list), "[call(['service', 'service1', 'status'], stderr=-1, stdout=-1)]"
)
p.returncode = 1
p.communicate.return_value = ("out", "err")
result = []
hostInfo.checkLiveServices(["service1"], result)
self.assertEquals(result[0]["status"], "Unhealthy")
self.assertEquals(result[0]["name"], "service1")
self.assertEquals(result[0]["desc"], "out")
p.communicate.return_value = ("", "err")
result = []
hostInfo.checkLiveServices(["service1"], result)
self.assertEquals(result[0]["status"], "Unhealthy")
self.assertEquals(result[0]["name"], "service1")
self.assertEquals(result[0]["desc"], "err")
p.communicate.return_value = ("", "err", "")
result = []
hostInfo.checkLiveServices(["service1"], result)
self.assertEquals(result[0]["status"], "Unhealthy")
self.assertEquals(result[0]["name"], "service1")
self.assertTrue(len(result[0]["desc"]) > 0)
示例2: test_checkLiveServices
# 需要导入模块: from ambari_agent.HostInfo import HostInfo [as 别名]
# 或者: from ambari_agent.HostInfo.HostInfo import checkLiveServices [as 别名]
def test_checkLiveServices(self, subproc_popen, get_os_type_method):
hostInfo = HostInfo()
p = MagicMock()
p.returncode = 0
p.communicate.return_value = ('', 'err')
subproc_popen.return_value = p
result = []
get_os_type_method.return_value = 'redhat'
hostInfo.checkLiveServices(['service1'], result)
self.assertEquals(result[0]['status'], 'Healthy')
self.assertEquals(result[0]['name'], 'service1')
self.assertEquals(result[0]['desc'], '')
self.assertEquals(str(subproc_popen.call_args_list),
"[call(['/sbin/service', 'service1', 'status'], stderr=-1, stdout=-1)]")
p.returncode = 1
p.communicate.return_value = ('out', 'err')
result = []
hostInfo.checkLiveServices(['service1'], result)
self.assertEquals(result[0]['status'], 'Unhealthy')
self.assertEquals(result[0]['name'], 'service1')
self.assertEquals(result[0]['desc'], 'out')
p.communicate.return_value = ('', 'err')
result = []
hostInfo.checkLiveServices(['service1'], result)
self.assertEquals(result[0]['status'], 'Unhealthy')
self.assertEquals(result[0]['name'], 'service1')
self.assertEquals(result[0]['desc'], 'err')
p.communicate.return_value = ('', 'err', '')
result = []
hostInfo.checkLiveServices(['service1'], result)
self.assertEquals(result[0]['status'], 'Unhealthy')
self.assertEquals(result[0]['name'], 'service1')
self.assertTrue(len(result[0]['desc']) > 0)