test(HH-460): observe restore file order (#108)
Co-authored-by: Rogee <rogee@ipao.vip>
This commit is contained in:
@@ -94,7 +94,27 @@ esac
|
||||
printf 'database\n' >>"$GOCHAT_TEST_EVENTS"
|
||||
exec docker exec -i "$GOCHAT_TEST_POSTGRES" pg_restore -U postgres --exit-on-error --no-owner --no-privileges --dbname gochat_target <"$6"
|
||||
EOF
|
||||
chmod +x "$tmp/bin/psql" "$tmp/bin/pg_dump" "$tmp/bin/pg_restore"
|
||||
cat >"$tmp/bin/tar" <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
if [[ $# -eq 4 && $1 == -C && $2 == "$GOCHAT_TEST_STORAGE" && $3 == -xf && $4 == */attachments.tar ]]; then
|
||||
/usr/bin/tar "$@"
|
||||
printf 'attachments\n' >>"$GOCHAT_TEST_EVENTS"
|
||||
exit
|
||||
fi
|
||||
exec /usr/bin/tar "$@"
|
||||
EOF
|
||||
cat >"$tmp/bin/install" <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
if [[ $# -eq 4 && $1 == -m && $2 == 0600 && $3 == */connector.db && $4 == "$GOCHAT_TEST_CONNECTOR" ]]; then
|
||||
/usr/bin/install "$@"
|
||||
printf 'connector\n' >>"$GOCHAT_TEST_EVENTS"
|
||||
exit
|
||||
fi
|
||||
exec /usr/bin/install "$@"
|
||||
EOF
|
||||
chmod +x "$tmp/bin/psql" "$tmp/bin/pg_dump" "$tmp/bin/pg_restore" "$tmp/bin/tar" "$tmp/bin/install"
|
||||
|
||||
if GOCHAT_DATABASE_DSN='postgres://test@db.example.test/test?sslmode=disable' "$tmp/scripts/database_client_entrypoint.sh" --check >"$tmp/rejected" 2>&1; then
|
||||
echo 'backup gate accepted sslmode=disable' >&2
|
||||
@@ -134,9 +154,7 @@ GOCHAT_BACKUP_PASSPHRASE_FILE="$tmp/passphrase" \
|
||||
"$tmp/scripts/db_restore.sh" "$bundle" >"$tmp/restore-output"
|
||||
|
||||
cmp "$tmp/storage/file.txt" "$tmp/restored/storage/file.txt"
|
||||
printf 'attachments\n' >>"$tmp/restore-events"
|
||||
cmp "$tmp/connector.db" "$tmp/restored/connector.db"
|
||||
printf 'connector\n' >>"$tmp/restore-events"
|
||||
printf 'database\nattachments\nconnector\n' | cmp - "$tmp/restore-events"
|
||||
grep -F 'restore=ok version=test-version migration=79 accounts=1 attachments=1' "$tmp/restore-output" >/dev/null
|
||||
echo 'backup and empty-target restore test passed'
|
||||
|
||||
Reference in New Issue
Block a user