Charmed PostgreSQL K8s

Channel Revision Published Runs on
latest/stable 20 20 Sep 2022
Ubuntu 20.04
14/stable 73 18 Apr 2023
Ubuntu 22.04
14/candidate 139 19 Sep 2023
14/beta 145 26 Sep 2023
14/edge 148 Yesterday
juju deploy postgresql-k8s --channel 14/stable
Show information

Platform:

There are a lot of test types available and most of them are well applicable for Charmed PostgreSQL K8s. 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-k8s --trust --channel 14/edge
juju scale-application postgresql-k8s 3 # (optional)

juju deploy postgresql-test-app
juju relate postgresql-test-app:first-database postgresql-k8s

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

export user=operator
export pass=$(juju run postgresql-k8s/leader get-password username=${user} | yq '.. | select(. | has("password")).password')
export relname=first-database
export ip=$(juju show-unit postgresql-k8s/0 --endpoint database | yq '.. | select(. | has("public-address")).public-address')
export db=$(juju show-unit postgresql-k8s/0 --endpoint database | yq '.. | select(. | has("database")).database')
export relid=$(juju show-unit postgresql-k8s/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 --container postgresql postgresql-k8s/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-k8s-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 14 days ago. Help improve this document in the forum.