Skip to content

Commit

Permalink
<fix>(CI): add CI rare string test.
Browse files Browse the repository at this point in the history
  • Loading branch information
kyonRay committed Feb 20, 2024
1 parent 91ba2f2 commit 3bd82db
Show file tree
Hide file tree
Showing 7 changed files with 188 additions and 1 deletion.
55 changes: 55 additions & 0 deletions .ci/check_rare_string.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/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)
stringFromGet=$(echo "$get_output" | grep "Return values" | sed 's/Return values:\(.*\)/\1/' | tr -d '()')
md5_stringFromGet=$(echo -n "$stringFromGet" | $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}"
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 "$@"

14 changes: 14 additions & 0 deletions .ci/ci_cross_all_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -e
ROOT=$(pwd)/demo/
PLUGIN_BRANCH=master
final_rare_input=""

LOG_INFO() {
local content=${1}
Expand All @@ -14,6 +15,14 @@ LOG_ERROR() {
echo -e "\033[31m[ERROR] ${content}\033[0m"
}

prepare_rare_string() {
final_rare_input=$(bash ./gen_rare_string.sh)
}

check_rare_string() {
bash ./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
Expand Down Expand Up @@ -62,6 +71,8 @@ demo_test() {

ensure_bcos_nodes_running

prepare_rare_string

cd WeCross-Console/
bash start.sh <<EOF
listResources
Expand All @@ -83,13 +94,16 @@ call payment.bcos-gm.HelloWorld get
sendTransaction payment.bcos-gm.HelloWorld set Jerry
call payment.bcos-gm.HelloWorld get
sendTransaction payment.bcos-gm.HelloWorld set ${final_rare_input}
call payment.bcos-gm.HelloWorld get
quit
EOF
cd ..

check_log
check_console_log ${ROOT}/WeCross-Console/logs/warn.log
check_console_log ${ROOT}/WeCross-Console/logs/error.log
check_rare_string

}

Expand Down
14 changes: 14 additions & 0 deletions .ci/ci_cross_bcos3_demo_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -e
ROOT=$(pwd)/demo/
PLUGIN_BRANCH=master
final_rare_input=""

LOG_INFO() {
local content=${1}
Expand All @@ -14,6 +15,14 @@ LOG_ERROR() {
echo -e "\033[31m[ERROR] ${content}\033[0m"
}

prepare_rare_string() {
final_rare_input=$(bash ./gen_rare_string.sh)
}

check_rare_string() {
bash ./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
Expand Down Expand Up @@ -56,6 +65,8 @@ cross_bcos3_demo_test() {

bash build_cross_bcos3.sh -H 127.0.0.1 -P 3306 -u root -p 123456

prepare_rare_string

cd WeCross-Console/
bash start.sh <<EOF
listResources
Expand All @@ -68,13 +79,16 @@ call payment.bcos3.HelloWorld get
call payment.bcos3_gm.HelloWorld get
sendTransaction payment.bcos3_gm.HelloWorld set Jerry
call payment.bcos3_gm.HelloWorld get
sendTransaction payment.bcos3_gm.HelloWorld set ${final_rare_input}
call payment.bcos3_gm.HelloWorld get
quit
EOF
cd ..

check_log
check_console_log ${ROOT}/WeCross-Console/logs/warn.log
check_console_log ${ROOT}/WeCross-Console/logs/error.log
check_rare_string
}

prepare_wecross() {
Expand Down
14 changes: 13 additions & 1 deletion .ci/ci_cross_fabric2_demo_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -e
ROOT=$(pwd)/demo/
PLUGIN_BRANCH=master
final_rare_input=""

LOG_INFO() {
local content=${1}
Expand All @@ -14,6 +15,14 @@ LOG_ERROR() {
echo -e "\033[31m[ERROR] ${content}\033[0m"
}

prepare_rare_string() {
final_rare_input=$(bash ./gen_rare_string.sh)
}

check_rare_string() {
bash ./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
Expand Down Expand Up @@ -61,6 +70,7 @@ demo_test() {
bash build_cross_fabric2.sh -H 127.0.0.1 -P 3306 -u root -p 123456

ensure_bcos_nodes_running
prepare_rare_string

cd WeCross-Console/
bash start.sh <<EOF
Expand All @@ -73,14 +83,16 @@ sendTransaction payment.bcos.HelloWorld set Tom
call payment.bcos.HelloWorld get
sendTransaction payment.fabric2.sacc set a 666
call payment.fabric2.sacc query a
sendTransaction payment.fabric2.sacc set a ${final_rare_input}
call payment.fabric2.sacc query a
quit
EOF
cd ..

check_log
check_console_log ${ROOT}/WeCross-Console/logs/warn.log
check_console_log ${ROOT}/WeCross-Console/logs/error.log

check_rare_string
}

prepare_wecross() {
Expand Down
13 changes: 13 additions & 0 deletions .ci/ci_cross_gm_demo_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -e
ROOT=$(pwd)/demo/
PLUGIN_BRANCH=master
final_rare_input=""

LOG_INFO() {
local content=${1}
Expand All @@ -14,6 +15,14 @@ LOG_ERROR() {
echo -e "\033[31m[ERROR] ${content}\033[0m"
}

prepare_rare_string() {
final_rare_input=$(bash ./gen_rare_string.sh)
}

check_rare_string() {
bash ./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
Expand Down Expand Up @@ -55,6 +64,7 @@ cross_normal_guomi_demo_test() {
cd ${ROOT}

bash build_cross_gm.sh -H 127.0.0.1 -P 3306 -u root -p 123456
prepare_rare_string

cd WeCross-Console/
bash start.sh <<EOF
Expand All @@ -68,13 +78,16 @@ call payment.bcos.HelloWorld get
call payment.bcos_gm.HelloWorld get
sendTransaction payment.bcos_gm.HelloWorld set Jerry
call payment.bcos_gm.HelloWorld get
sendTransaction payment.bcos_gm.HelloWorld set ${final_rare_input}
call payment.bcos_gm.HelloWorld get
quit
EOF
cd ..

check_log
check_console_log ${ROOT}/WeCross-Console/logs/warn.log
check_console_log ${ROOT}/WeCross-Console/logs/error.log
check_rare_string
}

prepare_wecross() {
Expand Down
11 changes: 11 additions & 0 deletions .ci/ci_demo_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -e
ROOT=$(pwd)/demo/
PLUGIN_BRANCH=master
final_rare_input=""

LOG_INFO() {
local content=${1}
Expand All @@ -13,7 +14,13 @@ LOG_ERROR() {
local content=${1}
echo -e "\033[31m[ERROR] ${content}\033[0m"
}
prepare_rare_string() {
final_rare_input=$(bash ./gen_rare_string.sh)
}

check_rare_string() {
bash ./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
Expand Down Expand Up @@ -61,6 +68,7 @@ demo_test() {
bash -x build.sh -H 127.0.0.1 -P 3306 -u root -p 123456

ensure_bcos_nodes_running
prepare_rare_string

cd WeCross-Console/
bash start.sh <<EOF
Expand All @@ -74,13 +82,16 @@ call payment.bcos.HelloWorld get
call payment.fabric.sacc query a
sendTransaction payment.fabric.sacc set a 666
call payment.fabric.sacc query a
sendTransaction payment.fabric.sacc set a ${final_rare_input}
call payment.fabric.sacc query a
quit
EOF
cd ..

check_log
check_console_log ${ROOT}/WeCross-Console/logs/warn.log
check_console_log ${ROOT}/WeCross-Console/logs/error.log
check_rare_string

}

Expand Down
68 changes: 68 additions & 0 deletions .ci/gen_rare_string.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash
rare_str_range_names=("CJKUnifiedIdeographs" "CJKCompatibilityIdeographs" "CJKCompatibilityIdeographsSupplement" "KangxiRadicals" "CJKRadicalsSupplement" "IdeographicDescriptionCharacters" "Bopomofo" "BopomofoExtended" "CJKStrokes" "CJKSymbolsandPunctuation" "CJKCompatibilityForms" "CJKCompatibility" "EnclosedCJKLettersandMonths" "CJKUnifiedIdeographsExtensionA" "CJKUnifiedIdeographsExtensionB" "CJKUnifiedIdeographsExtensionC" "CJKUnifiedIdeographsExtensionD" "CJKUnifiedIdeographsExtensionE" "CJKUnifiedIdeographsExtensionF")
rare_str_range_values=("19968,40959" "63744,64255" "194560,195103" "12032,12255" "11904,12031" "12272,12287" "12544,12591" "12704,12735" "12736,12783" "12288,12351" "65072,65103" "13056,13311" "12800,13055" "13312,19903" "131072,173791" "173824,177977" "177984,178205" "178208,183969" "183984,191456")
final_rare_input=""

LOG_INFO() {
local content=${1}
echo -e "\033[32m[INFO] ${content}\033[0m"
}

LOG_ERROR() {
local content=${1}
echo -e "\033[31m[ERROR] ${content}\033[0m"
}

download_rare_string_jar() {
LOG_INFO "----- Downloading get-rare-string-with-unicode.jar -------"
curl -LO "https://github.com/FISCO-BCOS/LargeFiles/raw/master/binaries/jar/get-rare-string-with-unicode.jar"
}

getRangeValues() {
local rangeValue=$1
IFS=',' read -r startValue endValue <<<"$rangeValue"

echo "$startValue $endValue"
}

getConcatenatedRareStringWithRange() {
local startUnicode=${1}
local endUnicode=${2}

# concatenate strings with begin middle end
local concatenatedString
concatenatedString=$(java -cp './get-rare-string-with-unicode.jar' org.example.Main ${startUnicode})
local midUnicode=$((($startUnicode + $endUnicode) / 2))
for ((i = midUnicode; i <= midUnicode + 5; i++)); do
local currentRareString
currentRareString=$(java -cp './get-rare-string-with-unicode.jar' org.example.Main ${i})
concatenatedString+="$currentRareString"
done
local endRareString
endRareString=$(java -cp './get-rare-string-with-unicode.jar' org.example.Main ${endUnicode})
concatenatedString+="$endRareString"
echo "$concatenatedString"
}

get_rare_string() {
download_rare_string_jar
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8

for ((i = 0; i < ${#rare_str_range_names[@]}; i++)); do
range_name="${rare_str_range_names[$i]}"
range_value="${rare_str_range_values[$i]}"

read -r start_value end_value <<<$(getRangeValues "${range_value}")
concatenated=$(getConcatenatedRareStringWithRange $start_value $end_value)
final_rare_input+="${concatenated}"
done
}

main() {
get_rare_string
echo "${final_rare_input}"
}

main

0 comments on commit 3bd82db

Please sign in to comment.