Merge "Wait for target status in remote_service_action"
This commit is contained in:
commit
c5236dad0d
@ -223,12 +223,23 @@ def interface_state_set(client, interface, state):
|
|||||||
path=shell_path, interface=interface, state=state))
|
path=shell_path, interface=interface, state=state))
|
||||||
|
|
||||||
|
|
||||||
def remote_service_action(client, service, action):
|
def remote_service_action(client, service, action, target_state):
|
||||||
cmd = "sudo systemctl {action} {service}".format(
|
cmd = "sudo systemctl {action} {service}".format(
|
||||||
action=action, service=service)
|
action=action, service=service)
|
||||||
LOG.debug("Running '{}' on {}".format(cmd, client.host))
|
LOG.debug("Running '{}' on {}".format(cmd, client.host))
|
||||||
client.exec_command(cmd)
|
client.exec_command(cmd)
|
||||||
time.sleep(5)
|
common_utils.wait_until_true(
|
||||||
|
lambda: remote_service_check_state(client, service, target_state),
|
||||||
|
timeout=30, sleep=5,
|
||||||
|
exception=RuntimeError("Service failed to reach the required "
|
||||||
|
"state '{}'".format(target_state)))
|
||||||
|
|
||||||
|
|
||||||
|
def remote_service_check_state(client, service, state):
|
||||||
|
cmd = ("sudo systemctl is-active {service} "
|
||||||
|
"| grep -w {state} || true".format(service=service, state=state))
|
||||||
|
output = client.exec_command(cmd).strip()
|
||||||
|
return (state in output)
|
||||||
|
|
||||||
|
|
||||||
# NOTE(mblue): Please use specific regex to avoid dismissing various issues
|
# NOTE(mblue): Please use specific regex to avoid dismissing various issues
|
||||||
|
@ -300,10 +300,12 @@ class L3haOvnTest(L3haOvnCommon):
|
|||||||
remote_service = 'ovs-vswitchd.service'
|
remote_service = 'ovs-vswitchd.service'
|
||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
utils.remote_service_action, node_client,
|
utils.remote_service_action, node_client,
|
||||||
remote_service, constants.ACTION_START)
|
remote_service, constants.ACTION_START, 'active')
|
||||||
utils.remote_service_action(
|
utils.remote_service_action(
|
||||||
node_client, remote_service, constants.ACTION_STOP)
|
node_client, remote_service, constants.ACTION_STOP,
|
||||||
|
target_state='inactive')
|
||||||
self.verify_routing_via_chassis(self.chassis_list[1])
|
self.verify_routing_via_chassis(self.chassis_list[1])
|
||||||
utils.remote_service_action(
|
utils.remote_service_action(
|
||||||
node_client, remote_service, constants.ACTION_START)
|
node_client, remote_service, constants.ACTION_START,
|
||||||
|
target_state='active')
|
||||||
self.verify_routing_via_chassis(self.chassis_list[0])
|
self.verify_routing_via_chassis(self.chassis_list[0])
|
||||||
|
Loading…
Reference in New Issue
Block a user