本文整理汇总了Python中MilkCheck.Engine.ServiceGroup.ServiceGroup.algo_reversed方法的典型用法代码示例。如果您正苦于以下问题:Python ServiceGroup.algo_reversed方法的具体用法?Python ServiceGroup.algo_reversed怎么用?Python ServiceGroup.algo_reversed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MilkCheck.Engine.ServiceGroup.ServiceGroup
的用法示例。
在下文中一共展示了ServiceGroup.algo_reversed方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_core_behaviour_reverse
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import algo_reversed [as 别名]
def test_core_behaviour_reverse(self):
'''Test ability of the core to solve a large graph in reverse mode'''
# Define Group 1
grp1 = ServiceGroup('GRP1')
grp1.algo_reversed = True
grp1_i1 = Service('I1')
grp1_i1.algo_reversed = True
grp1_i2 = Service('I2')
grp1_i2.algo_reversed = True
grp1_i3 = Service('I3')
grp1_i3.algo_reversed = True
grp1_i1.add_action(Action('stop', command='/bin/true'))
grp1_i2.add_action(Action('stop', command='/bin/true'))
grp1_i3.add_action(Action('stop', command='/bin/true'))
grp1.add_inter_dep(target=grp1_i1)
grp1.add_inter_dep(base=grp1_i1, target=grp1_i2)
grp1.add_inter_dep(target=grp1_i3)
# Define Group 2
grp2 = ServiceGroup('GRP2')
grp2.algo_reversed = True
grp2_i1 = Service('I1')
grp2_i1.algo_reversed = True
grp2_i2 = Service('I2')
grp2_i2.algo_reversed = True
grp2_i1.add_action(Action('stop', command='/bin/true'))
grp2_i2.add_action(Action('stop', command='/bin/true'))
grp2.add_inter_dep(target=grp2_i1)
grp2.add_inter_dep(base=grp2_i1, target=grp2_i2)
# Define Group init
svc1 = Service('S1')
svc1.algo_reversed = True
svc1.add_action(Action('stop', command='/bin/true'))
svc2 = Service('S2')
svc2.algo_reversed = True
svc2.add_action(Action('stop', command='/bin/true'))
svc3 = Service('S3')
svc3.algo_reversed = True
svc3.add_action(Action('stop', command='/bin/true'))
group_init = ServiceGroup('GROUP_INIT')
group_init.algo_reversed = True
group_init.add_inter_dep(target=svc1)
group_init.add_inter_dep(base=svc1, target=svc2, sgth=REQUIRE_WEAK)
group_init.add_inter_dep(base=svc1, target=grp1)
group_init.add_inter_dep(base=svc2, target=svc3)
group_init.add_inter_dep(base=grp1, target=svc3)
group_init.add_inter_dep(base=svc3, target=grp2)
# Solve the graph
group_init.run('stop')
# Assertions
self.assertEqual(grp2.status, DONE)
self.assertEqual(svc3.status, DONE)
self.assertEqual(svc2.status, DONE)
self.assertEqual(grp1.status, DONE)
self.assertEqual(svc1.status, DONE)
self.assertEqual(group_init.status, DONE)
示例2: test_set_algo_reversed
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import algo_reversed [as 别名]
def test_set_algo_reversed(self):
'''Test updates dependencies in changing the reversed flag'''
group = ServiceGroup('group')
self.assertTrue(group._source.has_child_dep('group'))
self.assertFalse(group._sink.has_parent_dep('group'))
group.algo_reversed = True
self.assertFalse(group._source.has_child_dep('group'))
self.assertTrue(group._sink.has_parent_dep('group'))
group.algo_reversed = False
self.assertTrue(group._source.has_child_dep('group'))
self.assertFalse(group._sink.has_parent_dep('group'))
示例3: test_prepare_group_subservice_reverse
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import algo_reversed [as 别名]
def test_prepare_group_subservice_reverse(self):
'''Test prepare reverse group with an internal dependency.'''
group = ServiceGroup('GROUP')
group.algo_reversed = True
subserv = Service('SUB1')
subserv.algo_reversed = True
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)
示例4: test_run_stop_on_group
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import algo_reversed [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)
示例5: test_prepare_empty_group_reverse
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import algo_reversed [as 别名]
def test_prepare_empty_group_reverse(self):
'''Test method prepare reverse with a single empty ServiceGroup.'''
group = ServiceGroup('GROUP')
group.algo_reversed = True
group.run('start')
self.assertEqual(group.status, MISSING)