From fdedc3d73fdecceeb51bc82bc465425a0ec0e977 Mon Sep 17 00:00:00 2001 From: kyonRay Date: Tue, 20 Feb 2024 10:34:34 +0800 Subject: [PATCH] (CI): add CI rare string test. --- .ci/check_rare_string.sh | 54 ++++++++++++++++++++++++ .ci/ci_cross_all_check.sh | 15 +++++++ .ci/ci_cross_bcos3_demo_check.sh | 15 +++++++ .ci/ci_cross_fabric2_demo_check.sh | 15 ++++++- .ci/ci_cross_gm_demo_check.sh | 13 ++++++ .ci/ci_demo_check.sh | 12 ++++++ .ci/gen_rare_string.sh | 67 ++++++++++++++++++++++++++++++ scripts/download_console.sh | 4 +- 8 files changed, 192 insertions(+), 3 deletions(-) create mode 100644 .ci/check_rare_string.sh create mode 100644 .ci/gen_rare_string.sh diff --git a/.ci/check_rare_string.sh b/.ci/check_rare_string.sh new file mode 100644 index 000000000..fa2555b20 --- /dev/null +++ b/.ci/check_rare_string.sh @@ -0,0 +1,54 @@ +#!/bin/bash + + + +function LOG_ERROR() +{ + local content=${1} + echo -e "\033[31m"${content}"\033[0m" +} + +function LOG_INFO() +{ + local content=${1} + echo -e "\033[32m"${content}"\033[0m" +} + +get_md5sum_cmd() { + local md5sum_cmd="md5sum" + if [ "$(uname)" == "Darwin" ]; then + md5sum_cmd="md5" + fi + echo "$md5sum_cmd" +} + +function checkConcatenatedRareString() { + + concatenatedString=${1} + log_file=${2} + md5sum_cmd=$(get_md5sum_cmd) + + md5_concatenatedString=$(echo -n "$concatenatedString" | $md5sum_cmd | awk '{print $1}') + + # compare rare string and stringFromGet + get_output=$(cat ${log_file}| grep "result=" | awk -F '[][]' '{print $4}' | awk NF | tail -n 1) + md5_stringFromGet=$(echo -n "$get_output" | $md5sum_cmd | awk '{print $1}') + if [ "$md5_concatenatedString" != "$md5_stringFromGet" ]; then + LOG_ERROR "error: check failed, the md5 values of rareString and stringFromGet are not equal, fail concatenatedString: ${concatenatedString}, get_output: ${get_output}" + exit 1 + else + LOG_INFO "check success, concatenatedString: ${concatenatedString}" + fi +} + +main() { + concatenatedString=${1} + log_file=${2} + LOG_INFO "check rare string start, concatenatedString: ${concatenatedString}" + + checkConcatenatedRareString ${concatenatedString} ${log_file} + LOG_INFO "check rare string finished!" +} + +main "$@" + diff --git a/.ci/ci_cross_all_check.sh b/.ci/ci_cross_all_check.sh index 937bdc7c9..1a8390345 100644 --- a/.ci/ci_cross_all_check.sh +++ b/.ci/ci_cross_all_check.sh @@ -2,7 +2,9 @@ set -e ROOT=$(pwd)/demo/ +CI_PWD=$(pwd) PLUGIN_BRANCH=master +final_rare_input="" LOG_INFO() { local content=${1} @@ -14,6 +16,14 @@ LOG_ERROR() { echo -e "\033[31m[ERROR] ${content}\033[0m" } +prepare_rare_string() { + final_rare_input=$(bash ${CI_PWD}/.ci/gen_rare_string.sh) +} + +check_rare_string() { + bash ${CI_PWD}/.ci/check_rare_string.sh ${final_rare_input} ${ROOT}/WeCross-Console/logs/debug.log +} + check_log() { cd ${ROOT} error_log=routers-payment/127.0.0.1-8250-25500/logs/error.log @@ -62,6 +72,8 @@ demo_test() { ensure_bcos_nodes_running + prepare_rare_string + cd WeCross-Console/ bash start.sh <