Skip to content

Testing your changes

Andrew Klychkov edited this page Oct 2, 2020 · 17 revisions

For what it is worth

Tests are extremely important for stability of stuff in this repository, so:

  • cover your changes as completely as possible

  • be sure your tests cover check_mode if applicable

  • be sure that functionality that can be affected by your changes is also covered, if not, cover it

Useful references

Prerequisites

We are assuming that you:

  • downloaded community.mysql repository

  • made some changes

  • added integration tests that cover your changes to one of the files in the tests/integration/targets/test_mysql_* directory (or you just want to run existing tests in order to check that your changes do not break currently covered code)

  • if you do not know how to add tests for your case, create a pull request and ask other contributors there for help

Prepare testing environment

  1. Install docker daemon on your system, run it.

  2. Download ansible-base repository.

  3. Go to the ansible-base repository root directory.

  4. Run source hacking/env-setup.

Run integration tests

  1. Be sure you ran source hacking/env-setup as described above.

  2. Go to the community.mysql repository root directory.

  3. Run (change test_mysql_query to an appropriate test directory name):

    ansible-test integration test_mysql_query --docker --docker-no-pull -vvv > /tmp/test.log

    Be sure you use default docker container, use the --docker default or just --docker command-line option.

  4. If something goes wrong, you can check the output stored in /tmp/test.log.

Run sanity tests

To run sanity tests:

  1. Be sure you ran source hacking/env-setup as described above.

  2. Run (change mysql_query.py to an appropriate file path):

    ansible-test sanity plugins/modules/mysql_query.py --docker --docker-no-pull

    Be sure you use default docker container, use the --docker default or just --docker command-line option.

When there are issues with local testing

  • You can just create a pull request in this repository and all sanity and integration tests (including yours) will run here automatically and you'll get a detailed report

  • Create a pull request and ask other contributors to help with running tests locally there.

Clone this wiki locally