From b8772d79ef802ba0f0742f4bdd0ed9ff03327d4b Mon Sep 17 00:00:00 2001 From: Volodymyr Shypyguzov Date: Wed, 20 Apr 2016 10:11:03 +0300 Subject: [PATCH] Fix haproxy check commands +Change command to point at correct pid file location +Refactor code in favor to ssh_manager Change-Id: I3968d49e017649a9efad5e5c5de236afe1a5b137 Closes-Bug: #1564903 Implements blueprint sshmanager-integration (cherry picked from commit f9f7cef2572259c0cc0a310d23eafa9aa29e8868) --- .../tests_strength/test_failover_base.py | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/fuelweb_test/tests/tests_strength/test_failover_base.py b/fuelweb_test/tests/tests_strength/test_failover_base.py index a2d7a5e8f..af835ae30 100644 --- a/fuelweb_test/tests/tests_strength/test_failover_base.py +++ b/fuelweb_test/tests/tests_strength/test_failover_base.py @@ -385,22 +385,28 @@ class TestHaFailoverBase(TestBasic): self.__class__.__name__) n_ctrls = self.fuel_web.get_nailgun_cluster_nodes_by_roles( cluster_id, ['controller']) - d_ctrls = self.fuel_web.get_devops_nodes_by_nailgun_nodes(n_ctrls) - for devops_node in d_ctrls: - with self.fuel_web.get_ssh_for_node(devops_node.name) as remote: - remote.check_call('kill -9 $(pidof haproxy)') + def haproxy_started(ip): + pid_path = '/var/run/resource-agents/ns_haproxy/ns_haproxy.pid' + 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(): - ret = remote.execute( - '[ -f /var/run/haproxy.pid ] && ' - '[ "$(ps -p $(cat /var/run/haproxy.pid) -o pid=)" == ' - '"$(pidof haproxy)" ]' - ) - return ret['exit_code'] == 0 - - wait(haproxy_started, timeout=20) - assert_true(haproxy_started(), 'haproxy restarted') + for nailgun_node in n_ctrls: + ip = nailgun_node['ip'] + cmd = 'kill -9 $(pidof haproxy)' + self.ssh_manager.execute_on_remote( + ip, + cmd=cmd) + wait(lambda: haproxy_started(ip), + timeout=20, + timeout_msg='Waiting 20 sec for haproxy timed out') + assert_true(haproxy_started(ip), 'haproxy was not started') cluster_id = self.fuel_web.client.get_cluster_id( self.__class__.__name__)