Charm testing¶
This reference describes the different software test types that are applicable to Charmed MySQL. It is intended for charm developers and contributors.
Smoke test¶
Complexity |
trivial |
Speed |
fast |
Goal |
ensure basic functionality works over short amount of time |
Create a Juju model for testing, deploy a database with a test application and start the “continuous write” test:
juju add-model smoke-test
juju deploy mysql --channel 8.0/edge --config profile=testing
juju add-unit mysql -n 2 # (optional)
juju deploy mysql-test-app --channel latest/edge
juju relate mysql-test-app mysql:database
# Make sure random data inserted into DB by test application:
juju run mysql-test-app/leader get-inserted-data
# Start "continuous write" test:
juju run mysql-test-app/leader start-continuous-writes
export password=$(juju run mysql/leader get-password username=root | yq '.. | select(. | has("password")).password')
watch -n1 -x juju ssh mysql/leader "mysql -h 127.0.0.1 -uroot -p${password} -e \"select count(*) from continuous_writes.data\""
# Watch the counter is growing!
juju add-model smoke-test
juju deploy mysql-k8s --trust --channel 8.0/edge --config profile=testing
juju scale-application mysql-k8s 3 # (optional)
juju deploy mysql-test-app --channel latest/edge
juju relate mysql-test-app mysql-k8s:database
# Make sure random data inserted into DB by test application:
juju run mysql-test-app/leader get-inserted-data
# Start "continuous write" test:
juju run mysql-test-app/leader start-continuous-writes
export password=$(juju run mysql-k8s/leader get-password username=root | yq '.. | select(. | has("password")).password')
watch -n1 -x juju ssh --container mysql mysql-k8s/leader "mysql -h 127.0.0.1 -uroot -p${password} -e \"select count(*) from continuous_writes.data\""
# Watch the counter is growing!
Juju 2.9 users
Remember that juju run <action name> becomes juju run-action <action name> --wait.
See also: Breaking changes between Juju 2.9 and 3
Expected results:
mysql-test-app continuously inserts records in database
continuous_writestabledata.the counters (amount of records in table) are growing on all cluster members
Hints:
# Stop "continuous write" test
juju run mysql-test-app/leader stop-continuous-writes
# Truncate "continuous write" table (delete all records from DB)
juju run mysql-test-app/leader clear-continuous-writes
Unit tests¶
Please check the Contributing guide and follow the tox examples there.
Integration tests¶
Please check the Contributing guide and follow the tox examples there.
System test¶
To deploy and test all parts at once, use the MySQL bundle:
mysql-bundle for machines
mysql-k8s-bundle for Kubernetes
Performance test¶
Refer to the Charmed Sysbench documentation.