Charmed PostgreSQL VM

Channel Revision Published Runs on
latest/stable 345 09 Nov 2023
Ubuntu 22.04 Ubuntu 20.04 Ubuntu 18.04 Ubuntu 16.04 Ubuntu 14.04
latest/stable 239 09 Feb 2022
Ubuntu 22.04 Ubuntu 20.04 Ubuntu 18.04 Ubuntu 16.04 Ubuntu 14.04
latest/stable 226 01 Apr 2021
Ubuntu 22.04 Ubuntu 20.04 Ubuntu 18.04 Ubuntu 16.04 Ubuntu 14.04
14/stable 468 11 Sep 2024
Ubuntu 22.04
14/stable 467 11 Sep 2024
Ubuntu 22.04
14/candidate 529 29 Nov 2024
Ubuntu 22.04
14/candidate 528 29 Nov 2024
Ubuntu 22.04
14/beta 529 28 Nov 2024
Ubuntu 22.04
14/beta 528 28 Nov 2024
Ubuntu 22.04
14/edge 531 29 Nov 2024
Ubuntu 22.04
14/edge 530 29 Nov 2024
Ubuntu 22.04
16/edge 527 27 Nov 2024
Ubuntu 24.04
16/edge 526 27 Nov 2024
Ubuntu 24.04
juju deploy postgresql --channel 14/edge
Show information

Platform:

Ubuntu
24.04 22.04 20.04 18.04 16.04 14.04

Note: All commands are written for juju >= v.3.1

If you’re using juju 2.9, check the juju 3.0 Release Notes.

Software testing for charms

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

This reference addresses the following types:


Smoke test

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

Steps

  1. Set up a juju v.3.x environment
  2. Deploy database with test application
  3. Start “continuous write” test
Example
juju add-model smoke-test

juju deploy postgresql --channel 14/edge
juju add-unit postgresql -n 2 # (optional)

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

# Start "continuous write" test:
juju run postgresql-test-app/leader start-continuous-writes
juju run postgresql/leader get-password

export user=operator
export pass=$(juju run postgresql/leader get-password username=${user} | yq '.. | select(. | has("password")).password')
export relname=first-database
export ip=$(juju show-unit postgresql/0 --endpoint database | yq '.. | select(. | has("public-address")).public-address')
export db=$(juju show-unit postgresql/0 --endpoint database | yq '.. | select(. | has("database")).database')
export relid=$(juju show-unit postgresql/0 --endpoint database | yq '.. | select(. | has("relation-id")).relation-id')
export query="select count(*) from continuous_writes"

watch -n1 -x juju run postgresql-test-app/leader run-sql dbname=${db} query="${query}" relation-id=${relid} relation-name=${relname}

# OR

watch -n1 -x juju ssh postgresql/leader "psql postgresql://${user}:${pass}@${ip}:5432/${db} -c \"${query}\""

# Watch that the counter is growing!

Expected results

  • postgresql-test-app continuously inserts records into the database received through the integration (the table continuous_writes).
  • The counters (amount of records in table) are growing on all cluster members

Tips

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.

System test

To perform a system test, deploy postgresql-bundle. This charm bundle automatically deploys and tests all the necessary parts at once.


Help improve this document in the forum (guidelines). Last updated 5 months ago.