本文整理汇总了Python中tests.util.services.Service类的典型用法代码示例。如果您正苦于以下问题:Python Service类的具体用法?Python Service怎么用?Python Service使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Service类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: Daemon
class Daemon(object):
"""Starts a daemon."""
def __init__(self, alternate_path=None, conf_file_name=None,
extra_cmds=None, service_path_root=None, service_path=None):
# The path to the daemon bin if the other one doesn't work.
self.alternate_path = alternate_path
self.extra_cmds = extra_cmds or []
# The name of a test config value which points to a conf file.
self.conf_file_name = conf_file_name
# The name of a test config value, which is inserted into the service_path.
self.service_path_root = service_path_root
# The first path to the daemon bin we try.
self.service_path = service_path or "%s"
def run(self):
# Print out everything to make it
print("Looking for config value %s..." % self.service_path_root)
print(CONFIG.values[self.service_path_root])
path = self.service_path % CONFIG.values[self.service_path_root]
print("Path = %s" % path)
if not os.path.exists(path):
path = self.alternate_path
if path is None:
fail("Could not find path to %s" % self.service_path_root)
conf_path = str(CONFIG.values[self.conf_file_name])
cmds = CONFIG.python_cmd_list() + [path] + self.extra_cmds + \
[conf_path]
print("Running cmds: %s" % cmds)
self.service = Service(cmds)
if not self.service.is_service_alive():
self.service.start()
开发者ID:Simplit-openapps,项目名称:trove-integration,代码行数:32,代码来源:initialize.py
示例2: KeystoneAll
class KeystoneAll(unittest.TestCase):
"""Starts the Keystone combined daemon."""
def setUp(self):
path = keystone_bin("keystone-all")
self.service = Service(python_cmd_list() + [path, "-c %s" % keystone_conf()])
def test_start(self):
if not self.service.is_service_alive():
self.service.start()
开发者ID:rnirmal,项目名称:reddwarf_lite-integration,代码行数:10,代码来源:initialize.py
示例3: Reaper
class Reaper(unittest.TestCase):
"""Starts the Reaper."""
def setUp(self):
self.service = Service(
python_cmd_list() + ["%s/bin/nova-reaper" % nova_code_root(), "--flagfile=%s" % nova_conf()]
)
def test_start(self):
if not self.service.is_service_alive():
self.service.start()
开发者ID:rnirmal,项目名称:reddwarf_lite-integration,代码行数:11,代码来源:initialize.py
示例4: Scheduler
class Scheduler(unittest.TestCase):
"""Starts the Scheduler Service."""
def setUp(self):
self.service = Service(
python_cmd_list() + ["%s/bin/nova-scheduler" % nova_code_root(), "--flagfile=%s" % nova_conf()]
)
def test_start(self):
if not either_web_service_is_up():
self.service.start()
开发者ID:rnirmal,项目名称:reddwarf_lite-integration,代码行数:11,代码来源:initialize.py
示例5: GlanceApi
class GlanceApi(unittest.TestCase):
"""Starts the Glance API."""
def setUp(self):
if os.path.exists("%sglance-api" % glance_bin_root()):
reg_path = "%sglance-api" % glance_bin_root()
else:
reg_path = "/usr/bin/glance-api"
self.service = Service(python_cmd_list() + [reg_path, glance_api_conf()])
def test_start(self):
if not either_web_service_is_up():
self.service.start()
开发者ID:rnirmal,项目名称:reddwarf_lite-integration,代码行数:13,代码来源:initialize.py
示例6: setUp
def setUp(self):
if os.path.exists("%sglance-registry" % glance_bin_root()):
reg_path = "%sglance-registry" % glance_bin_root()
else:
reg_path = "/usr/bin/glance-registry"
self.service = Service(python_cmd_list() +
[reg_path, glance_reg_conf()])
开发者ID:DJohnstone,项目名称:reddwarf_lite-integration,代码行数:7,代码来源:initialize.py
示例7: check_agent_path_is_correct
def check_agent_path_is_correct(self):
"""Make sure the agent binary listed in the config is correct."""
self.agent_bin = str(test_config.values["agent_bin"])
nova_conf = str(test_config.values["nova_conf"])
assert_true(path.exists(self.agent_bin),
"Agent not found at path: %s" % self.agent_bin)
self.agent = Service(cmd=[self.agent_bin, "--flagfile=%s" % nova_conf,
"--rabbit_reconnect_wait_time=1",
"--preset_instance_id=-99"])
开发者ID:TimSimpsonR,项目名称:reddwarf_lite-integration,代码行数:9,代码来源:amqp_restarts.py
示例8: run
def run(self):
# Print out everything to make it
print("Looking for config value %s..." % self.service_path_root)
print(CONFIG.values[self.service_path_root])
path = self.service_path % CONFIG.values[self.service_path_root]
print("Path = %s" % path)
if not os.path.exists(path):
path = self.alternate_path
if path is None:
fail("Could not find path to %s" % self.service_path_root)
conf_path = str(CONFIG.values[self.conf_file_name])
cmds = CONFIG.python_cmd_list() + [path] + self.extra_cmds + \
[conf_path]
print("Running cmds: %s" % cmds)
self.service = Service(cmds)
if not self.service.is_service_alive():
self.service.start()
开发者ID:Simplit-openapps,项目名称:trove-integration,代码行数:17,代码来源:initialize.py
示例9: setUp
def setUp(self):
self.service = Service(
python_cmd_list() + ["%s/bin/nova-reaper" % nova_code_root(), "--flagfile=%s" % nova_conf()]
)
开发者ID:rnirmal,项目名称:reddwarf_lite-integration,代码行数:4,代码来源:initialize.py
示例10: WhenAgentRunsAsRabbitGoesUpAndDown
class WhenAgentRunsAsRabbitGoesUpAndDown(object):
"""Tests the agent is ok when Rabbit
"""
def __init__(self):
self.rabbit = Rabbit()
self.send_after_reconnect_errors = 0
self.tolerated_send_errors = 0
@after_class
def stop_agent(self):
self.agent.stop()
def _send(self):
original_queue_count = self.rabbit.get_queue_items()
@time_out(5)
def send_msg_with_timeout():
self.rabbit.declare_queue(topic_name())
version = rpc.call(context.get_admin_context(),
topic_name(),
{"method": "version",
"args": {"package_name": "dpkg"}
})
return { "status":"good", "version": version }
try:
return send_msg_with_timeout()
except Exception as e:
# If the Python side works, we should at least see an item waiting
# in the queue.
# Whether we see this determines if the failure to send is Nova's
# fault or Sneaky Petes.
print("Error making RPC call: %s" % e)
print("Original queue count = %d, "
"current count = %d" % (original_queue_count,
self.rabbit.get_queue_items()))
# In the Kombu driver there is a bug where after restarting rabbit
# the first message to be sent fails with a broken pipe. So here we
# tolerate one such bug but no more.
if not isinstance(e, TimeoutError):
self.send_after_reconnect_errors += 1
if self.send_after_reconnect_errors > self.tolerated_send_errors:
fail("Exception while making RPC call: %s" % e)
if self.rabbit.get_queue_items() > original_queue_count:
return { "status":"bad", "blame":"agent"}
else:
return { "status":"bad", "blame":"host"}
def _send_allow_for_host_bug(self):
while True:
result = self._send()
if result['status'] == "good":
return result["version"]
else:
if result['blame'] == "agent":
fail("Nova Host put a message on the queue but the agent "
"never responded.")
@test
def check_agent_path_is_correct(self):
"""Make sure the agent binary listed in the config is correct."""
self.agent_bin = str(test_config.values["agent_bin"])
nova_conf = str(test_config.values["nova_conf"])
assert_true(path.exists(self.agent_bin),
"Agent not found at path: %s" % self.agent_bin)
self.agent = Service(cmd=[self.agent_bin, "--flagfile=%s" % nova_conf,
"--rabbit_reconnect_wait_time=1",
"--preset_instance_id=-99"])
@test(depends_on=[check_agent_path_is_correct])
@time_out(60)
def send_agent_a_message(self):
self.rabbit.start()
self.agent.start(time_out=30)
result = self._send()
print("RESULT:%s" % result)
assert_equal(result['status'], "good")
@test(depends_on=[send_agent_a_message])
@time_out(30)
def make_sure_we_can_identify_an_agent_failure(self):
# This is so confusing, but it has to be, so listen up:
# Nova code has issues sending messages so we either don't test this
# or make allowances for Kombu's bad behavior. This test runs before
# we start the agent and makes sure if Nova successfully sends a
# message and the agent never answers it this test can identify that
# and fail.
self.agent.stop()
result = self._send()
assert_equal(result['status'], 'bad')
assert_equal(result['blame'], 'agent')
@test(depends_on=[make_sure_we_can_identify_an_agent_failure])
def stop_rabbit(self):
if self.rabbit.is_alive:
self.rabbit.stop()
assert_false(self.rabbit.is_alive)
self.rabbit.reset()
@test(depends_on=[check_agent_path_is_correct, stop_rabbit])
#.........这里部分代码省略.........
开发者ID:TimSimpsonR,项目名称:reddwarf_lite-integration,代码行数:101,代码来源:amqp_restarts.py
注:本文中的tests.util.services.Service类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论