feat: restore native backup/<dbname>.conf pairs before falling back to native staging
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
PLUGIN_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
SCRIPT="$PLUGIN_DIR/scripts/da-integration/alt_mysql_user_restore_post_pre_cleanup.sh"
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP_DIR"' EXIT
|
||||
|
||||
fail() {
|
||||
echo "FAIL: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
mkdir -p "$TMP_DIR/fake_bin"
|
||||
|
||||
# Fake native-backup-restore tier: reports one imported, one skipped database.
|
||||
cat > "$TMP_DIR/fake_bin/alt_mysql_native_backup_restore.sh" <<'EOF'
|
||||
#!/bin/bash
|
||||
echo "CALLED native_backup_restore $*" >> "$FAKE_CALL_LOG"
|
||||
echo "IMPORTED demo_ok"
|
||||
echo "SKIPPED demo_bad import-failed"
|
||||
EOF
|
||||
chmod 755 "$TMP_DIR/fake_bin/alt_mysql_native_backup_restore.sh"
|
||||
|
||||
# Fake native-staging-migrate tier: just logs that it ran, and with which user.
|
||||
cat > "$TMP_DIR/fake_bin/da_restore_native_staging_to_alt_mysql.sh" <<'EOF'
|
||||
#!/bin/bash
|
||||
echo "CALLED native_staging_migrate $*" >> "$FAKE_CALL_LOG"
|
||||
EOF
|
||||
chmod 755 "$TMP_DIR/fake_bin/da_restore_native_staging_to_alt_mysql.sh"
|
||||
|
||||
# No plugin payload present anywhere reachable, so the hook falls past tier 1.
|
||||
mkdir -p "$TMP_DIR/empty_restore_root"
|
||||
|
||||
CALL_LOG="$TMP_DIR/calls.log"
|
||||
: > "$CALL_LOG"
|
||||
|
||||
DA_ALT_MYSQL_RESTORE_LOG="$TMP_DIR/restore.log" \
|
||||
DA_ALT_MYSQL_NATIVE_BACKUP_RESTORE_BIN="$TMP_DIR/fake_bin/alt_mysql_native_backup_restore.sh" \
|
||||
DA_ALT_MYSQL_NATIVE_STAGING_BIN="$TMP_DIR/fake_bin/da_restore_native_staging_to_alt_mysql.sh" \
|
||||
DA_ALT_MYSQL_SETTINGS_FILE="$TMP_DIR/missing-settings.conf" \
|
||||
FAKE_CALL_LOG="$CALL_LOG" \
|
||||
restore_path="$TMP_DIR/empty_restore_root" \
|
||||
username="demo" \
|
||||
bash "$SCRIPT" demo
|
||||
|
||||
grep -q "CALLED native_backup_restore" "$CALL_LOG" || fail "expected the native-backup-restore tier to be invoked"
|
||||
grep -q "CALLED native_staging_migrate" "$CALL_LOG" || fail "expected the native-staging-migrate fallback to still run for skipped databases"
|
||||
|
||||
# The staging-migrate fallback must be told which databases were already
|
||||
# imported, so it never touches demo_ok again.
|
||||
grep -q "\-\-skip demo_ok" "$CALL_LOG" || fail "expected native-staging-migrate to be told to skip demo_ok, log: $(cat "$CALL_LOG")"
|
||||
|
||||
echo "alt_mysql_user_restore_post_pre_cleanup_tiers_test: OK"
|
||||
Reference in New Issue
Block a user