本文整理汇总了Python中MilkCheck.Engine.ServiceGroup.ServiceGroup.add_inter_dep方法的典型用法代码示例。如果您正苦于以下问题:Python ServiceGroup.add_inter_dep方法的具体用法?Python ServiceGroup.add_inter_dep怎么用?Python ServiceGroup.add_inter_dep使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MilkCheck.Engine.ServiceGroup.ServiceGroup
的用法示例。
在下文中一共展示了ServiceGroup.add_inter_dep方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_prepare_group_subservices
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import add_inter_dep [as 别名]
def test_prepare_group_subservices(self):
'''Test prepare group with multiple internal dependencies.'''
group = ServiceGroup('GROUP')
ac_suc1 = Action('start', command='/bin/true')
ac_suc2 = Action('start', command='/bin/true')
ac_suc3 = Action('start', command='/bin/true')
subserv_a = Service('SUB1')
subserv_b = Service('SUB2')
subserv_c = Service('SUB3')
subserv_a.add_action(ac_suc1)
subserv_b.add_action(ac_suc2)
subserv_c.add_action(ac_suc3)
group.add_inter_dep(target=subserv_a)
group.add_inter_dep(target=subserv_b)
group.add_inter_dep(base=subserv_a, target=subserv_c)
group.add_inter_dep(base=subserv_b, target=subserv_c)
group.run('start')
self.assertEqual(group.status, DONE)
self.assertEqual(subserv_a.status, DONE)
self.assertEqual(subserv_b.status, DONE)
self.assertEqual(subserv_c.status, DONE)
示例2: test_has_subservice
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import add_inter_dep [as 别名]
def test_has_subservice(self):
'''Test whether a service is an internal dependency of a group'''
group = ServiceGroup('group')
serv = Service('intern_service')
self.assertFalse(group.has_subservice(serv.name))
group.add_inter_dep(target=serv)
self.assertTrue(group.has_subservice(serv.name))
示例3: setUp
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import add_inter_dep [as 别名]
def setUp(self):
'''
Set up the graph of services within the service manager
Graph
_ start
group --> service /
`- stop
'''
CLICommon.setUp(self)
# ServiceGroup
group = ServiceGroup('ServiceGroup')
# Service
self.service = service = Service('service')
service.desc = 'I am the service'
# Actions
start_action = Action('start', command='/bin/true')
stop_action = Action('stop', command='/bin/false')
self.timeout_action = Action('timeout', command='sleep 1', timeout=0.1)
start_action.inherits_from(service)
stop_action.inherits_from(service)
service.add_action(start_action)
service.add_action(stop_action)
service.add_action(self.timeout_action)
# Build graph
group.add_inter_dep(target=service)
# Register services within the manager
self.manager.register_services(group, service)
示例4: test_update_target
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import add_inter_dep [as 别名]
def test_update_target(self):
'''Test update of the target of a group of services'''
grp = ServiceGroup('G')
srva = Service('A')
grp.add_inter_dep(target=srva)
grp.update_target('fortoy[5-10]')
self.assertTrue(grp.target == NodeSet('fortoy[5-10]'))
self.assertTrue(srva.target == NodeSet('fortoy[5-10]'))
示例5: test_missing_group
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import add_inter_dep [as 别名]
def test_missing_group(self):
"""A group with only MISSING services should be MISSING"""
grp = ServiceGroup('group')
svc1 = Service('svc1')
svc1.add_action(Action('stop', command='/bin/true'))
grp.add_inter_dep(target=svc1)
grp.run('start')
self.assertEqual(grp.status, MISSING)
示例6: setUp
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import add_inter_dep [as 别名]
def setUp(self):
'''
Set up the graph of services within the service manager
Graph
__ S2 __ I1
S1 / -- G1 -- (src) / ^ -- (sink)
`-- S3 --/ `-- I2
Each node has an action start and an action stop
'''
CLICommon.setUp(self)
svc1 = Service('S1')
svc1.desc = 'I am the service S1'
self.svc2 = svc2 = Service('S2')
svc2.desc = 'I am the service S2'
svc3 = Service('S3')
svc3.desc = 'I am the service S3'
group1 = ServiceGroup('G1')
inter1 = Service('I1')
inter1.desc = 'I am the service I1'
inter2 = Service('I2')
inter2.desc = 'I am the service I2'
# Actions S1
start_svc1 = Action('start', HOSTNAME + ', BADNODE', '/bin/true')
start_svc1.delay = 1
stop_svc1 = Action('stop', HOSTNAME + ',BADNODE', '/bin/true')
stop_svc1.delay = 1
svc1.add_actions(start_svc1, stop_svc1)
# Actions S2
svc2.add_action(Action('start', HOSTNAME + ',BADNODE', '/bin/true'))
svc2.add_action(Action('stop', HOSTNAME + ',BADNODE', '/bin/true'))
# Actions S3
svc3.add_action(Action('start', HOSTNAME + ',BADNODE', '/bin/false'))
svc3.add_action(Action('stop', HOSTNAME + ',BADNODE', '/bin/false'))
# Actions I1
inter1.add_action(Action('start', HOSTNAME, 'echo ok'))
inter1.add_action(Action('stop', HOSTNAME, 'echo ok'))
# Actions I2
inter2.add_action(Action('start', HOSTNAME + ',BADNODE', '/bin/true'))
inter2.add_action(Action('stop', HOSTNAME + ',BADNODE', '/bin/true'))
# Build graph
svc1.add_dep(target=svc2)
svc1.add_dep(target=svc3)
svc3.add_dep(target=group1)
inter2.add_dep(inter1)
group1.add_inter_dep(target=inter1)
group1.add_inter_dep(target=inter2)
# Register services within the manager
self.manager.add_service(svc1)
self.manager.add_service(svc2)
self.manager.add_service(svc3)
self.manager.add_service(group1)
示例7: test_prepare_group_subservice
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import add_inter_dep [as 别名]
def test_prepare_group_subservice(self):
'''Test prepare group with an internal dependency.'''
group = ServiceGroup('GROUP')
subserv = Service('SUB1')
subserv.add_action(Action('start', command='/bin/true'))
group.add_inter_dep(target=subserv)
group.run('start')
self.assertEqual(group.status, DONE)
self.assertEqual(subserv.status, DONE)
示例8: test_skip
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import add_inter_dep [as 别名]
def test_skip(self):
"""Test skip method for ServiceGroup"""
grp = ServiceGroup('group')
srv = Service('skipped')
srv.add_action(Action('start', target=NodeSet('foo'),
command='/bin/true'))
grp.add_inter_dep(target=srv)
self.assertFalse(grp.to_skip('start'))
grp.skip()
self.assertTrue(grp.to_skip('start'))
示例9: test_skipped_group
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import add_inter_dep [as 别名]
def test_skipped_group(self):
"""A group with only SKIPPED services should be SKIPPED"""
grp = ServiceGroup('group')
svc1 = Service('svc1')
svc1.add_action(Action('start', target="@NOTHING", command=':'))
svc2 = Service('svc2')
svc2.add_action(Action('start', target="@NOTHING", command=':'))
grp.add_inter_dep(target=svc1)
grp.add_inter_dep(target=svc2)
grp.run('start')
self.assertEqual(grp.status, SKIPPED)
示例10: test_eval_deps_status_error
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import add_inter_dep [as 别名]
def test_eval_deps_status_error(self):
'''Test the method eval_deps_status DEP_ERROR'''
group = ServiceGroup('group')
e1 = Service('E1')
e2 = Service('E2')
e1.status = DEP_ERROR
group.add_dep(target=e1)
group.add_dep(target=e2)
group.add_inter_dep(target=Service('I1'))
self.assertEqual(group.eval_deps_status(), DEP_ERROR)
self.assertEqual(group.eval_deps_status(), DEP_ERROR)
示例11: test_eval_deps_status_done
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import add_inter_dep [as 别名]
def test_eval_deps_status_done(self):
'''Test the method eval_deps_status NO_STATUS'''
group = ServiceGroup('group')
e1 = Service('E1')
e2 = Service('E2')
group.add_dep(target=e1)
group.add_dep(target=e2)
group.add_inter_dep(target=Service('I1'))
self.assertEqual(group.eval_deps_status(), NO_STATUS)
e1.status = DONE
e2.status = DONE
self.assertEqual(group.eval_deps_status(), NO_STATUS)
示例12: test_eval_deps_status_ws
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import add_inter_dep [as 别名]
def test_eval_deps_status_ws(self):
'''Test the method eval_deps_status WAITING_STATUS'''
group = ServiceGroup('group')
ext1 = Service('E1')
ext2 = Service('E2')
ext1.status = DONE
ext2.status = WARNING
group.add_dep(target=ext1)
group.add_dep(target=ext2)
int1 = Service('E1')
group.add_inter_dep(target=int1)
int1.status = WAITING_STATUS
self.assertEqual(group.eval_deps_status(), WAITING_STATUS)
示例13: test_group_with_weak_dep_error
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import add_inter_dep [as 别名]
def test_group_with_weak_dep_error(self):
"""A group with a weak dep error runs fine (add_inter_dep())."""
dep1 = Service('dep1')
dep1.add_action(Action('stop', command='/bin/false'))
grp = ServiceGroup('group')
svc = Service('svc')
svc.add_action(Action('stop', command='/bin/true'))
grp.add_inter_dep(svc)
grp.add_dep(dep1, sgth=REQUIRE_WEAK)
grp.run('stop')
self.assertEqual(grp.status, DONE)
示例14: test_run_stop_on_group
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import add_inter_dep [as 别名]
def test_run_stop_on_group(self):
'''Test stop algorithm on a group'''
group = ServiceGroup('G1')
i1 = Service('I1')
i1.add_action(Action('stop', command='/bin/true'))
group.add_inter_dep(target=i1)
s1 = Service('S1')
s1.add_action(Action('stop', command='/bin/true'))
s1.add_dep(target=group)
s1.algo_reversed = True
group.algo_reversed = True
group.run('stop')
self.assertEqual(s1.status, DONE)
self.assertEqual(i1.status, DONE)
self.assertEqual(group.status, DONE)
示例15: test_filter
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import add_inter_dep [as 别名]
def test_filter(self):
"""ServiceGroup supports filter dependency"""
dep = Service('dep')
dep.add_action(Action('stop', command='false', target=HOSTNAME))
grp = ServiceGroup('group')
svc = Service('svc')
svc.add_action(Action('stop', command='true', target=HOSTNAME))
grp.add_inter_dep(svc)
grp.add_dep(dep, sgth=FILTER)
grp.run('stop')
self.assertEqual(dep.status, ERROR)
self.assertEqual(svc.status, SKIPPED)
self.assertEqual(grp.status, SKIPPED)