Fix ironic check_service_availability
run_ssh_cmd_with_exit_code mark test as failed as soon it executes command on node where process is not running. As result when process is not running on first node test is failed, and other nodes are not checked. check_service_availability should suceed only if process is running on specified number of nodes. ironic-api should be launched on all controllers. ironic-conductor should be launched on all Ironic nodes. nova-compute should be launched only on single controller. Change-Id: I5429f079d903e51cbe786548126af07bc140aee0
This commit is contained in:
parent
1bccfe65f6
commit
894e3e8cd4
|
@ -19,6 +19,7 @@ import traceback
|
|||
from fuel_health import nmanager
|
||||
import fuel_health.test
|
||||
|
||||
from fuel_health.common.ssh import Client as SSHClient
|
||||
from ironicclient.common import utils
|
||||
from ironicclient import exc as ironic_exc
|
||||
|
||||
|
@ -68,22 +69,38 @@ class IronicTest(nmanager.SanityChecksTest):
|
|||
n = self.ironic_client.node.get(node.uuid)
|
||||
return n
|
||||
|
||||
def check_service_availability(self, nodes, cmd, expected, timeout=30):
|
||||
def check_service_availability(self, nodes, cmd, expected,
|
||||
succeed_nodes=1):
|
||||
"""Check running processes on nodes.
|
||||
|
||||
At least one controller should run ironic-api process.
|
||||
At least one Ironic node should run ironic-conductor process.
|
||||
At least one controller should run nova-compute process.
|
||||
Check that output from specified command contain expected part.
|
||||
|
||||
:param nodes: List of nodes to check command.
|
||||
:param cmd: Command that is executed.
|
||||
:param expected: Expected output.
|
||||
:param succeed_nodes: Indicates if check should succeed on specified
|
||||
number of nodes.
|
||||
"""
|
||||
def check_services():
|
||||
succeed_count = 0
|
||||
for node in nodes:
|
||||
output = self.run_ssh_cmd_with_exit_code(node, cmd)
|
||||
LOG.debug(output)
|
||||
if expected in output:
|
||||
return True
|
||||
return False
|
||||
remote = SSHClient(node, self.usr, self.pwd,
|
||||
key_filename=self.key,
|
||||
timeout=self.timeout)
|
||||
try:
|
||||
output = remote.exec_command(cmd)
|
||||
LOG.debug(output)
|
||||
if expected in output:
|
||||
succeed_count += 1
|
||||
except Exception:
|
||||
pass
|
||||
if succeed_count == succeed_nodes:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
if not fuel_health.test.call_until_true(check_services, 30, timeout):
|
||||
if not fuel_health.test.call_until_true(check_services, 30,
|
||||
self.timeout):
|
||||
self.fail('Failed to discover service {0} '
|
||||
'within specified timeout'.format(expected))
|
||||
return True
|
||||
|
|
|
@ -45,9 +45,9 @@ class IronicSanityTests(ironicmanager.IronicTest):
|
|||
Target component: Ironic
|
||||
|
||||
Scenario:
|
||||
1. Check that ironic-api service is running on controller node.
|
||||
2. Check that ironic-conductor service is running on Ironic node.
|
||||
3. Check that nova-compute service is running on controller node.
|
||||
1. Check that ironic-api is running on all controllers.
|
||||
2. Check that ironic-conductor is running on all Ironic nodes.
|
||||
3. Check that nova-compute is running on single controller node.
|
||||
Duration: 60 s.
|
||||
Deployment tags: Ironic
|
||||
Available since release: liberty-9.0
|
||||
|
@ -59,14 +59,14 @@ class IronicSanityTests(ironicmanager.IronicTest):
|
|||
fail_msg = 'Ironic-api service is not running.'
|
||||
action = 'checking ironic-api service'
|
||||
self.verify(60, self.check_service_availability, 1, fail_msg, action,
|
||||
self.controllers, cmd, expected)
|
||||
self.controllers, cmd, expected, len(self.controllers))
|
||||
# Step 2
|
||||
expected = u'/usr/bin/ironic-conductor'
|
||||
cmd = 'pgrep -la ironic'
|
||||
fail_msg = 'Ironic-conductor service is not running.'
|
||||
action = 'checking ironic-conductor service'
|
||||
self.verify(60, self.check_service_availability, 2, fail_msg, action,
|
||||
self.conductors, cmd, expected)
|
||||
self.conductors, cmd, expected, len(self.conductors))
|
||||
# Step 3
|
||||
expected = u'/usr/bin/nova-compute'
|
||||
cmd = 'pgrep -la nova-compute'
|
||||
|
|
Loading…
Reference in New Issue