本文整理汇总了Python中MilkCheck.Engine.ServiceGroup.ServiceGroup.add_var方法的典型用法代码示例。如果您正苦于以下问题:Python ServiceGroup.add_var方法的具体用法?Python ServiceGroup.add_var怎么用?Python ServiceGroup.add_var使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MilkCheck.Engine.ServiceGroup.ServiceGroup
的用法示例。
在下文中一共展示了ServiceGroup.add_var方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_resolve_all_with_full_config
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import add_var [as 别名]
def test_resolve_all_with_full_config(self):
"""Test instantiation of a service group with variables subservices."""
sergrp = ServiceGroup('S1')
sergrp.add_var('TOUT', 1)
sergrp.add_var('RET', 2)
sergrp.add_var('FAN', 3)
sergrp.add_var('DLY', 4)
sergrp.add_var('ERRS', 0)
sergrp.add_var('WARN', 5)
sergrp.add_var('DSC', 'I am the service')
sergrp.add_var('MD', 'delegate')
sergrp.add_var('REQUIRES', ["dep1", "dep2"])
sergrp.fromdict({
'desc': "Check variables",
'target': "localhost",
'services': {
'dep1':
{'actions': {'start': {'cmd': '/bin/True'}} },
'dep2':
{'actions': {'start': {'cmd': '/bin/True'}} },
'fullvars': {
'target': 'localhost',
'require': "%REQUIRES",
'timeout': "%TOUT",
'retry': "%RET",
'fanout': "%FAN",
'delay': "%DLY",
'errors': "%ERRS",
'warnings': "%WARN",
'mode': "%MD",
'actions': {
'start': {'cmd': '/bin/True'},
'stop': {'cmd': '/bin/False'}
},
'desc': "%DSC"
}
},
})
sergrp.resolve_all()
service = sergrp._subservices['fullvars']
self.assertEqual(service.target, NodeSet('localhost'))
self.assertEqual(service.timeout, 1)
self.assertEqual(service.maxretry, 2)
self.assertEqual(service.fanout, 3)
self.assertEqual(service.delay, 4)
self.assertEqual(service.errors, 0)
self.assertEqual(service.warnings, 5)
self.assertEqual(service.mode, 'delegate')
self.assertEqual(service.desc, "I am the service")
self.assertTrue('dep1' in service.deps())
self.assertTrue('dep2' in service.deps())