| 1 |
#!/bin/sh |
| 2 |
set -ex |
| 3 |
|
| 4 |
# dep8 smoke test for mysql-server |
| 5 |
# Author: Robie Basak <robie.basak at canonical.com> |
| 6 |
# |
| 7 |
# This test should be declared in debian/tests/control with a dependency |
| 8 |
# on the package that provides a configured MySQL server (eg. |
| 9 |
# mysql-server-5.6). |
| 10 |
# |
| 11 |
# This test should be declared in debian/tests/control with the |
| 12 |
# following restrictions: |
| 13 |
# |
| 14 |
# needs-root (needed to reset the root mysql password) |
| 15 |
# breaks-testbed (because it resets the root mysql password) |
| 16 |
# allow-stderr |
| 17 |
# |
| 18 |
# This test: |
| 19 |
# |
| 20 |
# 1) Configures packaged mysql server root password with maintainer |
| 21 |
# scripts. |
| 22 |
# |
| 23 |
# 2) Creates a test database and test user as the root user. |
| 24 |
# |
| 25 |
# 3) Creates a test table and checks it appears to operate normally |
| 26 |
# using the test user and test database. |
| 27 |
|
| 28 |
debconf-set-selections <<EOT |
| 29 |
mysql-server-8.0 mysql-server/root_password password rootpassword |
| 30 |
mysql-server-8.0 mysql-server/root_password_again password rootpassword |
| 31 |
EOT |
| 32 |
|
| 33 |
DEBIAN_FRONTEND=noninteractive dpkg-reconfigure mysql-server-8.0 |
| 34 |
|
| 35 |
mysql --user=root --password=rootpassword <<EOT |
| 36 |
CREATE DATABASE testdatabase; |
| 37 |
CREATE USER 'testuser'@'localhost' identified by 'testpassword'; |
| 38 |
GRANT ALL ON testdatabase.* TO 'testuser'@'localhost'; |
| 39 |
EOT |
| 40 |
|
| 41 |
mysql --user=testuser --password=testpassword testdatabase <<EOT |
| 42 |
CREATE TABLE foo (bar INTEGER); |
| 43 |
INSERT INTO foo (bar) VALUES (41); |
| 44 |
EOT |
| 45 |
|
| 46 |
result=`echo 'SELECT bar+1 FROM foo;'|mysql --batch --skip-column-names --user=testuser --password=testpassword testdatabase` |
| 47 |
if [ "$result" != "42" ]; then |
| 48 |
echo "Unexpected result" >&2 |
| 49 |
exit 1 |
| 50 |
fi |
| 51 |
|
| 52 |
mysql --user=testuser --password=testpassword testdatabase <<EOT |
| 53 |
DROP TABLE foo; |
| 54 |
EOT |
| 55 |
|
| 56 |
mysql --user=root --password=rootpassword <<EOT |
| 57 |
DROP DATABASE testdatabase; |
| 58 |
DROP USER 'testuser'@'localhost'; |
| 59 |
EOT |