#!/bin/sh # dep8 smoke test for mysql-server # Author: Robie Basak # # This test should be declared in debian/tests/control with a dependency # on the package that provides a configured MariaDB server (eg. # mariadb-server). # # This test should be declared in debian/tests/control with the # following restrictions: # - allow-stderr (set -x always outputs to stderr) # - needs-root (to be able to log into the database) # - isolation-container (to be able to start service) # # This test: # # 1) Creates a test database and test user as the root user. # # 2) Creates a test table and checks it appears to operate normally # using the test user and test database. # # 3) Checks compression support for InnoDB & RocksDB engine. echo "Running test 'smoke'" set -ex # Start the daemon if it was not running. For example in Docker testing # environments there might not be any systemd et al and the service needs to # be started manually. if ! command -v systemctl then if ! /etc/init.d/mariadb status then echo "Did not find systemctl and daemon was not running, starting it.." /etc/init.d/mariadb start fi else echo "Found systemctl, continuing smoke test.." # If systemd (and systemctl) is available, but the service did not start, then # this smoke test is supposed to fail with extensive diagnostics output of # that might explain why the service failed to start. systemctl restart mariadb || { echo "=== Systemd service status ===" systemctl status mariadb.service || true echo "=== Systemd journal ===" journalctl -xeu mariadb.service || true echo "=== MariaDB error log (if exists) ===" cat /var/log/mysql/error.log 2>/dev/null || cat /var/lib/mysql/*.err 2>/dev/null || \ cat /var/log/mariadb/error.log 2>/dev/null || cat /var/lib/mariadb/*.err 2>/dev/null || echo "No error log found" echo "=== MariaDB processes ===" # shellcheck disable=SC2009 ps aux | grep -i mariadb || true echo "=== data directory contents and permissions ===" find /var/lib/mariadb/ -ls || true find /var/lib/mysql/ -ls || true echo "=== Socket existence ===" find /run/mariadbd/ -ls || true find /run/mysqld/ -ls || true echo "=== AppArmor profile status ===" aa-status 2>/dev/null | grep -A5 -B5 mariadb || true echo "=== AppArmor denials ===" dmesg | grep -i apparmor | grep -i mariadb || true journalctl -k | grep -i apparmor | grep -i mariadb || true echo "=== Start mariadbd directly to capture immediate error ===" timeout 10 /usr/sbin/mariadbd --user=mysql --console 2>&1 || true exit 1 } fi mariadb <&2 exit 1 fi mariadb --user=testuser --password=testpassword testdatabase <&2 exit 1 fi done else if dpkg-query -W $plugin then echo "Error: Plugin $plugin was found even though it should not exist on a 32-bit and little-endian system" exit 1 fi fi