Browse Source

Use test_molecule_prep for tests and fix filters

Change-Id: I24ba107687ba4816366bfe12d97d4fa5563f1c49
changes/25/705325/3
Sagi Shnaidman 2 years ago
parent
commit
7cc1b60634
  1. 3
      roles/tripleo_container_image_prepare/defaults/main.yml
  2. 22
      roles/tripleo_container_image_prepare/molecule/default/molecule.yml
  3. 80
      roles/tripleo_container_image_prepare/molecule/default/playbook.yml
  4. 8
      roles/tripleo_container_image_prepare/molecule/default/prepare.yml
  5. 6
      roles/tripleo_container_image_prepare/tasks/main.yml
  6. 11
      zuul.d/molecule.yaml

3
roles/tripleo_container_image_prepare/defaults/main.yml

@ -1,10 +1,11 @@
---
# defaults file for tripleo_container_image_prepare
openstack_bin: openstack
tripleo_container_image_prepare_become: true
tripleo_container_image_prepare_cleanup:
tripleo_container_image_prepare_debug: false
tripleo_container_image_prepare_dry_run: false
tripleo_container_image_prepare_environemnt_files: []
tripleo_container_image_prepare_environment_files: []
tripleo_container_image_prepare_environment_directory: []
tripleo_container_image_prepare_output_env_file:
tripleo_container_image_prepare_roles_file:

22
roles/tripleo_container_image_prepare/molecule/default/molecule.yml

@ -0,0 +1,22 @@
---
driver:
name: delegated
options:
managed: false
ansible_connection_options:
ansible_connection: local
log: true
lint:
name: yamllint
enabled: false
platforms:
- name: instance
provisioner:
name: ansible
scenario:
name: default
test_sequence:
- prepare
- syntax
- converge
- verify

80
roles/tripleo_container_image_prepare/molecule/default/playbook.yml

@ -0,0 +1,80 @@
---
- name: Converge
hosts: all
collections:
- tripleo.operator
vars:
tripleo_container_image_prepare_become: false
tasks:
- name: "Include tripleo_container_image_prepare with environment_files"
include_role:
name: "tripleo_container_image_prepare"
vars:
openstack_bin: echo
tripleo_container_image_prepare_environment_files:
- file1
- file2
tripleo_container_image_prepare_debug: true
- name: Check role with environment_files
assert:
that:
- tripleo_container_image_prepare_result.stdout ==
"tripleo container image prepare --environment-file file1 --environment-file file2"
- name: "Include tripleo_container_image_prepare with environment_directory"
include_role:
name: "tripleo_container_image_prepare"
vars:
openstack_bin: echo
tripleo_container_image_prepare_environment_directory:
- dir1
- dir2
tripleo_container_image_prepare_debug: true
- name: Check role with environment_directory
assert:
that:
- tripleo_container_image_prepare_result.stdout ==
"tripleo container image prepare --environment-directory dir1 --environment-directory dir2"
- name: "Include tripleo_container_image_prepare with roles_file"
include_role:
name: "tripleo_container_image_prepare"
vars:
openstack_bin: echo
tripleo_container_image_prepare_roles_file: role-file
tripleo_container_image_prepare_debug: true
- name: Check role with roles_file
assert:
that:
- tripleo_container_image_prepare_result.stdout ==
"tripleo container image prepare --roles-file role-file"
- name: "Include tripleo_container_image_prepare with all vars set"
include_role:
name: "tripleo_container_image_prepare"
vars:
openstack_bin: echo
tripleo_container_image_prepare_cleanup: true
tripleo_container_image_prepare_debug: true
tripleo_container_image_prepare_dry_run: true
tripleo_container_image_prepare_environment_files:
- file1
- file2
tripleo_container_image_prepare_environment_directory:
- dir1
tripleo_container_image_prepare_output_env_file: envfile
tripleo_container_image_prepare_roles_file: some_role_file
- debug: var=tripleo_container_image_prepare_result.stdout
- name: Check role with all vars set
assert:
that:
- tripleo_container_image_prepare_result.stdout ==
"tripleo container image prepare --environment-file file1 --environment-file file2 "
"--environment-directory dir1 --roles-file some_role_file --output-env-file envfile --dry-run --cleanup True"

8
roles/tripleo_container_image_prepare/molecule/default/prepare.yml

@ -0,0 +1,8 @@
---
- name: Prepare
hosts: all
tasks:
- name: Build collection
include_role:
name: test_molecule_prep

6
roles/tripleo_container_image_prepare/tasks/main.yml

@ -3,9 +3,9 @@
- name: Setup container image prepare facts
set_fact:
_prepare_cmd: >-
openstack tripleo container image prepare
{{ tripleo.operator.shell_arg_list(tripleo_container_image_prepare_environment_files, '--environment-file') }}
{{ tripleo.operator.shell_arg_list(tripleo_container_image_prepare_environment_directory, '--environment-directory') }}
{{ openstack_bin }} tripleo container image prepare
{{ tripleo_container_image_prepare_environment_files | tripleo.operator.shell_arg_list('--environment-file') }}
{{ tripleo_container_image_prepare_environment_directory | tripleo.operator.shell_arg_list('--environment-directory') }}
{{ tripleo_container_image_prepare_roles_file | ternary('--roles-file ' ~ tripleo_container_image_prepare_roles_file, '') }}
{{ tripleo_container_image_prepare_output_env_file | ternary('--output-env-file ' ~ tripleo_container_image_prepare_output_env_file, '') }}
{{ tripleo_container_image_prepare_dry_run | ternary('--dry-run', '') }}

11
zuul.d/molecule.yaml

@ -5,6 +5,7 @@
- tripleo-operator-molecule-test_molecule_prep
- tripleo-operator-molecule-tripleo_container_image_delete
- tripleo-operator-molecule-tripleo_container_image_list
- tripleo-operator-molecule-tripleo_container_image_prepare
- tripleo-operator-molecule-tripleo_container_image_push
- tripleo-operator-molecule-tripleo_container_image_show
- tripleo-operator-molecule-tripleo_overcloud_export
@ -18,6 +19,7 @@
- tripleo-operator-molecule-test_molecule_prep
- tripleo-operator-molecule-tripleo_container_image_delete
- tripleo-operator-molecule-tripleo_container_image_list
- tripleo-operator-molecule-tripleo_container_image_prepare
- tripleo-operator-molecule-tripleo_container_image_push
- tripleo-operator-molecule-tripleo_container_image_show
- tripleo-operator-molecule-tripleo_overcloud_export
@ -25,6 +27,7 @@
- tripleo-operator-molecule-tripleo_overcloud_node_introspect
- tripleo-operator-molecule-tripleo_overcloud_node_configure
- tripleo-operator-molecule-tripleo_overcloud_node_clean
- tripleo-operator-molecule-tripleo_container_image_prepare
- job:
files:
@ -113,3 +116,11 @@
parent: tripleo-operator-molecule-base
vars:
tox_extra_args: tripleo_overcloud_node_clean
- job:
files:
- ^roles/tripleo_container_image_prepare/.*
name: tripleo-operator-molecule-tripleo_container_image_prepare
parent: tripleo-operator-molecule-base
vars:
tox_extra_args: tripleo_container_image_prepare

Loading…
Cancel
Save