Skip to content

Commit a4ab951

Browse files
committed
Tests for simultaneous restores
1 parent ab1bdda commit a4ab951

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/test-ghe-restore.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,3 +410,37 @@ begin_test "ghe-restore with tarball strategy"
410410
echo "$output" | grep -q 'fake ghe-export-repositories data'
411411
)
412412
end_test
413+
414+
begin_test "ghe-restore aborts when another restore is underway"
415+
(
416+
set -e
417+
# This test is only valid for version 2 and above
418+
if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then
419+
rm -rf "$GHE_REMOTE_ROOT_DIR"
420+
setup_remote_metadata
421+
422+
# create file used to determine if instance has been configured.
423+
touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured"
424+
425+
# create file used to determine if instance is in maintenance mode.
426+
mkdir -p "$GHE_REMOTE_DATA_DIR/github/current/public/system"
427+
touch "$GHE_REMOTE_DATA_DIR/github/current/public/system/maintenance.html"
428+
429+
# create file to indicate restore is underway
430+
echo "restoring" > "$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status"
431+
432+
# set restore host environ var
433+
GHE_RESTORE_HOST=127.0.0.1
434+
export GHE_RESTORE_HOST
435+
436+
# run ghe-restore and write output to file for asserting against
437+
# this should fail due to the appliance being in an unconfigured state
438+
! ghe-restore -v > "$TRASHDIR/restore-out" 2>&1
439+
440+
cat $TRASHDIR/restore-out
441+
442+
# verify that ghe-restore failed due to the appliance not being configured
443+
grep -q -e "already has a restore underway" "$TRASHDIR/restore-out"
444+
fi
445+
)
446+
end_test

0 commit comments

Comments
 (0)