本文整理汇总了Python中MilkCheck.Engine.Action.Action.run方法的典型用法代码示例。如果您正苦于以下问题:Python Action.run方法的具体用法?Python Action.run怎么用?Python Action.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MilkCheck.Engine.Action.Action
的用法示例。
在下文中一共展示了Action.run方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_action_with_variables
# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import run [as 别名]
def test_action_with_variables(self):
"""Test variables in action command"""
cmd = 'echo %([ "%VAR1" != "" ] && echo "-x %VAR1")'
action = Action("start", command=cmd)
service = Service("TEST")
service.add_actions(action)
service.add_var("VAR1", "foo")
action.run()
self.assertEqual(action.worker.command, "echo -x foo")
示例2: test_failed_nodes
# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import run [as 别名]
def test_failed_nodes(self):
"""failed nodes are backup"""
action = Action('start', command='/bin/false', target=HOSTNAME)
service = Service('test')
service.add_actions(action)
action.run()
self.assertEqual(action.failed_nodes, NodeSet(HOSTNAME))
self.assertEqual(action.status, ERROR)
# This is propagated to action service
self.assertEqual(service.failed_nodes, action.failed_nodes)
示例3: test_action_with_variables
# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import run [as 别名]
def test_action_with_variables(self):
"""Test variables in action command"""
cmd = 'echo %([ "%VAR1" != "" ] && echo "-x %VAR1")'
action = Action('start', command=cmd)
service = Service('TEST')
service.add_actions(action)
service.add_var('VAR1', 'foo')
service.resolve_all()
action.run()
self.assertEqual(action.worker.command, 'echo -x foo')
示例4: test_schedule
# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import run [as 别名]
def test_schedule(self):
"""Test behaviour method schedule"""
a1 = Action(name="start", command="/bin/true")
a2 = Action(name="status", command="/bin/true", delay=1)
ser = Service("TEST")
ser.add_actions(a1, a2)
a1.run()
a2.run()
self.assertTrue(0 < a1.duration and a1.duration < 0.2)
self.assertTrue(0.9 < a2.duration and a2.duration < 1.2)
示例5: test_prepare_dep_failed
# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import run [as 别名]
def test_prepare_dep_failed(self):
"""Test prepare an action with a single failed dependency"""
a1 = Action('start', command='/bin/true')
a2 = Action('status', command='/bin/false')
ser = Service('TEST')
a1.add_dep(a2)
ser.add_actions(a1, a2)
a1.run()
self.assertEqual(a1.status, DONE)
self.assertTrue(a1.duration)
self.assertEqual(a2.status, ERROR)
self.assertTrue(a2.duration)
示例6: test_schedule
# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import run [as 别名]
def test_schedule(self):
"""Test behaviour method schedule"""
a1 = Action(name='start', command='/bin/true')
a2 = Action(name='status', command='/bin/true', delay=1)
ser = Service('TEST')
ser.add_actions(a1, a2)
a1.run()
a2.run()
self.assertTrue(0 < a1.duration and a1.duration <= 0.2,
"%.3f is not between 0 and 0.2" % a1.duration)
self.assertTrue(0.9 <= a2.duration and a2.duration <= 1.2,
"%.3f is not between 0.9 and 1.2" % a2.duration)
示例7: test_prepare_dep_success
# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import run [as 别名]
def test_prepare_dep_success(self):
"""Test prepare an action with a single successful dependency"""
a1 = Action("start", command="/bin/true")
a2 = Action("status", command="/bin/true")
ser = Service("TEST")
a1.add_dep(a2)
ser.add_actions(a1, a2)
a1.run()
self.assertEqual(a1.status, DONE)
self.assertFalse(a1.duration)
self.assertEqual(a2.status, DONE)
self.assertTrue(a2.duration)
示例8: test_prepare_actions_graph_with_errors
# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import run [as 别名]
def test_prepare_actions_graph_with_errors(self):
"""Test prepare an action graph with errors"""
a1 = Action('start', command='/bin/true')
a2 = Action('start_engine', command='/bin/true')
a3 = Action('start_gui', command='/bin/false')
a4 = Action('empty_home', command='/bin/false')
a1.add_dep(a2)
a1.add_dep(a3)
a2.add_dep(a4)
a3.add_dep(a4)
ser = Service('TEST')
ser.add_actions(a1, a2, a3, a4)
a1.run()
self.assertEqual(a1.status, DONE)
self.assertTrue(a1.duration)
self.assertEqual(a2.status, DONE)
self.assertTrue(a2.duration)
self.assertEqual(a3.status, ERROR)
self.assertTrue(a3.duration)
self.assertEqual(a4.status, ERROR)
self.assertTrue(a4.duration)
示例9: test_prepare_actions_graph
# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import run [as 别名]
def test_prepare_actions_graph(self):
"""Test prepare an action graph without errors"""
a1 = Action("start", command="/bin/true")
a2 = Action("start_engine", command="/bin/true")
a3 = Action("start_gui", command="/bin/true")
a4 = Action("empty_home", command="/bin/true")
a1.add_dep(a2)
a1.add_dep(a3)
a2.add_dep(a4)
a3.add_dep(a4)
ser = Service("TEST")
ser.add_actions(a1, a2, a3, a4)
a1.run()
self.assertEqual(a1.status, DONE)
self.assertFalse(a1.duration)
self.assertEqual(a2.status, DONE)
self.assertFalse(a2.duration)
self.assertEqual(a3.status, DONE)
self.assertFalse(a3.duration)
self.assertEqual(a4.status, DONE)
self.assertTrue(a4.duration)