#!/bin/bash set -euo pipefail PLUGIN_DIR="$(cd "$(dirname "$0")/.." && pwd)" SCRIPT="$PLUGIN_DIR/scripts/setup/mysql_upgrade.sh" fail() { echo "FAIL: $*" >&2 exit 1 } grep -Fq "rollback_upgrade()" "$SCRIPT" \ || fail "mysql_upgrade.sh does not define rollback_upgrade" grep -Fq "UPGRADE_COMMITTED=1" "$SCRIPT" \ || fail "mysql_upgrade.sh does not mark successful upgrades as committed" grep -Fq 'trap '\''code=$?; rollback_upgrade "$code"'\'' EXIT' "$SCRIPT" \ || fail "mysql_upgrade.sh does not run rollback on failed exit" grep -Fq "RESTORED_PREVIOUS_DIR" "$SCRIPT" \ || fail "mysql_upgrade.sh does not restore previous binary directory" grep -Fq "RESTORED_INSTANCE_CNF" "$SCRIPT" \ || fail "mysql_upgrade.sh does not restore previous instance config" echo "mysql_upgrade_rollback_test: OK"