New operator: validator_run
This one runes validations calling the new "openstack validator run" CLI Change-Id: I15bd85a806b880d65e3bef65b9b75c3ba6532091
This commit is contained in:
committed by
Cédric Jeanneret (Tengu)
parent
7dd68a353c
commit
af117701a5
8
roles/tripleo_validator_run/defaults/main.yml
Normal file
8
roles/tripleo_validator_run/defaults/main.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
tripleo_validator_run_debug: false
|
||||||
|
tripleo_validator_run_plan:
|
||||||
|
tripleo_validator_run_workers:
|
||||||
|
tripleo_validator_run_extra_vars:
|
||||||
|
tripleo_validator_run_extra_vars_file:
|
||||||
|
tripleo_validator_run_validation: []
|
||||||
|
tripleo_validator_run_group: []
|
||||||
123
roles/tripleo_validator_run/molecule/default/converge.yml
Normal file
123
roles/tripleo_validator_run/molecule/default/converge.yml
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
collections:
|
||||||
|
- tripleo.operator
|
||||||
|
vars:
|
||||||
|
openstack_bin: echo
|
||||||
|
tripleo_os_cloud: undercloud
|
||||||
|
tripleo_validator_run_debug: true
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
- name: Check parameter "tripleo_validator_run_validation" as a list
|
||||||
|
include_role:
|
||||||
|
name: "tripleo_validator_run"
|
||||||
|
vars:
|
||||||
|
tripleo_validator_run_validation:
|
||||||
|
- 'check_disk_space'
|
||||||
|
- 'check_ram'
|
||||||
|
|
||||||
|
- name: Assert "tripleo_validator_run_validation"
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- tripleo_validator_run_result.stdout ==
|
||||||
|
"tripleo validator run --validation check_disk_space,check_ram"
|
||||||
|
|
||||||
|
- name: Check parameter "tripleo_validator_run_validation" as single element
|
||||||
|
include_role:
|
||||||
|
name: "tripleo_validator_run"
|
||||||
|
vars:
|
||||||
|
tripleo_validator_run_validation: 'check_disk_space'
|
||||||
|
|
||||||
|
- name: Assert "tripleo_validator_run_validation"
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- tripleo_validator_run_result.stdout ==
|
||||||
|
"tripleo validator run --validation check_disk_space"
|
||||||
|
|
||||||
|
- name: Check parameter "tripleo_validator_run_group" as a list
|
||||||
|
include_role:
|
||||||
|
name: "tripleo_validator_run"
|
||||||
|
vars:
|
||||||
|
tripleo_validator_run_group:
|
||||||
|
- 'no-op'
|
||||||
|
- 'prep'
|
||||||
|
|
||||||
|
- name: Assert "tripleo_validator_run_group"
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- tripleo_validator_run_result.stdout ==
|
||||||
|
"tripleo validator run --group no-op,prep"
|
||||||
|
|
||||||
|
- name: Check parameter "tripleo_validator_run_group" as single element
|
||||||
|
include_role:
|
||||||
|
name: "tripleo_validator_run"
|
||||||
|
vars:
|
||||||
|
tripleo_validator_run_group: 'no-op'
|
||||||
|
|
||||||
|
- name: Assert "tripleo_validator_run_group"
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- tripleo_validator_run_result.stdout ==
|
||||||
|
"tripleo validator run --group no-op"
|
||||||
|
|
||||||
|
- name: Check parameter "tripleo_validator_run_extra_vars_file"
|
||||||
|
include_role:
|
||||||
|
name: "tripleo_validator_run"
|
||||||
|
vars:
|
||||||
|
tripleo_validator_run_extra_vars_file: '/tmp/foo.json'
|
||||||
|
tripleo_validator_run_group: 'no-op'
|
||||||
|
|
||||||
|
- name: Assert "tripleo_validator_run_extra_vars_file"
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- tripleo_validator_run_result.stdout ==
|
||||||
|
"tripleo validator run --extra-vars-file /tmp/foo.json --group no-op"
|
||||||
|
|
||||||
|
- name: Check parameter "tripleo_validator_run_plan"
|
||||||
|
include_role:
|
||||||
|
name: "tripleo_validator_run"
|
||||||
|
vars:
|
||||||
|
tripleo_validator_run_plan: 'my-thing'
|
||||||
|
tripleo_validator_run_group: 'no-op'
|
||||||
|
|
||||||
|
- name: Assert "tripleo_validator_run_plan"
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- tripleo_validator_run_result.stdout ==
|
||||||
|
'tripleo validator run --plan my-thing --group no-op'
|
||||||
|
|
||||||
|
- name: Check parameter "tripleo_validator_run_workers"
|
||||||
|
include_role:
|
||||||
|
name: "tripleo_validator_run"
|
||||||
|
vars:
|
||||||
|
tripleo_validator_run_workers: 10
|
||||||
|
tripleo_validator_run_group: 'no-op'
|
||||||
|
|
||||||
|
- name: Assert "tripleo_validator_run_workers"
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- tripleo_validator_run_result.stdout ==
|
||||||
|
'tripleo validator run --workers 10 --group no-op'
|
||||||
|
|
||||||
|
- name: "Catch failed inclusion"
|
||||||
|
block:
|
||||||
|
- name: "Include tripleo_validator_run and fail"
|
||||||
|
include_role:
|
||||||
|
name: "tripleo_validator_run"
|
||||||
|
|
||||||
|
rescue:
|
||||||
|
- name: Clear host errors
|
||||||
|
meta: clear_host_errors
|
||||||
|
|
||||||
|
- name: Status message
|
||||||
|
debug:
|
||||||
|
msg: "Successfully caught failure"
|
||||||
|
|
||||||
|
- name: End play
|
||||||
|
meta: end_play
|
||||||
|
|
||||||
|
- name: Fail the test
|
||||||
|
fail:
|
||||||
|
msg: |
|
||||||
|
tripleo_validator_run didn't properly detect missing param.
|
||||||
19
roles/tripleo_validator_run/molecule/default/molecule.yml
Normal file
19
roles/tripleo_validator_run/molecule/default/molecule.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
driver:
|
||||||
|
name: delegated
|
||||||
|
options:
|
||||||
|
managed: false
|
||||||
|
ansible_connection_options:
|
||||||
|
ansible_connection: local
|
||||||
|
log: true
|
||||||
|
platforms:
|
||||||
|
- name: instance
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
scenario:
|
||||||
|
name: default
|
||||||
|
test_sequence:
|
||||||
|
- prepare
|
||||||
|
- syntax
|
||||||
|
- converge
|
||||||
|
- verify
|
||||||
8
roles/tripleo_validator_run/molecule/default/prepare.yml
Normal file
8
roles/tripleo_validator_run/molecule/default/prepare.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
- name: Prepare
|
||||||
|
hosts: all
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
- name: Include molecule prep
|
||||||
|
include_role:
|
||||||
|
name: test_molecule_prep
|
||||||
54
roles/tripleo_validator_run/tasks/main.yml
Normal file
54
roles/tripleo_validator_run/tasks/main.yml
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
---
|
||||||
|
- name: Fail if we do not pass validation or group
|
||||||
|
fail:
|
||||||
|
msg: "Please pass either tripleo_validator_run_validation or tripleo_validator_run_group"
|
||||||
|
when:
|
||||||
|
- tripleo_validator_run_validation | length == 0
|
||||||
|
- tripleo_validator_run_group | length == 0
|
||||||
|
|
||||||
|
- name: Fail if we pass validation and group
|
||||||
|
fail:
|
||||||
|
msg: "Please pass either tripleo_validator_run_validation OR tripleo_validator_run_group"
|
||||||
|
when:
|
||||||
|
- tripleo_validator_run_validation | length != 0
|
||||||
|
- tripleo_validator_run_group | length != 0
|
||||||
|
|
||||||
|
- name: Setup validator run facts
|
||||||
|
set_fact:
|
||||||
|
_validator_run_cmd: >-
|
||||||
|
{{ openstack_bin }} tripleo validator run
|
||||||
|
{{ tripleo_validator_run_plan | ternary('--plan ' ~ tripleo_validator_run_plan, '') }}
|
||||||
|
{{ tripleo_validator_run_workers | ternary('--workers ' ~ tripleo_validator_run_workers, '') }}
|
||||||
|
{{ tripleo_validator_run_extra_vars_file | ternary('--extra-vars-file ' ~ tripleo_validator_run_extra_vars_file, '') }}
|
||||||
|
{{ tripleo_validator_run_validation | ternary('--validation "${TRIPLEO_VALIDATOR_RUN_VALIDATION}"', '') }}
|
||||||
|
{{ tripleo_validator_run_group | ternary('--group "${TRIPLEO_VALIDATOR_RUN_GROUP}"', '') }}
|
||||||
|
_validator_run_env:
|
||||||
|
TRIPLEO_VALIDATOR_RUN_VALIDATION: >-
|
||||||
|
{%- if tripleo_validator_run_validation is string -%}
|
||||||
|
{{ tripleo_validator_run_validation }}
|
||||||
|
{%- else -%}
|
||||||
|
{{ tripleo_validator_run_validation | join(',') }}
|
||||||
|
{%- endif -%}
|
||||||
|
TRIPLEO_VALIDATOR_RUN_GROUP: >-
|
||||||
|
{%- if tripleo_validator_run_group is string -%}
|
||||||
|
{{ tripleo_validator_run_group }}
|
||||||
|
{%- else -%}
|
||||||
|
{{ tripleo_validator_run_group | join(',') }}
|
||||||
|
{%- endif -%}
|
||||||
|
|
||||||
|
- name: Show debug information
|
||||||
|
when:
|
||||||
|
tripleo_validator_run_debug|bool
|
||||||
|
block:
|
||||||
|
- name: Show validator run environment
|
||||||
|
debug:
|
||||||
|
var: _validator_run_env
|
||||||
|
- name: Show validator run command
|
||||||
|
debug:
|
||||||
|
var: _validator_run_cmd
|
||||||
|
|
||||||
|
- name: Run validation
|
||||||
|
shell: "{{ _validator_run_cmd }}" # noqa 305
|
||||||
|
environment: "{{ _validator_run_env }}"
|
||||||
|
register: tripleo_validator_run_result
|
||||||
|
changed_when: true
|
||||||
@@ -61,6 +61,7 @@
|
|||||||
- tripleo-operator-molecule-tripleo_undercloud_minion_install
|
- tripleo-operator-molecule-tripleo_undercloud_minion_install
|
||||||
- tripleo-operator-molecule-tripleo_undercloud_minion_upgrade
|
- tripleo-operator-molecule-tripleo_undercloud_minion_upgrade
|
||||||
- tripleo-operator-molecule-tripleo_undercloud_upgrade
|
- tripleo-operator-molecule-tripleo_undercloud_upgrade
|
||||||
|
- tripleo-operator-molecule-tripleo_validator_run
|
||||||
|
|
||||||
gate:
|
gate:
|
||||||
jobs:
|
jobs:
|
||||||
@@ -123,6 +124,7 @@
|
|||||||
- tripleo-operator-molecule-tripleo_undercloud_minion_install
|
- tripleo-operator-molecule-tripleo_undercloud_minion_install
|
||||||
- tripleo-operator-molecule-tripleo_undercloud_minion_upgrade
|
- tripleo-operator-molecule-tripleo_undercloud_minion_upgrade
|
||||||
- tripleo-operator-molecule-tripleo_undercloud_upgrade
|
- tripleo-operator-molecule-tripleo_undercloud_upgrade
|
||||||
|
- tripleo-operator-molecule-tripleo_validator_run
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: tripleo-operator-molecule-base
|
name: tripleo-operator-molecule-base
|
||||||
@@ -928,3 +930,17 @@
|
|||||||
parent: tripleo-operator-molecule-base
|
parent: tripleo-operator-molecule-base
|
||||||
vars:
|
vars:
|
||||||
tox_extra_args: tripleo_undercloud_upgrade
|
tox_extra_args: tripleo_undercloud_upgrade
|
||||||
|
|
||||||
|
- job:
|
||||||
|
files:
|
||||||
|
- ^roles/tripleo_validator_run/.*
|
||||||
|
- ^bindep.txt
|
||||||
|
- ^galaxy.yml
|
||||||
|
- ^requirements.txt
|
||||||
|
- ^setup.cfg
|
||||||
|
- ^test-requirements.txt
|
||||||
|
- ^tox.ini
|
||||||
|
name: tripleo-operator-molecule-tripleo_validator_run
|
||||||
|
parent: tripleo-operator-molecule-base
|
||||||
|
vars:
|
||||||
|
tox_extra_args: tripleo_validator_run
|
||||||
|
|||||||
Reference in New Issue
Block a user