Create role for molecule prep

Since we need to install the collection (and possibly other actions in
the future), let's create a role that we can share across all the tests.

Change-Id: Ic0214e7c3f1b17a8932b432d6536ef9e44fa84a7
This commit is contained in:
Alex Schultz 2020-01-31 10:51:12 -07:00
parent 7685d83b0d
commit 49a562aa8d
9 changed files with 156 additions and 0 deletions

View File

@ -0,0 +1,44 @@
test_molecule_prep
==================
A role to do collection install for molecule testing. The role assumes it's being
run from a molecule path.
Requirements
------------
None.
Role Variables
--------------
* `test_module_prep_collections_build_root`: (String) Path a directory to output the collection build to. Default: "{{ ansible_env.HOME }}/collection-buildroot"
* `test_module_prep_execution_root`: (String) Path to the directory where the build action should run in. Default: '../../../..'
Output Variables
----------------
None.
Dependencies
------------
None.
Example Playbook
----------------
Example install execution playbook
```yaml
- hosts: localhost
tasks:
- name: Do molecule prep actions
import_role:
name: test_molecule_prep
```
License
-------
Apache-2.0

View File

@ -0,0 +1,4 @@
---
# defaults file for test_molecule_prep
test_molecule_prep_collections_build_root: "{{ ansible_env.HOME }}/collection-buildroot"
test_molecule_prep_execution_root: "../../../.."

View File

@ -0,0 +1,42 @@
---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
galaxy_info:
author: OpenStack
description: TripleO Operator Role -- test_molecule_prep
company: Red Hat
license: Apache-2.0
min_ansible_version: 2.8
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
platforms:
- name: CentOS
versions:
- 7
- 8
galaxy_tags:
- tripleo
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies: []

View File

@ -0,0 +1,21 @@
---
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:
- syntax
- converge
- verify

View File

@ -0,0 +1,17 @@
---
- name: Converge
hosts: all
tasks:
- name: "Include test_molecule_prep"
include_role:
name: "test_molecule_prep"
- name: Test known collection filter
set_fact:
test_var: "{{ 'test' | tripleo.operator.shell_arg_list(parameter='--test') }}"
- name: Assert value
assert:
that:
- test_var == "--test test"

View File

@ -0,0 +1,12 @@
---
- name: Build collection
shell: >-
pwd && ansible-galaxy collection build --force --output-path {{ test_molecule_prep_collections_build_root }}
args:
chdir: "{{ test_molecule_prep_execution_root }}"
changed_when: true
- name: Install collection
shell: >-
ansible-galaxy collection install --force {{ test_molecule_prep_collections_build_root }}/tripleo-operator*
changed_when: true

View File

@ -0,0 +1 @@
localhost

View File

@ -0,0 +1,4 @@
---
- hosts: localhost
roles:
- test_molecule_prep

View File

@ -2,6 +2,7 @@
name: tripleo-operator-molecule-jobs
check:
jobs:
- 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_push
@ -12,6 +13,7 @@
gate:
jobs:
- 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_push
@ -20,6 +22,15 @@
- tripleo-operator-molecule-tripleo_overcloud_failures
- tripleo-operator-molecule-tripleo_overcloud_node_introspect
- job:
files:
- ^roles/test_molecule_prep/.*
- ^plugins/.*
name: tripleo-operator-molecule-test_molecule_prep
parent: tripleo-operator-molecule-base
vars:
tox_extra_args: test_molecule_prep
- job:
name: tripleo-operator-molecule-base
abstract: true