本文整理匯總了Python中WMCore.Services.LogDB.LogDB.LogDB.wmstats_down_components_report方法的典型用法代碼示例。如果您正苦於以下問題:Python LogDB.wmstats_down_components_report方法的具體用法?Python LogDB.wmstats_down_components_report怎麽用?Python LogDB.wmstats_down_components_report使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WMCore.Services.LogDB.LogDB.LogDB
的用法示例。
在下文中一共展示了LogDB.wmstats_down_components_report方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: LogDBTest
# 需要導入模塊: from WMCore.Services.LogDB.LogDB import LogDB [as 別名]
# 或者: from WMCore.Services.LogDB.LogDB.LogDB import wmstats_down_components_report [as 別名]
#.........這裏部分代碼省略.........
self.assertEqual(len(docs), 4) # this should result the same as above.
docs1 = self.agent_inst.get(request, 'info')
docs2 = self.agent_inst.get(request, 'info')
req1 = set([r['request'] for r in docs1])
self.assertEqual(len(req1), 1)
req2 = set([r['request'] for r in docs2])
self.assertEqual(len(req2), 1)
self.assertEqual(req1, req2)
def test_thread_name(self):
"Test thread name support by LogDB APIs"
request = 'abc'
self.agent_inst2.post(request, 'msg1', 'info') # doc with different thread name
self.agent_inst.post(request, 'msg1', 'info')
self.agent_inst.post(request, 'msg2', 'info')
self.agent_inst.post(request, 'msg3', 'warning')
self.agent_inst.post(request, 'msg4', 'error')
maindocs = self.agent_inst.get(request)
self.assertEqual(len(maindocs), 4) # since we have two info records in agent_inst
thr_docs = self.agent_inst2.get(request)
self.assertEqual(len(thr_docs), 4) # number of docs in different thread
req1 = set([r['request'] for r in maindocs])
self.assertEqual(len(req1), 1)
req2 = set([r['request'] for r in thr_docs])
self.assertEqual(len(req2), 1)
self.assertEqual(req1, req2)
worker1 = set([r['thr'] for r in maindocs])
self.assertEqual(worker1, set(["Test", "MainThread"]))
worker2 = set([r['thr'] for r in thr_docs])
self.assertEqual(worker2, set(["Test", "MainThread"]))
docs = set([r['identifier'] for r in maindocs])
self.assertEqual(docs, set([self.agent_inst.identifier]))
docs = set([r['identifier'] for r in thr_docs])
self.assertEqual(docs, set([self.agent_inst.identifier]))
def test_checks(self):
"Tests LogDB check/mtype functionality"
request = 'abc'
res = self.agent_inst.post(request, 'msg', 'ingo') # should be silent, i.o. no Exceptions
self.assertEqual('post-error', res)
args = (request, 'msg', 'ingo') # wrong type
self.assertRaises(LogDBError, self.agent_inst.backend.agent_update, *args)
args = (request, 'ingo') # wrong type
self.assertRaises(LogDBError, self.agent_inst.backend.check, *args)
args = ('', 'msg', 'info') # empty request string
self.assertRaises(LogDBError, self.agent_inst.backend.agent_update, *args)
args = ('', 'info') # empty request string
self.assertRaises(LogDBError, self.agent_inst.backend.check, *args)
def test_report(self):
"Test LogDBReport APIs"
request = 'abc'
self.agent_inst.post(request, 'msg1', 'info')
time.sleep(1)
self.agent_inst.post(request, 'msg2', 'comment')
time.sleep(1)
self.agent_inst.post(request, 'msg3', 'warning')
time.sleep(1)
self.agent_inst.post(request, 'msg4', 'error')
time.sleep(1)
self.report.to_stdout(request)
out = self.report.to_txt(request)
print("\n### txt report\n", out)
out = self.report.to_html(request)
print("\n### html report\n", out)
docs = self.agent_inst.get(request)
tdocs = self.report.orderby(docs, order='ts')
messages = [d['msg'] for d in tdocs]
self.assertEqual(messages, ['msg4', 'msg3', 'msg2', 'msg1'])
def test_heartbeat(self):
"Test heartbeat_report function"
threadName = 'MainThread'
failThread = 'FailThread'
self.agent_inst.post(msg="Test heartbeat", mtype="info")
time.sleep(1)
self.agent_inst.post(msg="Test heartbeatError", mtype="error")
report = self.agent_inst.heartbeat_report()
self.assertEqual(report[threadName]['type'], 'agent-error')
report = self.agent_inst.wmstats_down_components_report([threadName])
self.assertEqual(report['down_components'], [threadName])
self.agent_inst.post(msg="Test heartbeat", mtype="info")
report = self.agent_inst.wmstats_down_components_report([threadName])
self.assertEqual(report['down_components'], [])
report = self.agent_inst.wmstats_down_components_report([threadName, failThread])
self.assertEqual(report['down_components'], [failThread])
self.agent_inst.post(msg="Test heartbeatError2", mtype="error")
report = self.agent_inst.wmstats_down_components_report([threadName])
self.assertEqual(report['down_components'], [threadName])
self.agent_inst.delete(mtype="error", this_thread=True)
report = self.agent_inst.wmstats_down_components_report([threadName])
self.assertEqual(report['down_components'], [])