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


Python HealthChecker.health_check方法代码示例

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


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

示例1: test_no_checks

# 需要导入模块: from otter.tap.api import HealthChecker [as 别名]
# 或者: from otter.tap.api.HealthChecker import health_check [as 别名]
 def test_no_checks(self):
     """
     If there are no checks, HealthChecker returns healthy
     """
     checker = HealthChecker(self.clock)
     d = checker.health_check()
     self.assertEqual(self.successResultOf(d), {'healthy': True})
开发者ID:rackerlabs,项目名称:otter,代码行数:9,代码来源:test_api.py

示例2: test_invalid_check

# 需要导入模块: from otter.tap.api import HealthChecker [as 别名]
# 或者: from otter.tap.api.HealthChecker import health_check [as 别名]
 def test_invalid_check(self):
     """
     If an invalid check is added, its health is unhealthy
     """
     checker = HealthChecker(self.clock, {'invalid': None})
     d = checker.health_check()
     self.assertEqual(self.successResultOf(d), {
         'healthy': False,
         'invalid': {
             'healthy': False,
             'details': {'reason': mock.ANY}
         }
     })
开发者ID:rackerlabs,项目名称:otter,代码行数:15,代码来源:test_api.py

示例3: test_synchronous_health_check

# 需要导入模块: from otter.tap.api import HealthChecker [as 别名]
# 或者: from otter.tap.api.HealthChecker import health_check [as 别名]
 def test_synchronous_health_check(self):
     """
     Synchronous health checks are supported
     """
     checker = HealthChecker(self.clock, {'sync': mock.Mock(return_value=(True, {}))})
     d = checker.health_check()
     self.assertEqual(self.successResultOf(d), {
         'healthy': True,
         'sync': {
             'healthy': True,
             'details': {}
         }
     })
开发者ID:zancas,项目名称:otter,代码行数:15,代码来源:test_api.py

示例4: test_check_failure

# 需要导入模块: from otter.tap.api import HealthChecker [as 别名]
# 或者: from otter.tap.api.HealthChecker import health_check [as 别名]
 def test_check_failure(self):
     """
     If a check raises an exception, its health is unhealthy
     """
     checker = HealthChecker(self.clock, {'fail': mock.Mock(side_effect=Exception)})
     d = checker.health_check()
     self.assertEqual(self.successResultOf(d), {
         'healthy': False,
         'fail': {
             'healthy': False,
             'details': {'reason': matches(Contains('Exception'))}
         }
     })
开发者ID:zancas,项目名称:otter,代码行数:15,代码来源:test_api.py

示例5: test_check_is_timed_out

# 需要导入模块: from otter.tap.api import HealthChecker [as 别名]
# 或者: from otter.tap.api.HealthChecker import health_check [as 别名]
 def test_check_is_timed_out(self):
     """
     Each health check is timed out after 15 seconds
     """
     checker = HealthChecker(
         self.clock, {'a': mock.Mock(return_value=defer.Deferred()),
                      'b': mock.Mock(return_value=defer.succeed((True, {})))})
     d = checker.health_check()
     self.assertNoResult(d)
     self.clock.advance(16)
     r = self.successResultOf(d)
     self.assertEqual(r, {
         'healthy': False,
         'a': {'healthy': False, 'details': {'reason': mock.ANY}},
         'b': {'healthy': True, 'details': {}}
     })
     self.assertIn('a health check timed out', r['a']['details']['reason'])
开发者ID:zancas,项目名称:otter,代码行数:19,代码来源:test_api.py

示例6: test_one_failed_health_fails_overall_health

# 需要导入模块: from otter.tap.api import HealthChecker [as 别名]
# 或者: from otter.tap.api.HealthChecker import health_check [as 别名]
 def test_one_failed_health_fails_overall_health(self):
     """
     All health checks must pass in order for the main check to be healthy
     """
     checker = HealthChecker(self.clock, {
         'healthy_thing': mock.Mock(return_value=(True, {})),
         'unhealthy_thing': mock.Mock(return_value=(False, {}))
     })
     d = checker.health_check()
     self.assertEqual(self.successResultOf(d), {
         'healthy': False,
         'healthy_thing': {
             'healthy': True,
             'details': {}
         },
         'unhealthy_thing': {
             'healthy': False,
             'details': {}
         }
     })
开发者ID:rackerlabs,项目名称:otter,代码行数:22,代码来源:test_api.py

示例7: test_all_health_passes_means_overall_health_passes

# 需要导入模块: from otter.tap.api import HealthChecker [as 别名]
# 或者: from otter.tap.api.HealthChecker import health_check [as 别名]
 def test_all_health_passes_means_overall_health_passes(self):
     """
     When all health checks pass the overall check is healthy
     """
     checker = HealthChecker(self.clock, dict([
         ("check{0}".format(i), mock.Mock(return_value=(True, {})))
         for i in range(3)
     ]))
     d = checker.health_check()
     self.assertEqual(self.successResultOf(d), {
         'healthy': True,
         'check0': {
             'healthy': True,
             'details': {}
         },
         'check1': {
             'healthy': True,
             'details': {}
         },
         'check2': {
             'healthy': True,
             'details': {}
         }
     })
开发者ID:rackerlabs,项目名称:otter,代码行数:26,代码来源:test_api.py


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