Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: integrate pytest-molecule plugin #124

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a1bf2a1
integrate pytest-molecule plugin WIP
Ruchip16 May 10, 2023
2f68be2
Add python 3.8 back (#119)
cidrblock May 10, 2023
d4c7c3c
Remove password (#120)
cidrblock May 10, 2023
d35539d
Add token write for pypi (#122)
cidrblock May 10, 2023
67dd05b
REmove ansible as dep (#127)
cidrblock May 11, 2023
0de974d
Restore python 3.7 support (#128)
cidrblock May 15, 2023
e97022e
WIP
Ruchip16 May 18, 2023
8665f9a
Merge branch 'main' into integrate-molecule
Ruchip16 May 18, 2023
1648519
need review
Ruchip16 May 22, 2023
70657eb
molecule integration
Ruchip16 May 29, 2023
21b0de7
checks testing
Ruchip16 May 29, 2023
3a0adc3
fixes
Ruchip16 Jun 7, 2023
e07b0b2
tests for molecule
Ruchip16 Jun 13, 2023
373ef00
broken tests & fixes
Ruchip16 Jun 16, 2023
5c6418d
tox failing tests
Ruchip16 Jun 19, 2023
79802d9
constraint file fixture
Ruchip16 Jun 20, 2023
6e8325e
fixtures
Ruchip16 Jun 20, 2023
aff79e0
Merge branch 'main' into integrate-molecule
Ruchip16 Jun 21, 2023
ddf74b3
REmove ansible as dep (#127)
cidrblock May 11, 2023
2dd8d4f
Restore python 3.7 support (#128)
cidrblock May 15, 2023
e7386d1
molecule integration
Ruchip16 May 29, 2023
5d1677a
naming conflicts fix
Ruchip16 Jul 17, 2023
699e7d2
chore: auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 17, 2023
e8652c8
Merge branch 'main' into integrate-molecule
audgirka Jul 18, 2023
e085bc2
Switch to ANSIBLE_COLLECTION_PATH (#139)
cidrblock Aug 1, 2023
94a0af0
Fix for ansible 2.9 (#141)
cidrblock Aug 1, 2023
b0f07f5
integrate pytest-molecule plugin WIP
Ruchip16 May 10, 2023
6202eda
REmove ansible as dep (#127)
cidrblock May 11, 2023
f051d4a
WIP
Ruchip16 May 18, 2023
2aeb3a8
need review
Ruchip16 May 22, 2023
f53d18a
molecule integration
Ruchip16 May 29, 2023
97582b2
broken tests & fixes
Ruchip16 Jun 16, 2023
55baec0
REmove ansible as dep (#127)
cidrblock May 11, 2023
6f7deb0
molecule integration
Ruchip16 May 29, 2023
8e2fe4d
ModuleNotFoundError in tests
Ruchip16 Aug 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .config/requirements.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
coverage
pytest>=6,<8.0.0

3 changes: 2 additions & 1 deletion .config/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# This file is autogenerated by pip-compile with Python 3.8
# by the following command:
#
# pip-compile --extra=docs --extra=test --no-annotate --output-file=.config/requirements.txt --resolver=backtracking --strip-extras --unsafe-package=ruamel-yaml-clib pyproject.toml
#

ansible-core==2.15.1
attrs==22.2.0
cffi==1.15.1
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ venv/
ENV/
env.bak/
venv.bak/
newenv

# Spyder project settings
.spyderproject
Expand Down Expand Up @@ -166,4 +167,4 @@ cython_debug/
# and should all have detailed explanations

# Version created and populated by setuptools_scm
/src/pytest_ansible/_version.py
/src/pytest_ansible/_version.py
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"editor.defaultFormatter": "ms-python.black-formatter"
},
"editor.formatOnSave": true,
"isort.check": false,
"prettier.enable": false,
"python.formatting.provider": "black",
"python.formatting.provider": "none",
Ruchip16 marked this conversation as resolved.
Show resolved Hide resolved
"python.linting.flake8Enabled": true,
"python.linting.mypyEnabled": true,
"python.linting.pylintEnabled": true,
Expand Down
15 changes: 15 additions & 0 deletions molecule/default/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
***********************************
Delegated driver installation guide
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this root molecule directory supported to be here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah looks like it's for the tests....... It can be moved to a /tests/fixtures/molecule directory

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can move this in a seperate PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so should I move it or not in this PR?

***********************************

Requirements
============

This driver is delegated to the developer. Up to the developer to implement
requirements.

Install
=======

This driver is delegated to the developer. Up to the developer to implement
requirements.
8 changes: 8 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- name: Converge
hosts: all
gather_facts: false
tasks:
- name: "Include pytest-ansible"
ansible.builtin.include_role:
name: "pytest-ansible"
36 changes: 36 additions & 0 deletions molecule/default/create.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
- name: Create
hosts: localhost
connection: local
gather_facts: false
no_log: "{{ molecule_no_log }}"
tasks:
# TODO: Developer must implement and populate 'server' variable

- when: server.changed | default(false) | bool
block:
- name: Populate instance config dict
ansible.builtin.set_fact:
instance_conf_dict:
{
"instance": "{{ }}",
"address": "{{ }}",
"user": "{{ }}",
"port": "{{ }}",
"identity_file": "{{ }}",
}
with_items: "{{ server.results }}"
register: instance_config_dict

- name: Convert instance config dict to a list
ansible.builtin.set_fact:
instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}"

- name: Dump instance config
ansible.builtin.copy:
content: |
# Molecule managed

{{ instance_conf | to_json | from_json | to_yaml }}
dest: "{{ molecule_instance_config }}"
mode: 0600
24 changes: 24 additions & 0 deletions molecule/default/destroy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
- name: Destroy
hosts: localhost
connection: local
gather_facts: false
no_log: "{{ molecule_no_log }}"
tasks:
# Developer must implement.

# Mandatory configuration for Molecule to function.

- name: Populate instance config
ansible.builtin.set_fact:
instance_conf: {}

- name: Dump instance config
ansible.builtin.copy:
content: |
# Molecule managed

{{ instance_conf | to_json | from_json | to_yaml }}
dest: "{{ molecule_instance_config }}"
mode: 0600
when: server.changed | default(false) | bool
31 changes: 31 additions & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
dependency:
name: galaxy
state: present

driver:
name: delegated

platforms:
- name: instance

verifier:
name: ansible

provisioner:
name: ansible
log: true
config_options:
defaults:
interpreter_python: auto
verbosity: 1

scenario:
name: default
test_sequence:
- dependency
- syntax
- create
- prepare
- converge
- verify
10 changes: 10 additions & 0 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
# This is an example playbook to execute Ansible tests.

- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Example assertion
ansible.builtin.assert:
that: true
Loading