Add tripleo validations (post-deployment group checks) to overcloud healthchecks

- This adds the v>=1.0 dependency of tripleo validations-lib (py library)
  and the validations lib ansible checks as master
- We are adding the post-deployment group to the overcloud checks
- For now the checks will be passive - won't fail the test but report
failures if the are found

Change-Id: I8f768219fb52c64616f155583b77d6948b54abee
This commit is contained in:
pinikomarov 2020-06-12 03:27:21 +03:00
parent 40cb580bd9
commit 352a8b5a47
3 changed files with 67 additions and 0 deletions

View File

@ -59,3 +59,10 @@
- name: "show last change details" - name: "show last change details"
debug: var=get_git_log.stdout_lines debug: var=get_git_log.stdout_lines
#we need also the master here so we are on the latest branch of validations
- name: "get validation-framework master checks"
git:
repo: https://github.com/openstack/tripleo-validations.git
dest: "{{ ansible_env.HOME }}/tripleo-validations"
version: master

View File

@ -8,6 +8,7 @@ from tobiko.tripleo import containers
from tobiko.tripleo import nova from tobiko.tripleo import nova
from tobiko.tripleo import neutron from tobiko.tripleo import neutron
from tobiko.tripleo import undercloud from tobiko.tripleo import undercloud
from tobiko.tripleo import validations
def overcloud_health_checks(passive_checks_only=False): def overcloud_health_checks(passive_checks_only=False):
@ -23,6 +24,7 @@ def overcloud_health_checks(passive_checks_only=False):
containers.list_node_containers.cache_clear() containers.list_node_containers.cache_clear()
containers.assert_all_tripleo_containers_running() containers.assert_all_tripleo_containers_running()
containers.assert_equal_containers_state() containers.assert_equal_containers_state()
validations.run_post_deployment_validations()
# check vm create with ssh and ping checks # check vm create with ssh and ping checks

View File

@ -0,0 +1,58 @@
from __future__ import absolute_import
from oslo_log import log
from validations_libs import validation_actions
from validations_libs import constants as v_consts
from tobiko.tripleo import overcloud
from tobiko.openstack import topology
from tobiko.shell import sh
LOG = log.getLogger(__name__)
v_consts.DEFAULT_VALIDATIONS_BASEDIR = '/home/stack/tripleo-validations'
def prepare_ansible_hosts_inventory():
"""create a hosts.yaml with ansible connections'
specifications for overcloud nodes"""
sshcu = topology.list_openstack_nodes(group='undercloud')[0].ssh_client
sh.execute('if [ ! -f /home/stack/hosts.yaml ]; then '
'source /home/stack/stackrc;tripleo-ansible-inventory '
'--ansible_ssh_user heat-admin --static-yaml-inventory '
'hosts.yaml;fi', ssh_client=sshcu, stdout=True)
def run_post_deployment_validations():
"""run validtion framework post-deploument validations
only if we're in a tripleo env"""
if overcloud.has_overcloud():
prepare_ansible_hosts_inventory()
failures = []
validates_object = validation_actions.ValidationActions(
validation_path='/home/stack/tripleo-validations/playbooks')
validations_result = validates_object.run_validations(
group='post-deployment',
quiet=False,
inventory='/home/stack/hosts.yaml')
for validation in validations_result:
if validation['Status'] == 'FAILED':
failures.append(
'failed validation: {}\n\n'.format(validation))
if failures:
LOG.info('Failed tripleo validations:\n {}'.format(failures))
# We should not fail over validations in the beginning we have to
# test run them, and handle false negatives.
# tobiko.fail(
# 'nova agents are unhealthy:\n{!s}', '\n'.join(failures))
# to list possible validations:
# validates_object.list_validations()
# single validation example
# validates_object.run_validations(
# validation_name='healthcheck-service-status',quiet=False,inventory='/home/stack/hosts.yaml')