diff --git a/infrared_plugin/roles/tobiko-ir-deploy/tasks/main.yaml b/infrared_plugin/roles/tobiko-ir-deploy/tasks/main.yaml index 5556715fb..28f26e85c 100644 --- a/infrared_plugin/roles/tobiko-ir-deploy/tasks/main.yaml +++ b/infrared_plugin/roles/tobiko-ir-deploy/tasks/main.yaml @@ -59,3 +59,10 @@ - name: "show last change details" 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 diff --git a/tobiko/tests/faults/ha/test_cloud_recovery.py b/tobiko/tests/faults/ha/test_cloud_recovery.py index a8c901a94..e29e341e9 100644 --- a/tobiko/tests/faults/ha/test_cloud_recovery.py +++ b/tobiko/tests/faults/ha/test_cloud_recovery.py @@ -8,6 +8,7 @@ from tobiko.tripleo import containers from tobiko.tripleo import nova from tobiko.tripleo import neutron from tobiko.tripleo import undercloud +from tobiko.tripleo import validations 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.assert_all_tripleo_containers_running() containers.assert_equal_containers_state() + validations.run_post_deployment_validations() # check vm create with ssh and ping checks diff --git a/tobiko/tripleo/validations.py b/tobiko/tripleo/validations.py new file mode 100644 index 000000000..75ece15d9 --- /dev/null +++ b/tobiko/tripleo/validations.py @@ -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')