|
| 1 | +#!/usr/bin/env bash |
| 2 | +# ghe-restore command tests |
| 3 | + |
| 4 | +# Bring in testlib |
| 5 | +# shellcheck source=test/testlib.sh |
| 6 | +. "$(dirname "$0")/testlib.sh" |
| 7 | + |
| 8 | +setup_incremental_restore_data |
| 9 | +setup_actions_enabled_settings_for_restore true |
| 10 | + |
| 11 | +# Make the current symlink |
| 12 | +ln -s 1 "$GHE_DATA_DIR/current" |
| 13 | +begin_test "ghe_restore -i doesn't run on unsupported versions" |
| 14 | +( |
| 15 | + set -e |
| 16 | + GHE_RESTORE_HOST=127.0.0.1 |
| 17 | + export GHE_RESTORE_HOST |
| 18 | + |
| 19 | + # restore should fail on versions older than 3.10 |
| 20 | + ! GHE_TEST_REMOTE_VERSION=3.9.0 ghe-restore -i -v |
| 21 | + ! GHE_TEST_REMOTE_VERSION=3.7.0 ghe-restore -i -v |
| 22 | + ! GHE_TEST_REMOTE_VERSION=3.1.0 ghe-restore -i -v |
| 23 | +) |
| 24 | +end_test |
| 25 | + |
| 26 | +begin_test "ghe-restore -i into configured vm from full backup" |
| 27 | +( |
| 28 | + set -e |
| 29 | + rm -rf "$GHE_REMOTE_ROOT_DIR" |
| 30 | + setup_remote_metadata |
| 31 | + |
| 32 | + # set as configured, enable maintenance mode and create required directories |
| 33 | + setup_maintenance_mode "configured" |
| 34 | + |
| 35 | + # set restore host environ var |
| 36 | + GHE_RESTORE_HOST=127.0.0.1 |
| 37 | + export GHE_RESTORE_HOST |
| 38 | + # run ghe-restore and write output to file for asserting against |
| 39 | + if ! GHE_TEST_REMOTE_VERSION=3.10.0 GHE_DEBUG=1 ghe-restore -i -v -f > "$TRASHDIR/restore-out" 2>&1; then |
| 40 | +output_debug_logs_and_fail_test |
| 41 | + fi |
| 42 | + |
| 43 | + |
| 44 | + # verify connect to right host |
| 45 | + grep -q "Connect 127.0.0.1:122 OK" "$TRASHDIR/restore-out" |
| 46 | + |
| 47 | + # verify stale servers were cleared |
| 48 | + grep -q "Cleaning up stale nodes ..." "$TRASHDIR/restore-out" |
| 49 | + |
| 50 | + # Verify all the data we've restored is as expected |
| 51 | + verify_all_restored_data |
| 52 | +) |
| 53 | +end_test |
| 54 | + |
| 55 | +begin_test "ghe-restore -i fails when the lsn information for the listed files is out of order" |
| 56 | +( |
| 57 | + set -e |
| 58 | + rm -rf "$GHE_REMOTE_ROOT_DIR" |
| 59 | + setup_remote_metadata |
| 60 | + |
| 61 | + # set as configured, enable maintenance mode and create required directories |
| 62 | + setup_maintenance_mode "configured" |
| 63 | + |
| 64 | + # set restore host environ var |
| 65 | + GHE_RESTORE_HOST=127.0.0.1 |
| 66 | + export GHE_RESTORE_HOST |
| 67 | + |
| 68 | + inc_1="$GHE_DATA_DIR/2" |
| 69 | + inc_2="$GHE_DATA_DIR/3" |
| 70 | + |
| 71 | + # screw up the order of the LSNs in xtrabackup_checkpoints |
| 72 | + setup_incremental_lsn $inc_1 100 200 incremental |
| 73 | + setup_incremental_lsn $inc_2 50 50 incremental |
| 74 | + # run ghe-restore and write output to file for asserting against |
| 75 | + # we expect failure and need the right output. |
| 76 | + if GHE_DEBUG=1 ghe-restore -i -v -f > "$TRASHDIR/restore-out" 2>&1; then |
| 77 | + true |
| 78 | + fi |
| 79 | +) |
| 80 | +end_test |
| 81 | + |
| 82 | + |
0 commit comments