Merge "Ceph_check operator test to support dedicated and centralized with error code"

This commit is contained in:
Jenkins 2016-09-01 01:11:39 +00:00 committed by Gerrit Code Review
commit f19dc487d4
2 changed files with 33 additions and 23 deletions

View File

@ -146,6 +146,9 @@ class TestManager(object):
if result[0] == 200: if result[0] == 200:
Test['state'] = 'success' Test['state'] = 'success'
Test['result'] = textwrap.fill(str(result[1]), 40) Test['result'] = textwrap.fill(str(result[1]), 40)
elif result[0] == 300:
Test['state'] = 'skipped'
Test['result'] = textwrap.fill(str(result[1]), 40)
else: else:
Test['state'] = 'failed' Test['state'] = 'failed'
Test['result'] = textwrap.fill(str(result[1]), 40) Test['result'] = textwrap.fill(str(result[1]), 40)

View File

@ -196,34 +196,41 @@ class operator_scenario(base.Scenario):
@base.scenario(admin_only=False, operator=True) @base.scenario(admin_only=False, operator=True)
def ceph_check(self): def ceph_check(self):
self.load() self.load()
cmd = (r"ceph -f json status") storage_nodes_from_ansible_config = [node.name.lower(
) for node in self.os_node_info_obj.get_host_list()
if node.role == "block_storage"]
is_containerized = cfg.CONF.operator_test.containerized if storage_nodes_from_ansible_config:
if is_containerized: cmd = (r"ceph -f json status")
ceph_container = cfg.CONF.operator_test.ceph_container is_containerized = cfg.CONF.operator_test.containerized
cmd = ("docker exec %s %s" % (ceph_container, cmd)) if is_containerized:
ceph_container = cfg.CONF.operator_test.ceph_container
cmd = ("docker exec %s %s" % (ceph_container, cmd))
out = self.ans_runner.execute(cmd, roles=['controller']) out = self.ans_runner.execute(cmd, roles=['controller'])
results, failed_hosts = self.ans_runner.validate_results(out) results, failed_hosts = self.ans_runner.validate_results(out)
if results['status'] is 'PASS': if results['status'] is 'PASS':
ceph_status = results['contacted'][ ceph_status = results['contacted'][
results['contacted'].keys()[0]]['stdout'] results['contacted'].keys()[0]]['stdout']
ceph_status_string = ceph_status.replace('\n', '') ceph_status_string = ceph_status.replace('\n', '')
ceph_json = json.loads(ceph_status_string) ceph_json = json.loads(ceph_status_string)
overall_status = ceph_json['health']['overall_status'] overall_status = ceph_json['health']['overall_status']
num_of_osd = ceph_json['osdmap']['osdmap']['num_osds'] num_of_osd = ceph_json['osdmap']['osdmap']['num_osds']
num_up_osds = ceph_json['osdmap']['osdmap']['num_up_osds'] num_up_osds = ceph_json['osdmap']['osdmap']['num_up_osds']
if overall_status == 'HEALTH_OK': if overall_status == 'HEALTH_OK':
return (200, "Overall Status = %s, Cluster status = %s/%s" % return (200, "Overall Status = %s, "
(overall_status, num_up_osds, num_of_osd)) "Cluster status = %s/%s" %
else: (overall_status, num_up_osds, num_of_osd))
return (404, "Overall Status = %s, Cluster status = %s/%s" % else:
(overall_status, num_up_osds, num_of_osd)) return (404, "Overall Status = %s, "
"Cluster status = %s/%s" %
(overall_status, num_up_osds, num_of_osd))
else: else:
return (404, ("Ceph cluster Test Failed: %s" % return (300, ("Ceph cluster test skipped "
results['status_message']), []) "as no dedicated storage found"))
@base.scenario(admin_only=False, operator=True) @base.scenario(admin_only=False, operator=True)
def node_check(self): def node_check(self):