Charmed PostgreSQL

Channel Revision Published Runs on
latest/stable 316 11 Aug 2023
Ubuntu 22.04 Ubuntu 20.04 Ubuntu 18.04 Ubuntu 16.04
14/stable 288 18 Apr 2023
Ubuntu 22.04
14/candidate 326 19 Sep 2023
14/beta 330 27 Sep 2023
14/edge 330 26 Sep 2023
juju deploy postgresql --channel 14/stable
Show information

Platform:

Ubuntu
22.04

Charm Testing reference

There are a lot of test types available and most of them are well applicable for Charmed PostgreSQL. Here is a list prepared by Canonical:

  • Smoke test
  • Unit tests
  • Integration tests
  • System test
  • Performance test

:information_source: Note: below examples are written for Juju 3.x, but Juju 2.9 is supported as well.
Please adopt the juju run ... commands as juju run-action ... --wait for Juju 2.9.

Smoke test

Complexity: trivial
Speed: fast
Goal: ensure basic functionality works over short amount of time.

Setup an Juju 3.x environment, deploy DB with test application and start “continuous write” test:

juju add-model smoke-test

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

juju deploy postgresql-test-app
juju relate 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 the counter is growing!

Expected results:

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

Hints:

# Stop "continuous write" test
juju run postgresql-test-app/leader stop-continuous-writes

# Truncate "continuous write" table (delete all records from DB)
juju run postgresql-test-app/leader clear-continuous-writes

Unit tests

Please check the “Contributing” guide and follow tox run -e unit examples there.

Integration tests

Please check the “Contributing” guide and follow tox run -e integration examples there.

System test

Please check/deploy the charm postgresql-bundle (Git). It deploy and test all the necessary parts at once.

Performance test

Please check the separate document.


Help us improve this documentation

Most of this documentation can be collaboratively discussed and changed on the respective topic in the doc category of the Charmhub forum. See the documentation guidelines if you’d like to contribute.

Last updated 16 days ago. Help improve this document in the forum.