本文整理汇总了Python中WMCore.Services.LogDB.LogDB.LogDB.get_all_requests方法的典型用法代码示例。如果您正苦于以下问题:Python LogDB.get_all_requests方法的具体用法?Python LogDB.get_all_requests怎么用?Python LogDB.get_all_requests使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WMCore.Services.LogDB.LogDB.LogDB
的用法示例。
在下文中一共展示了LogDB.get_all_requests方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LogDBTest
# 需要导入模块: from WMCore.Services.LogDB.LogDB import LogDB [as 别名]
# 或者: from WMCore.Services.LogDB.LogDB.LogDB import get_all_requests [as 别名]
class LogDBTest(unittest.TestCase):
"""
_LogDBTest_
"""
def setUp(self):
"""
_setUp_
Setup the database and logging connection.
"""
logging.basicConfig()
self.logger = logging.getLogger('LogDBTest')
# self.logger.setLevel(logging.DEBUG)
url = 'http://localhost:5984/logdb_t'
identifier = 'agentname'
self.agent_inst = LogDB(url, identifier, logger=self.logger, create=True)
self.agent_inst2 = LogDB(url, identifier, logger=self.logger, create=True, thread_name="Test")
identifier = '/DC=org/DC=doegrids/OU=People/CN=First Last 123'
self.user_inst = LogDB(url, identifier, logger=self.logger, create=True)
self.report = LogDBReport(self.agent_inst)
def tearDown(self):
"""
_tearDown_
Drop all the WMBS tables.
"""
self.agent_inst.backend.deleteDatabase()
def test_docid(self):
"Test docid API"
request = 'abs'
mtype = self.agent_inst.backend.prefix('info')
res = self.agent_inst.backend.docid(request, mtype)
key = '--'.join([request, self.agent_inst.identifier, self.agent_inst.thread_name, mtype])
khash = gen_hash(key)
self.assertEqual(res, khash)
def test_prefix(self):
"Test prefix LogDBBackend API"
request = 'abc'
self.assertEqual(self.agent_inst.agent, 1)
mtype = self.agent_inst.backend.prefix('msg')
self.assertEqual(mtype, 'agent-msg')
self.assertEqual(self.user_inst.agent, 0)
mtype = self.user_inst.backend.prefix('msg')
self.assertEqual(mtype, 'msg')
def test_apis(self):
"Test LogDB APIs"
request = 'abc'
# if we post messages for the same request only last one should survive
self.agent_inst.post(request, 'msg1')
# time.sleep(1)
self.agent_inst.post(request, 'msg2')
# time.sleep(1)
self.agent_inst.post(request, 'msg3')
# time.sleep(1)
self.agent_inst.post(request, 'msg4')
# time.sleep(1)
docs = self.agent_inst.get(request)
self.assertEqual(len(docs), 1)
self.assertEqual(docs[0]['msg'], 'msg4')
# add message as user, user based messages will grow
self.user_inst.post(request, 'doc1')
# time.sleep(1)
docs = self.user_inst.get(request)
self.assertEqual(len(docs), 2) # we have msg4 and doc1
self.user_inst.post(request, 'doc1') # we have msg2 and two doc1 messages
# time.sleep(1)
docs = self.user_inst.get(request)
self.assertEqual(len(docs), 3)
def test_cleanup(self):
"Test clean-up LogDB API"
request = 'abc'
self.agent_inst.post(request, 'msg1', 'info')
self.agent_inst.post(request, 'msg2', 'comment')
self.agent_inst.post(request, 'msg3', 'warning')
self.agent_inst.post(request, 'msg4', 'error')
all_docs = self.agent_inst.get(request)
self.agent_inst.backend.cleanup(thr=10) # look into past
past_docs = self.agent_inst.get(request)
self.assertEqual(len(all_docs), len(past_docs))
self.agent_inst.backend.cleanup(thr=-10) # look into future
docs = self.agent_inst.get(request)
self.assertEqual(len(docs), 0)
def test_get_all_requests(self):
"Test get_all_requests LogDB API"
request = 'abc'
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')
#.........这里部分代码省略.........