Browse Source

Merge "Molecule testing for TripleO Strategy Plugins" into stable/train

changes/53/740153/1
Zuul 4 weeks ago
committed by Gerrit Code Review
parent
commit
fcf06e4018
8 changed files with 219 additions and 0 deletions
  1. +1
    -0
      ansible-test-env.rc
  2. +1
    -0
      tripleo_ansible/ansible_plugins/tests/molecule/tripleo_strategies/ansible-test-env.rc
  3. +16
    -0
      tripleo_ansible/ansible_plugins/tests/molecule/tripleo_strategies/inventory-fail
  4. +16
    -0
      tripleo_ansible/ansible_plugins/tests/molecule/tripleo_strategies/inventory-success
  5. +38
    -0
      tripleo_ansible/ansible_plugins/tests/molecule/tripleo_strategies/molecule.yml
  6. +67
    -0
      tripleo_ansible/ansible_plugins/tests/molecule/tripleo_strategies/playbook.yml
  7. +40
    -0
      tripleo_ansible/ansible_plugins/tests/molecule/tripleo_strategies/tripleo-free.yml
  8. +40
    -0
      tripleo_ansible/ansible_plugins/tests/molecule/tripleo_strategies/tripleo-linear.yml

+ 1
- 0
ansible-test-env.rc View File

@@ -2,6 +2,7 @@ export TRIPLEO_ANSIBLE_WORKPATH="$(dirname $(readlink -f ${BASH_SOURCE[0]}))"
export ANSIBLE_STDOUT_CALLBACK=debug
export ANSIBLE_ACTION_PLUGINS="${TRIPLEO_ANSIBLE_WORKPATH}/tripleo_ansible/roles.galaxy/config_template/action:${TRIPLEO_ANSIBLE_WORKPATH}/tripleo_ansible/ansible_plugins/action"
export ANSIBLE_CALLBACK_PLUGINS="${TRIPLEO_ANSIBLE_WORKPATH}/tripleo_ansible/ansible_plugins/callback"
export ANSIBLE_STRATEGY_PLUGINS="${TRIPLEO_ANSIBLE_WORKPATH}/tripleo_ansible/ansible_plugins/strategy"
export ANSIBLE_FILTER_PLUGINS="${TRIPLEO_ANSIBLE_WORKPATH}/tripleo_ansible/ansible_plugins/filter"
export ANSIBLE_LIBRARY="${TRIPLEO_ANSIBLE_WORKPATH}/tripleo_ansible/roles.galaxy/config_template/library:${TRIPLEO_ANSIBLE_WORKPATH}/tripleo_ansible/ansible_plugins/modules"
export ANSIBLE_MODULE_UTILS="${TRIPLEO_ANSIBLE_WORKPATH}/tripleo_ansible/ansible_plugins/module_utils"


+ 1
- 0
tripleo_ansible/ansible_plugins/tests/molecule/tripleo_strategies/ansible-test-env.rc View File

@@ -0,0 +1 @@
../../../../../ansible-test-env.rc

+ 16
- 0
tripleo_ansible/ansible_plugins/tests/molecule/tripleo_strategies/inventory-fail View File

@@ -0,0 +1,16 @@
[Controller]
instance1 ansible_connection=local
instance2 ansible_connection=local
instance3 ansible_connection=local

[Compute]
instance4 ansible_connection=local
instance5 ansible_connection=local

[Controller:vars]
max_fail_percentage=0
tripleo_role_name=Controller

[Compute:vars]
max_fail_percentage=10
tripleo_role_name=Compute

+ 16
- 0
tripleo_ansible/ansible_plugins/tests/molecule/tripleo_strategies/inventory-success View File

@@ -0,0 +1,16 @@
[Controller]
instance1 ansible_connection=local
instance2 ansible_connection=local
instance3 ansible_connection=local

[Compute]
instance4 ansible_connection=local
instance5 ansible_connection=local

[Controller:vars]
max_fail_percentage=0
tripleo_role_name=Controller

[Compute:vars]
max_fail_percentage=100
tripleo_role_name=Compute

+ 38
- 0
tripleo_ansible/ansible_plugins/tests/molecule/tripleo_strategies/molecule.yml View File

@@ -0,0 +1,38 @@
---
driver:
name: delegated
options:
managed: false
login_cmd_template: >-
ssh
-o UserKnownHostsFile=/dev/null
-o StrictHostKeyChecking=no
-o Compression=no
-o TCPKeepAlive=yes
-o VerifyHostKeyDNS=no
-o ForwardX11=no
-o ForwardAgent=no
{instance}
ansible_connection_options:
ansible_connection: ssh

log: true

platforms:
- name: instance1

provisioner:
name: ansible
config_options:
defaults:
fact_caching: jsonfile
fact_caching_connection: /tmp/molecule/facts
log: true

scenario:
test_sequence:
- converge
- verify

verifier:
name: testinfra

+ 67
- 0
tripleo_ansible/ansible_plugins/tests/molecule/tripleo_strategies/playbook.yml View File

@@ -0,0 +1,67 @@
---
# Copyright 2020 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.
#
- name: Run strategy tests
hosts: localhost
connection: local
gather_facts: false
environment:
ANSIBLE_ROLES_PATH: "${ANSIBLE_ROLES_PATH:-/usr/share/ansible/roles}:${HOME}/zuul-jobs/roles"
ANSIBLE_LIBRARY: "${ANSIBLE_LIBRARY:-/usr/share/ansible/plugins/modules}"
ANSIBLE_FILTER_PLUGINS: "${ANSIBLE_FILTER_PLUGINS:-/usr/share/ansible/plugins/filter}"
ANSIBLE_STRATEGY_PLUGINS: "${ANSIBLE_STRATEGY_PLUGINS:-/usr/share/ansible/plugins/strategy}"
tasks:
- name: Run TripleO linear success
shell: |-
. {{ playbook_dir }}/ansible-test-env.rc
ansible-playbook {{ playbook_dir }}/tripleo-linear.yml -i {{ playbook_dir }}/inventory-success | grep "second"
args:
executable: /bin/bash
register: linear_success
tags:
- skip_ansible_lint

- name: Run TripleO linear fail
shell: |-
. {{ playbook_dir }}/ansible-test-env.rc
ansible-playbook {{ playbook_dir }}/tripleo-linear.yml -i {{ playbook_dir }}/inventory-fail | grep "second"
args:
executable: /bin/bash
register: linear_fail
failed_when: linear_fail.rc == 0
tags:
- skip_ansible_lint

- name: Run TripleO free success
shell: |-
. {{ playbook_dir }}/ansible-test-env.rc
ansible-playbook {{ playbook_dir }}/tripleo-free.yml -i {{ playbook_dir }}/inventory-success | grep "second"
args:
executable: /bin/bash
register: free_success
tags:
- skip_ansible_lint

- name: Run TripleO free fail
shell: |-
. {{ playbook_dir }}/ansible-test-env.rc
ansible-playbook {{ playbook_dir }}/tripleo-free.yml -i {{ playbook_dir }}/inventory-fail | grep "second"
args:
executable: /bin/bash
register: free_fail
failed_when: free_fail.rc == 0
tags:
- skip_ansible_lint

+ 40
- 0
tripleo_ansible/ansible_plugins/tests/molecule/tripleo_strategies/tripleo-free.yml View File

@@ -0,0 +1,40 @@
---
# Copyright 2020 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.
#
- name: Run a first play with tests for the tripleo_linear strategy
hosts: all
any_errors_fatal: true
gather_facts: false
strategy: tripleo_free
tasks:
- name: Run a task that will fail on one host
debug:
msg: "Task running with tripleo_linear strategy with max_fail_percentage set to {{ max_fail_percentage|default('undefined') }}"
failed_when:
- ansible_host in ['instance5']
- name: Run a task after a potential failure on a node
debug:
msg: "Task running on {{ ansible_host }} after a potential failure"

- name: Run a second play with tests for the tripleo_linear strategy
hosts: all
any_errors_fatal: true
gather_facts: false
strategy: tripleo_free
tasks:
- name: Run a task on a node
debug:
msg: "Task running on {{ ansible_host }}"

+ 40
- 0
tripleo_ansible/ansible_plugins/tests/molecule/tripleo_strategies/tripleo-linear.yml View File

@@ -0,0 +1,40 @@
---
# Copyright 2020 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.
#
- name: Run a first play with tests for the tripleo_linear strategy
hosts: all
any_errors_fatal: true
gather_facts: false
strategy: tripleo_linear
tasks:
- name: Run a task that will fail on one host
debug:
msg: "Task running with tripleo_linear strategy with max_fail_percentage set to {{ max_fail_percentage|default('undefined') }}"
failed_when:
- ansible_host in ['instance5']
- name: Run a task after a potential failure on a node
debug:
msg: "Task running on {{ ansible_host }} after a potential failure"

- name: Run a second play with tests for the tripleo_linear strategy
hosts: all
any_errors_fatal: true
gather_facts: false
strategy: tripleo_linear
tasks:
- name: Run a task on a node
debug:
msg: "Task running on {{ ansible_host }}"

Loading…
Cancel
Save