当前位置: 首页>>代码示例>>Python>>正文


Python Action.add_dep方法代码示例

本文整理汇总了Python中MilkCheck.Engine.Action.Action.add_dep方法的典型用法代码示例。如果您正苦于以下问题:Python Action.add_dep方法的具体用法?Python Action.add_dep怎么用?Python Action.add_dep使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MilkCheck.Engine.Action.Action的用法示例。


在下文中一共展示了Action.add_dep方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_run_action_with_failed_subaction

# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import add_dep [as 别名]
 def test_run_action_with_failed_subaction(self):
     """Test action running a failed sub action (start->status)"""
     serv = Service('BASE')
     act_start = Action('start', command='/bin/true')
     act_status_fail = Action('status', command='/bin/false')
     act_start.add_dep(target=act_status_fail)
     serv.add_actions(act_start, act_status_fail)
     serv.run('start')
     self.assertEqual(serv.status, DONE)
     self.assertTrue(act_start.duration)
     self.assertTrue(act_status_fail.duration)
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:13,代码来源:ServiceTest.py

示例2: test_prepare_dep_failed

# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import add_dep [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)
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:14,代码来源:ActionTest.py

示例3: test_prepare_dep_success

# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import add_dep [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)
开发者ID:mdlx,项目名称:milkcheck,代码行数:14,代码来源:ActionTest.py

示例4: test_run_multiple_action_with_subaction

# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import add_dep [as 别名]
    def test_run_multiple_action_with_subaction(self):
        """Test with multiple actions running a sub action (start-> status)"""
        nemesis = Service("NEMESIS")
        zombie_one = Service("ZOMBIE_ONE")
        zombie_two = Service("ZOMBIE_TWO")
        hive = Service("THE_HIVE")

        act_start1 = Action("start", command="/bin/true")
        act_start2 = Action("start", command="/bin/false")
        act_start3 = Action("start", command="/bin/true")
        act_start4 = Action("start", command="/bin/true")
        act_sta = Action("status", command="/bin/true")
        act_sta_fai = Action("status", command="/bin/false")

        act_start2.add_dep(act_sta_fai)
        act_start4.add_dep(act_sta)

        nemesis.add_action(act_start1)
        zombie_one.add_actions(act_start2, act_sta_fai)
        zombie_two.add_action(act_start3)
        hive.add_actions(act_start4, act_sta)

        zombie_one.add_dep(hive)
        zombie_two.add_dep(hive)
        nemesis.add_dep(zombie_one)
        nemesis.add_dep(zombie_two)

        nemesis.run("start")
        self.assertEqual(hive.status, DONE)
        self.assertEqual(zombie_one.status, ERROR)
        self.assertEqual(zombie_two.status, DONE)
        self.assertEqual(nemesis.status, DEP_ERROR)
        self.assertFalse(act_start1.duration)
        self.assertTrue(act_start2.duration)
        self.assertTrue(act_start3.duration)
        self.assertFalse(act_start4.duration)
        self.assertTrue(act_sta_fai.duration)
        self.assertTrue(act_sta.duration)
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:40,代码来源:ServiceTest.py

示例5: fromdict

# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import add_dep [as 别名]
    def fromdict(self, svcdict):
        """Populate service attributes from dict."""
        BaseEntity.fromdict(self, svcdict)

        if "actions" in svcdict:
            dependencies = {}
            actions = {}
            for names, props in svcdict["actions"].items():
                for name in NodeSet(names):
                    action = Action(name)
                    action.fromdict(props)

                    actions[name] = action
                    dependencies[name] = props.get("check", [])

            for action in actions.values():
                for dep in dependencies[action.name]:
                    action.add_dep(actions[dep])
                self.add_action(action)

        # Inherits properies between service and actions
        for action in self.iter_actions():
            action.inherits_from(self)
开发者ID:pombredanne,项目名称:milkcheck,代码行数:25,代码来源:Service.py

示例6: test_prepare_actions_graph_with_errors

# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import add_dep [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)
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:23,代码来源:ActionTest.py

示例7: test_prepare_actions_graph

# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import add_dep [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)
开发者ID:mdlx,项目名称:milkcheck,代码行数:23,代码来源:ActionTest.py


注:本文中的MilkCheck.Engine.Action.Action.add_dep方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。