From a461feab01100de91a10e6d6c60b1f467f20fc79 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Mon, 17 Jan 2022 11:55:43 +0300 Subject: [PATCH] [#304] Add update of results for chosen storage Signed-off-by: Denis Kirillov --- updateTestsResult.sh | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/updateTestsResult.sh b/updateTestsResult.sh index e7c9336b..4a39fdd6 100755 --- a/updateTestsResult.sh +++ b/updateTestsResult.sh @@ -1,8 +1,28 @@ #!/bin/bash INPUT_FILE=$1 +if [ -z "$INPUT_FILE" ]; then + echo "you must provide file with tests results" + exit 1 +fi + +STORAGE=$2 +if [ "$STORAGE" != "s3gw" ] && [ "$STORAGE" != "minio" ] && [ "$STORAGE" != "aws" ]; then + echo "you must specify storage type [s3gw | minio | aws]" + exit 1 +fi + RESULT_FILE=docs/s3_test_results.md +get_adjusted_result () { + local OLD_RESULT=$1 + local NEW_RESULT=$2 + local OLD_RESULT_LEN=${#OLD_RESULT} + local NEW_RESULT_LEN=${#NEW_RESULT} + local ADDITIONAL_SPACES=$((OLD_RESULT_LEN - NEW_RESULT_LEN)) + printf "%s%*s" "$NEW_RESULT" $ADDITIONAL_SPACES '' +} + while read -r line; do RES_LINE=$(echo "$line" | sed -nE '/^s3tests_boto3/p') @@ -12,12 +32,21 @@ do RESULT=$(echo "$RES_LINE" | sed -e 's/^.*\.\.\.[[:space:]]*//') # beautify trailing spaces - OLD_RESULT=$(sed -n "s/^.*${TEST}[[:space:]]*|[[:space:]]\(.*\)[[:space:]]|.*|$/\1/p" "$RESULT_FILE") - OLD_RESULT_LEN=${#OLD_RESULT} - RESULT_LEN=${#RESULT} - ADDITIONAL_SPACES=$((OLD_RESULT_LEN - RESULT_LEN)) - ADJUSTED_RESULT=$(printf "%s%*s" "$RESULT" $ADDITIONAL_SPACES '') + OLD_RESULT_S3GW=$(sed -n "s/^.*${TEST}[[:space:]]*|[[:space:]]\(.*\)[[:space:]]|.*|.*|$/\1/p" "$RESULT_FILE") + OLD_RESULT_MINIO=$(sed -n "s/^.*${TEST}[[:space:]]*|.*|[[:space:]]\(.*\)[[:space:]]|.*|$/\1/p" "$RESULT_FILE") + OLD_RESULT_AWS=$(sed -n "s/^.*${TEST}[[:space:]]*|.*|.*|[[:space:]]\(.*\)[[:space:]]|$/\1/p" "$RESULT_FILE") + + ADJUSTED_RESULT_S3GW=$(get_adjusted_result "$OLD_RESULT_S3GW" "$RESULT") + ADJUSTED_RESULT_MINIO=$(get_adjusted_result "$OLD_RESULT_MINIO" "$RESULT") + ADJUSTED_RESULT_AWS=$(get_adjusted_result "$OLD_RESULT_AWS" "$RESULT") + + if [ "$STORAGE" = "s3gw" ]; then + sed -i "/UNSUPPORTED/! s/^\(.*${TEST}[[:space:]]*\)|[[:space:]].*[[:space:]]|\(.*\)$/\1| ${ADJUSTED_RESULT_S3GW} | ${OLD_RESULT_MINIO} | ${OLD_RESULT_AWS} |\2/" "$RESULT_FILE" + elif [ "$STORAGE" = "minio" ]; then + sed -i "/UNSUPPORTED/! s/^\(.*${TEST}[[:space:]]*\)|[[:space:]].*[[:space:]]|\(.*\)$/\1| ${OLD_RESULT_S3GW} | ${ADJUSTED_RESULT_MINIO} | ${OLD_RESULT_AWS} |\2/" "$RESULT_FILE" + else + sed -i "/UNSUPPORTED/! s/^\(.*${TEST}[[:space:]]*\)|[[:space:]].*[[:space:]]|\(.*\)$/\1| ${OLD_RESULT_S3GW} | ${OLD_RESULT_MINIO} | ${ADJUSTED_RESULT_AWS} |\2/" "$RESULT_FILE" + fi - sed -i "/UNSUPPORTED/! s/^\(.*${TEST}[[:space:]]*\)|[[:space:]].*[[:space:]]|\(.*|\)$/\1| ${ADJUSTED_RESULT} |\2/" "$RESULT_FILE" fi done < "$INPUT_FILE"