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


Python Action.delay方法代码示例

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


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

示例1: setUp

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

示例2: test_retry_timeout

# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import delay [as 别名]
 def test_retry_timeout(self):
     """Test retry behaviour when timeout"""
     action = Action("start", command="/bin/sleep 0.5", timeout=0.1)
     action.delay = 0.1
     action.maxretry = 2
     service = Service("retry")
     service.add_action(action)
     service.run("start")
     self.assertEqual(action.tries, 3)
     self.assertEqual(action.status, TIMEOUT)
     self.assertTrue(0.6 < action.duration < 0.8, "%.3f is not between 0.6 and 0.8" % action.duration)
开发者ID:mdlx,项目名称:milkcheck,代码行数:13,代码来源:ActionTest.py

示例3: test_retry_error

# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import delay [as 别名]
 def test_retry_error(self):
     """Test retry behaviour when errors"""
     action = Action("start", command="/bin/false")
     action.delay = 0.1
     action.maxretry = 3
     service = Service("retry")
     service.add_action(action)
     service.run("start")
     self.assertEqual(action.tries, 4)
     self.assertEqual(action.status, ERROR)
     self.assertTrue(0.3 < action.duration < 0.5, "%.3f is not between 0.3 and 0.5" % action.duration)
开发者ID:mdlx,项目名称:milkcheck,代码行数:13,代码来源:ActionTest.py

示例4: test_retry_timeout

# 需要导入模块: from MilkCheck.Engine.Action import Action [as 别名]
# 或者: from MilkCheck.Engine.Action.Action import delay [as 别名]
 def test_retry_timeout(self):
     """Test retry behaviour when timeout"""
     action = Action('start', command='/bin/sleep 0.5', timeout=0.1)
     action.delay = 0.1
     action.maxretry = 2
     service = Service('retry')
     service.add_action(action)
     service.run('start')
     self.assertEqual(action.tries, 3)
     self.assertEqual(action.status, TIMEOUT)
     self.assertTrue(0.59 <= action.duration <= 0.8,
                     "%.3f is not between 0.59 and 0.8" % action.duration)
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:14,代码来源:ActionTest.py


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