Merge "Fix haproxy check commands" into stable/mitaka

This commit is contained in:
Jenkins 2016-05-03 11:53:27 +00:00 committed by Gerrit Code Review
commit 0744ad1867

View File

@ -385,22 +385,28 @@ class TestHaFailoverBase(TestBasic):
self.__class__.__name__) self.__class__.__name__)
n_ctrls = self.fuel_web.get_nailgun_cluster_nodes_by_roles( n_ctrls = self.fuel_web.get_nailgun_cluster_nodes_by_roles(
cluster_id, ['controller']) cluster_id, ['controller'])
d_ctrls = self.fuel_web.get_devops_nodes_by_nailgun_nodes(n_ctrls)
for devops_node in d_ctrls: def haproxy_started(ip):
with self.fuel_web.get_ssh_for_node(devops_node.name) as remote: pid_path = '/var/run/resource-agents/ns_haproxy/ns_haproxy.pid'
remote.check_call('kill -9 $(pidof haproxy)') cmd = '[ -f {pid_path} ] && ' \
'[ "$(ps -p $(cat {pid_path}) -o pid=)" ' \
'== "$(pidof haproxy)" ]'.format(pid_path=pid_path)
result = self.ssh_manager.execute_on_remote(
ip,
cmd,
raise_on_assert=False)
return result['exit_code'] == 0
def haproxy_started(): for nailgun_node in n_ctrls:
ret = remote.execute( ip = nailgun_node['ip']
'[ -f /var/run/haproxy.pid ] && ' cmd = 'kill -9 $(pidof haproxy)'
'[ "$(ps -p $(cat /var/run/haproxy.pid) -o pid=)" == ' self.ssh_manager.execute_on_remote(
'"$(pidof haproxy)" ]' ip,
) cmd=cmd)
return ret['exit_code'] == 0 wait(lambda: haproxy_started(ip),
timeout=20,
wait(haproxy_started, timeout=20) timeout_msg='Waiting 20 sec for haproxy timed out')
assert_true(haproxy_started(), 'haproxy restarted') assert_true(haproxy_started(ip), 'haproxy was not started')
cluster_id = self.fuel_web.client.get_cluster_id( cluster_id = self.fuel_web.client.get_cluster_id(
self.__class__.__name__) self.__class__.__name__)