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

feat: add tests for Ansible Verifier #367

Merged
merged 6 commits into from
Jun 9, 2023
Merged

feat: add tests for Ansible Verifier #367

merged 6 commits into from
Jun 9, 2023

Conversation

ThomasSanson
Copy link
Sponsor Contributor

πŸš€ feat(molecule): add Postgres and Patroni tests
✨ feat(molecule): add etcd health check test
πŸ› fix(molecule): enable verifier in molecule config The molecule configuration file was updated to enable the verifier. A new group_vars file was added to set the default Postgres database name, user, and password. Tests were added to check if PostgreSQL is running, listening on the default port, and if the database exists. A test was added to check the replication status of PostgreSQL. Tests were added to check the status of Patroni and etcd. These tests will help ensure that the application is running correctly and that the infrastructure is properly configured.

✨ feat(molecule): add etcd health check test
πŸ› fix(molecule): enable verifier in molecule config
The molecule configuration file was updated to enable the verifier. A new group_vars file was added to set the default Postgres database name, user, and password. Tests were added to check if PostgreSQL is running, listening on the default port, and if the database exists. A test was added to check the replication status of PostgreSQL. Tests were added to check the status of Patroni and etcd. These tests will help ensure that the application is running correctly and that the infrastructure is properly configured.
@vitabaks
Copy link
Owner

vitabaks commented Jun 7, 2023

Thank you for your contribution

I think we should clarify the title of this PR
In my understanding, there are already tests - https://github.com/vitabaks/postgresql_cluster/actions/workflows/molecule.yml

@vitabaks
Copy link
Owner

vitabaks commented Jun 7, 2023

I believe we are talking about additional tests here

It is important to note that the necessary tests are performed in the main playbook

here is an example:

https://github.com/vitabaks/postgresql_cluster/blob/master/roles/patroni/tasks/main.yml#L836
https://github.com/vitabaks/postgresql_cluster/blob/master/roles/etcd/tasks/main.yml#L122

You can find a lot of detailed checks in the code.

@vitabaks
Copy link
Owner

vitabaks commented Jun 7, 2023

maybe so "Add tests for Ansible Verifier"

@ThomasSanson ThomasSanson changed the title feat: add tests feat: add tests for Ansible Verifier Jun 8, 2023
@ThomasSanson
Copy link
Sponsor Contributor Author

@vitabaks

It's important to note that there are two scopes of testing in our process:

  1. The tests run during the installation, via the playbooks.
  2. The tests initiated by molecule's verify, designed to facilitate a test-driven development approach (TDD).

I believe that both types of tests are necessary. However, I could consider combining them and initiating them at the right time. This is what I anticipate with the collection format: I will have a 'healthcheck' playbook that can be launched at any time to check the health status of our infrastructure. This playbook will itself be triggered by molecule's verify.

In summary, I differentiate between the tests performed during installation, which are an integral part of the installation process, and the verification tests performed at the end.

To provide a bit more context, I plan to implement the 'side_effect' in the future. This process will aim to disrupt a part of the infrastructure (for example, by killing a master container) to then launch the verify and ensure everything is working correctly (i.e., the recovery is successful). This is just an example to highlight the importance of conducting tests after the convergence (installation) phase.

https://github.com/confluentinc/cp-ansible/tree/7.4.0-post/molecule

ThomasSanson and others added 4 commits June 8, 2023 12:42
Co-authored-by: Vitaliy Kukharik <37010174+vitabaks@users.noreply.github.com>
✨ feat(verify.yml): include all tests and remove replica tests
πŸ› fix(postgres.yml): use patroni_superuser_username and patroni_superuser_password instead of postgres_user and postgres_password
πŸ› fix(postgres.yml): fix typo in task name
The all.yml file was removed as it was no longer needed. The verify.yml file was updated to include all tests and remove replica tests. The postgres.yml file was updated to use patroni_superuser_username and patroni_superuser_password instead of postgres_user and postgres_password. A typo in the task name was also fixed.
The test to check if the databases exist is redundant as it is already being checked in the `molecule/default/converge.yml` playbook. Removing this test will reduce the time taken to run the tests and improve the overall performance of the test suite.
The indentation of the file path in the include_vars task was fixed to be consistent with the rest of the file.
@vitabaks
Copy link
Owner

vitabaks commented Jun 8, 2023

Thank you for sharing your detailed testing approach.
I find the idea of integrating both installation testing and post-installation verification compelling. The planned 'healthcheck' playbook and future 'side_effect' implementation certainly add robustness to the process.
Looking forward to seeing these enhancements in action.

@vitabaks
Copy link
Owner

vitabaks commented Jun 9, 2023

@ThomasSanson Let me know when you're done working on this PR.

The database name was changed from postgres to template1 to avoid issues with the postgres database being used as a template database.
@ThomasSanson
Copy link
Sponsor Contributor Author

@vitabaks all done for me, this pull request is ready

@vitabaks vitabaks merged commit 16062c3 into vitabaks:master Jun 9, 2023
18 checks passed
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.

None yet

2 participants