• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python Service.Service类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_skip

 def test_skip(self):
     """Test skip method for services"""
     srv = Service('skipped')
     srv.add_action(Action('start', target=NodeSet('foo'),
                           command='/bin/true'))
     srv.skip()
     self.assertTrue(srv._actions['start'].to_skip())
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:7,代码来源:ServiceTest.py


示例2: test_fromdict1

 def test_fromdict1(self):
     '''Test instanciate a service from a dictionnary'''
     ser = Service('S1')
     ser.fromdict(
         {
             'desc': 'I am the service S1',
             'target': 'localhost',
             'variables':{
                 'var1': 'toto',
                 'var2': 'titi'
             },
             'actions':
             {
                 'start': {'cmd': '/bin/True'},
                 'stop': {'cmd': '/bin/True'}
             }
         }
     )
     self.assertTrue(ser)
     self.assertEqual(ser.name, 'S1')
     self.assertEqual(ser.desc, 'I am the service S1')
     self.assertEqual(ser.target, NodeSet('localhost'))
     self.assertEqual(len(ser.variables), 2)
     self.assertTrue('var1' in ser.variables)
     self.assertTrue('var2' in ser.variables)
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:25,代码来源:ServiceTest.py


示例3: test_fromdict2

 def test_fromdict2(self):
     '''
     Test instanciate a service from a dictionnary with dependant actions
     '''
     ser = Service('S1')
     ser.fromdict(
         {
             'desc': 'I am the service S1',
             'target': 'localhost',
             'actions':
             {
                 'start':
                 {
                     'check': ['status'],
                     'cmd': '/bin/True'
                 },
                 'stop': {'cmd': '/bin/True'},
                 'status': {'cmd': '/bin/True'}
             }
         }
     )
     self.assertTrue(ser)
     self.assertEqual(len(ser._actions), 3)
     self.assertTrue('start' in ser._actions)
     self.assertTrue('stop' in ser._actions)
     self.assertTrue('status' in ser._actions)
     self.assertTrue(ser._actions['start'].has_parent_dep('status'))
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:27,代码来源:ServiceTest.py


示例4: reset

 def reset(self):
     '''Reset values of attributes in order to perform multiple exec'''
     Service.reset(self)
     for service in self._subservices.values():
         service.reset()
     self._sink.reset()
     self._source.reset()
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:7,代码来源:ServiceGroup.py


示例5: setUp

    def setUp(self):
        '''
        Set up the graph of services within the service manager

        Graph
                                _ start
                   -- service1 /
                 -'             _ start
                  '-- service2 /
        '''

        CLICommon.setUp(self)

        # Service
        service1 = Service('service1')
        service1.desc = 'I am the service 1'
        service2 = Service('service2')
        service2.desc = 'I am the service 2'
        # Actions
        action = Action('start', command='/bin/true')
        action.inherits_from(service1)
        service1.add_action(action)

        service2.add_dep(target=service1)

        action = Action('start', command='/bin/true')
        action.inherits_from(service2)
        service2.add_action(action)

        # Register services within the manager
        self.manager.register_services(service1, service2)
开发者ID:mdlx,项目名称:milkcheck,代码行数:31,代码来源:CliTest.py


示例6: test_command_output_warning

    def test_command_output_warning(self):
        '''Test command line output with warning'''
        svc_warn = Service('service_failled')
        svc_warn.desc = 'I am the failled service'
        svc_ok = Service('service_ok')
        svc_ok.desc = 'I am the ok service'
        # Actions
        action = Action('warning', command='/bin/false')
        action.inherits_from(svc_warn)
        svc_warn.add_action(action)
        action = Action('warning', command='/bin/true')
        action.inherits_from(svc_ok)
        svc_ok.add_action(action)

        # Register services within the manager
        svc_ok.add_dep(target=svc_warn, sgth=REQUIRE_WEAK)
        self.manager.add_service(svc_warn)
        self.manager.add_service(svc_ok)

        self._output_check(['service_ok', 'warning'], RC_OK,
"""warning service_failled ran in 0.00 s
 > localhost exited with 1
service_failled - I am the failled service                        [  ERROR  ]
service_ok - I am the ok service                                  [    OK   ]
""")
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:25,代码来源:CliTest.py


示例7: test_local_variables

    def test_local_variables(self):
        """Test Action local variables"""
        action = Action("bar")
        self.assertEqual(action._resolve("I'm %ACTION"), "I'm bar")

        svc = Service("foo")
        svc.add_action(action)
        self.assertEqual(action._resolve("I'm %SERVICE.%ACTION"), "I'm foo.bar")
开发者ID:mdlx,项目名称:milkcheck,代码行数:8,代码来源:ActionTest.py


示例8: test_prepare_delayed_action

 def test_prepare_delayed_action(self):
     """Test prepare Service with a delayed action"""
     serv = Service('DELAYED_SERVICE')
     act = Action(name='start', command='/bin/true', delay=1)
     serv.add_action(act)
     serv.run('start')
     self.assertEqual(serv.status, DONE)
     self.assert_near(1.0, 0.3, act.duration)
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:8,代码来源:ServiceTest.py


示例9: test_local_variables

    def test_local_variables(self):
        '''Test Action local variables'''
        action = Action('bar')
        self.assertEqual(action._resolve("I'm %ACTION"), "I'm bar")

        svc = Service('foo')
        svc.add_action(action)
        self.assertEqual(action._resolve("I'm %SERVICE.%ACTION"), "I'm foo.bar")
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:8,代码来源:ActionTest.py


示例10: test_prepare_single_service

 def test_prepare_single_service(self):
     """Test prepare without dependencies between services."""
     serv_test = Service('test_service')
     ac_start = Action(name='start', command='/bin/true')
     serv_test.add_action(ac_start)
     serv_test.run('start')
     self.assertTrue(serv_test.origin)
     self.assertEqual(serv_test.status, DONE)
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:8,代码来源:ServiceTest.py


示例11: test_update_target

 def test_update_target(self):
     '''Test update of the target of an service'''
     serv = Service('A')
     act = Action('start', 'fortoy[5-10]', '/bin/true')
     serv.add_action(act)
     serv.update_target('aury[1-12]^fortoy[3-6]')
     self.assertTrue(serv.target == NodeSet('aury[1-12]^fortoy[3-6]'))
     self.assertTrue(act.target == NodeSet('aury[1-12]^fortoy[3-6]'))
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:8,代码来源:ServiceTest.py


示例12: test_nb_timeout_remote

 def test_nb_timeout_remote(self):
     """Test nb_timeout() method (remote mode)"""
     action = Action(name="start", target=HOSTNAME, command="sleep 3", timeout=0.5)
     service = Service("test_service")
     service.add_action(action)
     service.run("start")
     self.assertEqual(action.nb_timeout(), 1)
     self.assertEqual(action.status, TIMEOUT)
开发者ID:mdlx,项目名称:milkcheck,代码行数:8,代码来源:ActionTest.py


示例13: test_missing_group

 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)
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:8,代码来源:ServiceGroupTest.py


示例14: test_nb_errors_remote2

 def test_nb_errors_remote2(self):
     """Test the method nb_errors() with no error (remote)."""
     action = Action(name="test", target=HOSTNAME, command="/bin/true")
     service = Service("test_service")
     service.add_action(action)
     service.run("test")
     self.assertEqual(action.nb_errors(), 0)
     self.assertEqual(action.status, DONE)
开发者ID:mdlx,项目名称:milkcheck,代码行数:8,代码来源:ActionTest.py


示例15: test_action_with_variables

 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")
开发者ID:mdlx,项目名称:milkcheck,代码行数:9,代码来源:ActionTest.py


示例16: test_nb_timeout_local

 def test_nb_timeout_local(self):
     """Test nb_timeout() method (local)"""
     action = Action(name="start", command="sleep 3", timeout=0.3)
     service = Service("test_service")
     service.add_action(action)
     service.run("start")
     self.assertEqual(action.nb_errors(), 0)
     self.assertEqual(action.nb_timeout(), 1)
     self.assertEqual(action.status, TIMEOUT)
开发者ID:mdlx,项目名称:milkcheck,代码行数:9,代码来源:ActionTest.py


示例17: test_prepare_group_subservice

 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)
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:9,代码来源:ServiceGroupTest.py


示例18: test_nb_errors_remote2

 def test_nb_errors_remote2(self):
     """Test the method nb_errors() with no error (remote)."""
     action = Action(name='test', target=HOSTNAME, command='/bin/true')
     service = Service('test_service')
     service.add_action(action)
     service.run('test')
     self.assertEqual(action.nodes_error(), NodeSet())
     self.assertEqual(action.nb_errors(), 0)
     self.assertEqual(action.status, DONE)
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:9,代码来源:ActionTest.py


示例19: test_add_action

 def test_add_action(self):
     """Test add_action's behaviour."""
     service = Service('brutus')
     service.add_action(Action('start'))
     self.assertTrue(service.has_action('start'))
     self.assertRaises(ActionAlreadyReferencedError,
             service.add_action,Action('start'))
     self.assertRaises(TypeError,
             service.add_action,None)
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:9,代码来源:ServiceTest.py


示例20: test_perform_action

 def test_perform_action(self):
     """test perform an action without any delay"""
     action = Action("start", command="/bin/true")
     ser = Service("TEST")
     ser.add_action(action)
     ser.run("start")
     task_manager = action_manager_self()
     self.assertEqual(task_manager.tasks_done_count, 1)
     self.assertTrue(action.duration < 0.5, "Too long: %.2f > 0.5" % action.duration)
开发者ID:mdlx,项目名称:milkcheck,代码行数:9,代码来源:ActionTest.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ServiceGroup.ServiceGroup类代码示例发布时间:2022-05-24
下一篇:
Python BaseEntity.BaseEntity类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap