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

Set up molecule testing #3

Merged
merged 10 commits into from
Nov 24, 2023
Merged

Set up molecule testing #3

merged 10 commits into from
Nov 24, 2023

Conversation

p-j-smith
Copy link
Contributor

@p-j-smith p-j-smith commented Nov 24, 2023

  • Add a centos7 molecule scenario (tests/molecule/centos7/molecule.yml) - it has two instances, one for a database and another for a web server
  • Add an inventory for testing (tests/molecule/resources/inventory/hosts.yml)
  • Add group vars for testing (tests/molecule/resources/inventory/group_vars/all.yml)
  • Add a converge playbook for testing (tests/molecule/resources/converge.yml). This playbook uses tags to limit which roles are included. This means we can run molecule only on roles that have changed in a given pr.
  • Add a workflow to run molecule on mirsg.infrastructure.provision when the provision role has changed
  • Add a requirements file so we can install this collection

Edit: @drmatthews after talking offline, we'll use a single instance for running molecule tests rather than two (database + web server)

@p-j-smith p-j-smith requested a review from drmatthews November 24, 2023 10:19
scenario:
- centos7
env:
MOLECULE_RUN_TAGS: provision
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this limits molecule to run only mirsg.infrastructure.provision

callbacks_enabled: profile_tasks, timer, yaml
vault_password_file: "${MOLECULE_SCENARIO_DIRECTORY}/../resources/.vault_password"
tags:
run: ${MOLECULE_RUN_TAGS:-all}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we don't define MOLECULE_RUN_TAGS, all converge steps are performed

Comment on lines +7 to +10
- role: mirsg.infrastructure.provision
tags: provision
- role: mirsg.infrastructure.install_python
tags: python
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we will need to add the other roles here, and probably target specific groups for some of them

@drmatthews
Copy link
Contributor

drmatthews commented Nov 24, 2023

Hi @p-j-smith - I don't think we need collection level testing here. We do it in the xnat collection because we have a playbook we want to test (i.e. we want to know that the roles work in combination). Here each of the roles has its own test and in CI we want those tests to run when changes are made to the role itself (as you have done already with the path filter in the workflow). Does that makes sense?

Copy link
Contributor

@drmatthews drmatthews left a comment

Choose a reason for hiding this comment

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

👍

@p-j-smith p-j-smith merged commit f7d3661 into main Nov 24, 2023
1 of 2 checks passed
@p-j-smith p-j-smith deleted the feat/molecule-testing branch November 24, 2023 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants