Software testing for charms

Most types of standard software tests are applicable to Charmed PostgreSQL.

Smoke test

This type of test ensures that basic functionality works over a short amount of time.

One way to do this is by integrating your PostgreSQL application with the PostgreSQL Test Application , and running the “continuous writes” test:

juju run postgresql-test-app/leader start-continuous-writes

The expected behaviour is:

  • postgresql-test-app will continuously inserts records into the database received through the integration (the table continuous_writes).

  • The counters (amount of records in table) will grow on all cluster members

Full example
juju add-model smoke-test

juju deploy postgresql --channel 16/stable
juju add-unit postgresql -n 2 

juju deploy postgresql-test-app
juju integrate postgresql-test-app:database postgresql

# Optionally configure write speed (default is 500 miliseconds)
juju config postgresql-test-app sleep_interval=1000

juju run postgresql-test-app/leader start-continuous-writes

juju run postgresql-test-app/leader show-continuous-writes

To stop the “continuous write” test, run

juju run postgresql-test-app/leader stop-continuous-writes

To truncate the “continuous write” table (i.e. delete all records from database), run

juju run postgresql-test-app/leader clear-continuous-writes

Unit test

Check the Contributing guide on GitHub and follow tox run -e unit examples there.

Integration test

Check the Contributing guide on GitHub and follow tox run -e integration examples there.