Skip to content

Commit

Permalink
Add e2e test for ignore error option for backup-delete.
Browse files Browse the repository at this point in the history
  • Loading branch information
woblerr committed Jun 4, 2024
1 parent b137db3 commit 9bb4c94
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
10 changes: 10 additions & 0 deletions e2e_tests/conf/gpbackup_s3_plugin_invalid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
executablepath: /home/gpbackman/gpbackup_s3_plugin
options:
region: us-west-1
endpoint: minio:9000
aws_access_key_id: demoInvalid
aws_secret_access_key: demoBackup
bucket: backup
folder: test
encryption: off
1 change: 1 addition & 0 deletions e2e_tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ services:
- "./src_data:/home/gpbackman/src_data"
- "./scripts/run_backup-delete.sh:/home/gpbackman/run_backup-delete.sh"
- "./conf/gpbackup_s3_plugin.yaml:/home/gpbackman/gpbackup_s3_plugin.yaml"
- "./conf/gpbackup_s3_plugin_invalid.yaml:/home/gpbackman/gpbackup_s3_plugin_invalid.yaml"
command: /home/gpbackman/run_backup-delete.sh
networks:
- e2e
Expand Down
39 changes: 38 additions & 1 deletion e2e_tests/scripts/run_backup-delete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ${WORK_DIR}
# The yaml history file format is used.
# History file yaml format is used, there are a real s3 call and a real backup deletion.

# At secod call, there are a real s3 call and no real backup deletion.
# At second call, there are a real s3 call and no real backup deletion.
# The sqlite history file format is used.
# Because this backup was deleted in first call, there are no files in the s3.
# But the info about deletion attempt is written to log file and DATE DELETED is updated in history file.
Expand Down Expand Up @@ -114,5 +114,42 @@ if [ $? == 0 ]; then
fi
echo "[INFO] ${GPBACKMAN_TEST_COMMAND} test ${TEST_ID} passed."

################################################################
# Test 4.
# Test ignore errors option.

TEST_ID="4"

# After previous tests, in history there should be 6 backup with dete deleted info.
# In this test we use plugin config with invalid aws_access_key_id for s3.
# The error occurs:
# InvalidAccessKeyId: The Access Key Id you provided does not exist in our records.
#
# With --force and --ignore-errors, the error that occurs is ignored and the backup is marked as deleted.
TEST_CNT=7

TIMESTAMP="20230721090000"

set -x
# Execute backup-delete commnad.
gpbackman ${GPBACKMAN_TEST_COMMAND} \
--history-db ${WORK_DIR}/gpbackup_history.db \
--timestamp ${TIMESTAMP} \
--plugin-config ${HOME_DIR}/gpbackup_s3_plugin_invalid.yaml \
--force \
--ignore-errors

GPBACKMAN_RESULT_SQLITE=$(gpbackman backup-info \
--history-db ${WORK_DIR}/gpbackup_history.db \
--deleted)

echo "[INFO] ${GPBACKMAN_TEST_COMMAND} test ${TEST_ID}."
result_cnt_sqlite=$(echo "${GPBACKMAN_RESULT_SQLITE}" | cut -f9 -d'|' | awk '{$1=$1};1' | grep -E ${DATE_REGEX} | wc -l)
if [ "${result_cnt_sqlite}" != "${TEST_CNT}" ]; then
echo -e "[ERROR] ${GPBACKMAN_TEST_COMMAND} test ${TEST_ID} failed.\nget_sqlite=${result_cnt_sqlite}, want=${TEST_CNT}"
exit 1
fi
echo "[INFO] ${GPBACKMAN_TEST_COMMAND} test ${TEST_ID} passed."

echo "[INFO] ${GPBACKMAN_TEST_COMMAND} all tests passed"
exit 0

0 comments on commit 9bb4c94

Please sign in to comment.