diff --git a/dev/tests/run_tests.sh b/dev/tests/run_tests.sh index d8be244..e347b17 100755 --- a/dev/tests/run_tests.sh +++ b/dev/tests/run_tests.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -## obackup basic tests suite 2018110501 +## obackup basic tests suite 2018110601 # Supported environment variables @@ -75,6 +75,7 @@ DATABASE_EXCLUDED="information_schema.sql.xz" CRYPT_EXTENSION=".obackup.gpg" ROTATE_1_EXTENSION=".obackup.1" +ROTATE_2_EXTENSION=".obackup.2" PASSFILE="passfile" CRYPT_TESTFILE="testfile" @@ -404,12 +405,29 @@ function test_LocalRun () { for file in "${DatabasePresence[@]}"; do [ -f "$TARGET_DIR_SQL_LOCAL/$file$ROTATE_1_EXTENSION" ] - assertEquals "Database rotated Presence [$TARGET_DIR_SQL_LOCAL/$file]" "0" $? + assertEquals "Database rotated Presence [$TARGET_DIR_SQL_LOCAL/$file$ROTATE_1_EXTENSION]" "0" $? done [ -d "$TARGET_DIR_FILE_LOCAL/$(dirname $SOURCE_DIR)$ROTATE_1_EXTENSION" ] assertEquals "File rotated Presence [$TARGET_DIR_FILE_LOCAL/$(dirname $SOURCE_DIR)$ROTATE_1_EXTENSION]" "0" $? + # Second test of rotated files + + REMOTE_HOST_PING=$RHOST_PING ./$OBACKUP_EXECUTABLE "$CONF_DIR/$LOCAL_CONF" + assertEquals "Return code" "0" $? + + for file in "${DatabasePresence[@]}"; do + [ -f "$TARGET_DIR_SQL_LOCAL/$file$ROTATE_1_EXTENSION" ] + assertEquals "Database rotated Presence [$TARGET_DIR_SQL_LOCAL/$file$ROTATE_1_EXTENSION]" "0" $? + [ -f "$TARGET_DIR_SQL_LOCAL/$file$ROTATE_2_EXTENSION" ] + assertEquals "Database rotated Presence [$TARGET_DIR_SQL_LOCAL/$file$ROTATE_2_EXTENSION]" "0" $? + done + + [ -d "$TARGET_DIR_FILE_LOCAL/$(dirname $SOURCE_DIR)$ROTATE_1_EXTENSION" ] + assertEquals "File rotated Presence [$TARGET_DIR_FILE_LOCAL/$(dirname $SOURCE_DIR)$ROTATE_1_EXTENSION]" "0" $? + [ -d "$TARGET_DIR_FILE_LOCAL/$(dirname $SOURCE_DIR)$ROTATE_2_EXTENSION" ] + assertEquals "File rotated Presence [$TARGET_DIR_FILE_LOCAL/$(dirname $SOURCE_DIR)$ROTATE_2_EXTENSION]" "0" $? + } function test_PullRun () { @@ -455,7 +473,6 @@ function test_PullRun () { # Tests presence of rotated files - cd "$OBACKUP_DIR" REMOTE_HOST_PING=$RHOST_PING ./$OBACKUP_EXECUTABLE "$CONF_DIR/$PULL_CONF" assertEquals "Return code" "0" $? @@ -467,6 +484,23 @@ function test_PullRun () { [ -d "$TARGET_DIR_FILE_PULL/$(dirname $SOURCE_DIR)$ROTATE_1_EXTENSION" ] assertEquals "File rotated Presence [$TARGET_DIR_FILE_PULL/$(dirname $SOURCE_DIR)$ROTATE_1_EXTENSION]" "0" $? + # Second test of presence of rotated files + + REMOTE_HOST_PING=$RHOST_PING ./$OBACKUP_EXECUTABLE "$CONF_DIR/$PULL_CONF" + assertEquals "Return code" "0" $? + + for file in "${DatabasePresence[@]}"; do + [ -f "$TARGET_DIR_SQL_PULL/$file$ROTATE_1_EXTENSION" ] + assertEquals "Database rotated Presence [$TARGET_DIR_SQL_PULL/$file$ROTATE_1_EXTENSION]" "0" $? + [ -f "$TARGET_DIR_SQL_PULL/$file$ROTATE_2_EXTENSION" ] + assertEquals "Database rotated Presence [$TARGET_DIR_SQL_PULL/$file$ROTATE_2_EXTENSION]" "0" $? + done + + [ -d "$TARGET_DIR_FILE_PULL/$(dirname $SOURCE_DIR)$ROTATE_1_EXTENSION" ] + assertEquals "File rotated Presence [$TARGET_DIR_FILE_PULL/$(dirname $SOURCE_DIR)$ROTATE_1_EXTENSION]" "0" $? + [ -d "$TARGET_DIR_FILE_PULL/$(dirname $SOURCE_DIR)$ROTATE_2_EXTENSION" ] + assertEquals "File rotated Presence [$TARGET_DIR_FILE_PULL/$(dirname $SOURCE_DIR)$ROTATE_2_EXTENSION]" "0" $? + } function test_PushRun () { @@ -511,18 +545,34 @@ function test_PushRun () { assertEquals "Diff should only output excluded files" "0" $? # Tests presence of rotated files - cd "$OBACKUP_DIR" + + REMOTE_HOST_PING=$RHOST_PING ./$OBACKUP_EXECUTABLE "$CONF_DIR/$PULL_CONF" + assertEquals "Return code" "0" $? + + for file in "${DatabasePresence[@]}"; do + [ -f "$TARGET_DIR_SQL_PULL/$file$ROTATE_1_EXTENSION" ] + assertEquals "Database rotated Presence [$TARGET_DIR_SQL_PULL/$file$ROTATE_1_EXTENSION]" "0" $? + done + + [ -d "$TARGET_DIR_FILE_PULL/$(dirname $SOURCE_DIR)$ROTATE_1_EXTENSION" ] + assertEquals "File rotated Presence [$TARGET_DIR_FILE_PULL/$(dirname $SOURCE_DIR)$ROTATE_1_EXTENSION]" "0" $? + + # Second test of presence of rotated files + REMOTE_HOST_PING=$RHOST_PING ./$OBACKUP_EXECUTABLE "$CONF_DIR/$PUSH_CONF" assertEquals "Return code" "0" $? for file in "${DatabasePresence[@]}"; do [ -f "$TARGET_DIR_SQL_PUSH/$file$ROTATE_1_EXTENSION" ] assertEquals "Database rotated Presence [$TARGET_DIR_SQL_PUSH/$file$ROTATE_1_EXTENSION]" "0" $? + [ -f "$TARGET_DIR_SQL_PUSH/$file$ROTATE_2_EXTENSION" ] + assertEquals "Database rotated Presence [$TARGET_DIR_SQL_PUSH/$file$ROTATE_2_EXTENSION]" "0" $? done [ -d "$TARGET_DIR_FILE_PUSH/$(dirname $SOURCE_DIR)$ROTATE_1_EXTENSION" ] assertEquals "File rotated Presence [$TARGET_DIR_FILE_PUSH/$(dirname $SOURCE_DIR)$ROTATE_1_EXTENSION]" "0" $? - + [ -d "$TARGET_DIR_FILE_PUSH/$(dirname $SOURCE_DIR)$ROTATE_2_EXTENSION" ] + assertEquals "File rotated Presence [$TARGET_DIR_FILE_PUSH/$(dirname $SOURCE_DIR)$ROTATE_2_EXTENSION]" "0" $? } function test_EncryptLocalRun () {