本文整理汇总了Python中WMCore.Agent.HeartbeatAPI.HeartbeatAPI.getAllHeartbeatInfo方法的典型用法代码示例。如果您正苦于以下问题:Python HeartbeatAPI.getAllHeartbeatInfo方法的具体用法?Python HeartbeatAPI.getAllHeartbeatInfo怎么用?Python HeartbeatAPI.getAllHeartbeatInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WMCore.Agent.HeartbeatAPI.HeartbeatAPI
的用法示例。
在下文中一共展示了HeartbeatAPI.getAllHeartbeatInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testAddComponent
# 需要导入模块: from WMCore.Agent.HeartbeatAPI import HeartbeatAPI [as 别名]
# 或者: from WMCore.Agent.HeartbeatAPI.HeartbeatAPI import getAllHeartbeatInfo [as 别名]
def testAddComponent(self):
"""
_testAddComponent_
Test creation of components and worker threads as well as the
get heartbeat DAOs
"""
comp1 = HeartbeatAPI("testComponent1", pollInterval=60, heartbeatTimeout=600)
comp1.registerComponent()
self.assertEqual(comp1.getHeartbeatInfo(), []) # no worker thread yet
comp1.registerWorker("testWorker1")
self.assertEqual(len(comp1.getHeartbeatInfo()), 1)
comp1.registerWorker("testWorker2")
self.assertEqual(len(comp1.getHeartbeatInfo()), 2)
comp2 = HeartbeatAPI("testComponent2", pollInterval=30, heartbeatTimeout=300)
comp2.registerComponent()
self.assertEqual(comp2.getHeartbeatInfo(), []) # no worker thread yet
self.assertEqual(len(comp2.getAllHeartbeatInfo()), 2)
comp2.registerWorker("testWorker21")
self.assertEqual(len(comp2.getHeartbeatInfo()), 1)
self.assertEqual(len(comp2.getAllHeartbeatInfo()), 3)
comp1.updateWorkerHeartbeat("testWorker1", "Running")
comp1.updateWorkerHeartbeat("testWorker2", "Running")
comp2.updateWorkerHeartbeat("testWorker21", "Running")
self.assertEqual(len(comp1.getAllHeartbeatInfo()), 3)
self.assertEqual(len(comp2.getAllHeartbeatInfo()), 3)
comp1Res = comp1.getHeartbeatInfo()
comp2Res = comp2.getHeartbeatInfo()
self.assertEqual(len(comp1Res), 2)
self.assertEqual(len(comp2Res), 1)
self.assertItemsEqual([item["name"] for item in comp1Res], ["testComponent1", "testComponent1"])
self.assertItemsEqual([item["worker_name"] for item in comp1Res], ["testWorker1", "testWorker2"])
self.assertItemsEqual([item["state"] for item in comp1Res], ["Running", "Running"])
self.assertItemsEqual([item["poll_interval"] for item in comp1Res], [60, 60])
self.assertItemsEqual([item["update_threshold"] for item in comp1Res], [600, 600])
self.assertItemsEqual([item["name"] for item in comp2Res], ["testComponent2"])
self.assertItemsEqual([item["worker_name"] for item in comp2Res], ["testWorker21"])
self.assertItemsEqual([item["state"] for item in comp2Res], ["Running"])
self.assertItemsEqual([item["poll_interval"] for item in comp2Res], [30])
self.assertItemsEqual([item["update_threshold"] for item in comp2Res], [300])