-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into add_tag_support
- Loading branch information
Showing
23 changed files
with
208 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,4 @@ plugins: | |
shell: {} | ||
strategy: {} | ||
vars: {} | ||
version: 1.1.0 | ||
version: 1.1.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
--- | ||
ancestor: | ||
releases: | ||
1.1.1: | ||
changes: {} | ||
release_date: "2023-08-01" | ||
1.1.0: | ||
changes: | ||
minor_changes: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
- name: Default create playbook | ||
hosts: localhost | ||
gather_facts: false | ||
vars_files: | ||
- ../resources/vars/vars.yml | ||
tasks: | ||
- name: Find integration test targets | ||
ansible.builtin.find: | ||
file_type: directory | ||
paths: "{{ integration_tests_path }}" | ||
recurse: false | ||
register: _targets | ||
|
||
- name: Create directories | ||
ansible.builtin.file: | ||
path: "{{ directory }}" | ||
state: directory | ||
mode: "0700" | ||
loop: "{{ _targets.files }}" | ||
loop_control: | ||
loop_var: target | ||
label: "{{ directory }}" | ||
vars: | ||
directory: "../integration_{{ target.path | basename }}" | ||
|
||
- name: Copy the template vars_files | ||
ansible.builtin.template: | ||
src: "{{ source }}" | ||
dest: "{{ destination }}" | ||
mode: "0600" | ||
loop: "{{ _targets.files | product(files) | list }}" | ||
loop_control: | ||
loop_var: product | ||
label: "{{ destination }}" | ||
vars: | ||
source: "{{ product[1] }}" | ||
destination: "../integration_{{ product[0].path | basename }}/{{ product[1] | basename }}" | ||
files: | ||
- ../resources/templates/molecule.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
platforms: | ||
- name: na | ||
|
||
provisioner: | ||
name: ansible | ||
playbooks: | ||
destroy: ../resources/playbooks/noop.yml | ||
prepare: ../resources/playbooks/noop.yml | ||
|
||
scenario: | ||
create_sequence: | ||
- create | ||
test_sequence: | ||
- prepare | ||
destroy_sequence: | ||
- destroy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
platforms: | ||
- name: na | ||
|
||
provisioner: | ||
name: ansible | ||
playbooks: | ||
cleanup: ../resources/playbooks/noop.yml | ||
converge: ../resources/playbooks/converge.yml | ||
destroy: ../resources/playbooks/noop.yml | ||
prepare: ../resources/playbooks/noop.yml | ||
config_options: | ||
defaults: | ||
collections_path: ${ANSIBLE_COLLECTIONS_PATH} | ||
scenario: | ||
test_sequence: | ||
- prepare | ||
- converge | ||
destroy_sequence: | ||
- destroy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
platforms: | ||
- name: na | ||
|
||
provisioner: | ||
name: ansible | ||
playbooks: | ||
cleanup: ../resources/playbooks/noop.yml | ||
converge: ../resources/playbooks/converge.yml | ||
destroy: ../resources/playbooks/noop.yml | ||
prepare: ../resources/playbooks/noop.yml | ||
config_options: | ||
defaults: | ||
collections_path: ${ANSIBLE_COLLECTIONS_PATH} | ||
scenario: | ||
test_sequence: | ||
- prepare | ||
- converge | ||
destroy_sequence: | ||
- destroy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
platforms: | ||
- name: na | ||
|
||
provisioner: | ||
name: ansible | ||
playbooks: | ||
cleanup: ../resources/playbooks/noop.yml | ||
converge: ../resources/playbooks/converge.yml | ||
destroy: ../resources/playbooks/noop.yml | ||
prepare: ../resources/playbooks/noop.yml | ||
config_options: | ||
defaults: | ||
collections_path: ${ANSIBLE_COLLECTIONS_PATH} | ||
scenario: | ||
test_sequence: | ||
- prepare | ||
- converge | ||
destroy_sequence: | ||
- destroy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
platforms: | ||
- name: na | ||
|
||
provisioner: | ||
name: ansible | ||
playbooks: | ||
cleanup: ../resources/playbooks/noop.yml | ||
converge: ../resources/playbooks/converge.yml | ||
destroy: ../resources/playbooks/noop.yml | ||
prepare: ../resources/playbooks/noop.yml | ||
config_options: | ||
defaults: | ||
collections_path: ${ANSIBLE_COLLECTIONS_PATH} | ||
scenario: | ||
test_sequence: | ||
- prepare | ||
- converge | ||
destroy_sequence: | ||
- destroy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
- name: Shared integration test runner | ||
hosts: localhost | ||
gather_facts: false | ||
|
||
tasks: | ||
- name: Load the vars | ||
ansible.builtin.include_vars: | ||
file: ../../resources/vars/vars.yml | ||
|
||
- name: "Integration test: {{ test_name }}" | ||
ansible.builtin.include_role: | ||
name: "{{ test_path }}" | ||
vars: | ||
test_path: "{{ integration_tests_path }}{{ test_name }}" | ||
test_name: "{{ molecule_scenario_name.replace('integration_', '') }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- name: noop | ||
hosts: localhost | ||
gather_facts: false | ||
tasks: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
platforms: | ||
- name: na | ||
|
||
provisioner: | ||
name: ansible | ||
playbooks: | ||
cleanup: ../resources/playbooks/noop.yml | ||
converge: ../resources/playbooks/converge.yml | ||
destroy: ../resources/playbooks/noop.yml | ||
prepare: ../resources/playbooks/noop.yml | ||
config_options: | ||
defaults: | ||
collections_path: ${ANSIBLE_COLLECTIONS_PATH} | ||
scenario: | ||
test_sequence: | ||
- prepare | ||
- converge | ||
destroy_sequence: | ||
- destroy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
collection_root: "{{ lookup( 'pipe', 'git rev-parse --show-toplevel') }}" | ||
integration_tests_path: "{{ collection_root }}/tests/integration/targets/" | ||
molecule_scenario_name: "{{ molecule_scenario_directory | basename }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,13 @@ | ||
"""Run the integration tests.""" | ||
"""Tests for molecule scenarios.""" | ||
from __future__ import absolute_import, division, print_function | ||
|
||
import subprocess | ||
from pytest_ansible.molecule import MoleculeScenario | ||
|
||
from typing import Dict | ||
|
||
import pytest | ||
def test_integration(molecule_scenario: MoleculeScenario) -> None: | ||
"""Run molecule for each scenario. | ||
from pytest_ansible_network_integration import AnsibleProject | ||
|
||
|
||
# pylint: disable=invalid-name | ||
__metaclass__ = type | ||
# pylint: enable=invalid-name | ||
|
||
|
||
def run(localhost_project: AnsibleProject, environment: Dict[str, str]) -> None: | ||
"""Run the integration tests. | ||
:param localhost_project: The localhost project. | ||
:param environment: The environment. | ||
""" | ||
__tracebackhide__ = True # pylint: disable=unused-variable | ||
args = [ | ||
"ansible-navigator", | ||
"run", | ||
str(localhost_project.playbook), | ||
"--ee", | ||
"false", | ||
"--mode", | ||
"stdout", | ||
"--pas", | ||
str(localhost_project.playbook_artifact), | ||
"--ll", | ||
"debug", | ||
"--lf", | ||
str(localhost_project.log_file), | ||
"--cdcp", | ||
str(localhost_project.collection_doc_cache), | ||
"-vvvv", | ||
] | ||
process = subprocess.run( | ||
args=args, | ||
env=environment, | ||
capture_output=True, | ||
check=False, | ||
shell=False, | ||
) | ||
if process.returncode: | ||
print(process.stdout.decode("utf-8")) | ||
print(process.stderr.decode("utf-8")) | ||
|
||
pytest.fail(msg=f"Integration test failed: {localhost_project.role}") | ||
|
||
|
||
def test_integration( | ||
localhost_project: AnsibleProject, | ||
environment: Dict[str, str], | ||
) -> None: | ||
"""Run the integration tests. | ||
:param localhost_project: The localhost project. | ||
:param environment: The environment. | ||
:param molecule_scenario: The molecule scenario object | ||
""" | ||
run(localhost_project, environment) | ||
proc = molecule_scenario.test() | ||
assert proc.returncode == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
|
||
skip = | ||
py3.7 | ||
2.9 # molecule is >= 2.12 |