mirror of
https://github.com/versity/versitygw.git
synced 2026-08-23 23:56:28 +00:00
test: fix
This commit is contained in:
@@ -64,7 +64,7 @@ head_bucket_rest() {
|
||||
return 1
|
||||
fi
|
||||
if ! result=$(COMMAND_LOG="$COMMAND_LOG" BUCKET_NAME="$1" OUTPUT_FILE="$TEST_FILE_FOLDER/$result_file" ./tests/rest_scripts/head_bucket.sh 2>&1); then
|
||||
log 2 "error getting head bucket: $result"
|
||||
log 2 "error with HeadBucket command: $result"
|
||||
return 2
|
||||
fi
|
||||
local callback_code=0
|
||||
|
||||
@@ -15,9 +15,13 @@
|
||||
# under the License.
|
||||
|
||||
source ./tests/env.sh
|
||||
source ./tests/drivers/delete_bucket/delete_bucket_rest.sh
|
||||
|
||||
setup_env() {
|
||||
TEST_ID=$(date +"%Y%m%d-%H%M%S").$(basename "$BATS_TEST_FILENAME").$BATS_TEST_NAME
|
||||
TEST_ID=$(date +"%Y%m%d-%H%M%S")
|
||||
if [ -n "$BATS_TEST_FILENAME" ]; then
|
||||
TEST_ID+=".$(basename "$BATS_TEST_FILENAME").$BATS_TEST_NAME"
|
||||
fi
|
||||
export TEST_ID
|
||||
|
||||
source_config_file
|
||||
@@ -31,7 +35,9 @@ setup_env() {
|
||||
printf "\n%s\n\n" "**** $TEST_ID ****" >> "${TEST_LOG_FILE}.${TEST_ID}"
|
||||
fi
|
||||
|
||||
log 4 "Running test $BATS_TEST_NAME"
|
||||
if [ -n "$BATS_TEST_NAME" ]; then
|
||||
log 4 "Running test $BATS_TEST_NAME"
|
||||
fi
|
||||
if [[ $LOG_LEVEL -ge 5 ]] || [[ -n "$TIME_LOG" ]]; then
|
||||
START_TIME=$(date +%s)
|
||||
export START_TIME
|
||||
@@ -77,6 +83,21 @@ setup_versitygw() {
|
||||
return 0
|
||||
}
|
||||
|
||||
setup_env_and_versitygw() {
|
||||
local response
|
||||
|
||||
if ! setup_env; then
|
||||
log 1 "error setting up env"
|
||||
return 1
|
||||
fi
|
||||
if ! response=$(setup_versitygw "$@" 2>&1); then
|
||||
log 2 "error setting up versitygw: $response"
|
||||
return 1
|
||||
fi
|
||||
export VERSITYGW_PID_1="$response"
|
||||
return 0
|
||||
}
|
||||
|
||||
setup_clients() {
|
||||
if [[ $RUN_S3CMD == true ]]; then
|
||||
S3CMD_OPTS=()
|
||||
@@ -103,16 +124,27 @@ teardown_common() {
|
||||
|
||||
log 5 "proc status one: '$proc_status_one'"
|
||||
if [ "$proc_status_one" == "none" ] || [[ ( "$proc_status_one" == "running" ) && (( "$proc_status_two" == "none") || ( "$proc_status_two" == "running")) ]]; then
|
||||
bucket_and_user_cleanup
|
||||
if ! bucket_and_user_cleanup; then
|
||||
log 3 "bucket and user cleanup not properly done"
|
||||
fi
|
||||
fi
|
||||
if [ "$proc_status_one" == "running" ]; then
|
||||
stop_versity_process "$VERSITYGW_PID_1"
|
||||
if ! stop_versity_process "$VERSITYGW_PID_1"; then
|
||||
log 3 "unable to properly stop versitygw process"
|
||||
fi
|
||||
fi
|
||||
if [ "$proc_status_two" == "running" ]; then
|
||||
stop_versity_process "$VERSITYGW_PID_2"
|
||||
if ! stop_versity_process "$VERSITYGW_PID_2"; then
|
||||
log 3 "unable to properly stop second versity process"
|
||||
fi
|
||||
fi
|
||||
remove_test_file_folder_if_desired
|
||||
teardown_logs
|
||||
if ! remove_test_file_folder_if_desired; then
|
||||
log 3 "test file folder cleanup error"
|
||||
fi
|
||||
if ! teardown_logs; then
|
||||
log 3 "log file teardown error"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
static_user_v1_cleanup() {
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
source ./tests/env.sh
|
||||
source ./tests/logger.sh
|
||||
source ./tests/setup_env_and_versitygw.sh
|
||||
source ./tests/util/util_object.sh
|
||||
source ./tests/commands/create_bucket.sh
|
||||
source ./tests/drivers/put_bucket_ownership_controls/put_bucket_ownership_controls_rest.sh
|
||||
@@ -40,7 +41,11 @@ create_bucket_if_not_exists() {
|
||||
return 0
|
||||
}
|
||||
|
||||
base_setup
|
||||
if ! setup_env_and_versitygw; then
|
||||
log 1 "error setting up env and/or versitygw"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! create_bucket_if_not_exists "$BUCKET_ONE_NAME"; then
|
||||
log 2 "error creating static bucket one"
|
||||
elif ! create_bucket_if_not_exists "$BUCKET_TWO_NAME"; then
|
||||
@@ -49,6 +54,6 @@ fi
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
RECREATE_BUCKETS=false
|
||||
if ! stop_versity_process "$VERSITYGW_PID_1"; then
|
||||
log 2 "error stopping versity"
|
||||
if ! teardown_common; then
|
||||
log 2 "teardown error"
|
||||
fi
|
||||
|
||||
+3
-2
@@ -40,9 +40,10 @@ build_run_and_log_command() {
|
||||
if ! check_param_count_gt "versitygw process number (1 or 2), command array" 2 $#; then
|
||||
return 1
|
||||
fi
|
||||
local process_number="$1" command_array=("${@:2}")
|
||||
local response full_command versitygw_log_file_name="" pid check_result
|
||||
|
||||
IFS=' ' read -r -a full_command <<< "${@:2}"
|
||||
IFS=' ' read -r -a full_command <<< "${command_array[@]}"
|
||||
log 5 "versity command: ${full_command[*]}"
|
||||
if [ -n "$COMMAND_LOG" ]; then
|
||||
if ! response=$(mask_args "${full_command[*]}" 2>&1); then
|
||||
@@ -53,7 +54,7 @@ build_run_and_log_command() {
|
||||
echo "$response" >> "$COMMAND_LOG"
|
||||
fi
|
||||
if [ -n "$VERSITY_LOG_FILE" ]; then
|
||||
versitygw_log_file_name="$VERSITY_LOG_FILE.$TEST_ID".$1
|
||||
versitygw_log_file_name="$VERSITY_LOG_FILE.$TEST_ID".$process_number
|
||||
printf '****************************** VERSITYGW %s LOG \***********************************\n' "$1" >> "$versitygw_log_file_name"
|
||||
"${full_command[@]}" >> "$versitygw_log_file_name" 2>&1 &
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user