Commit 80796322 authored by QM's avatar QM Committed by 33cn

export x2eth logs

parent 5f158371
...@@ -12,6 +12,26 @@ RED='\033[1;31m' ...@@ -12,6 +12,26 @@ RED='\033[1;31m'
GRE='\033[1;32m' GRE='\033[1;32m'
NOC='\033[0m' NOC='\033[0m'
# 出错退出前拷贝日志文件
function exit_cp_file() {
ls
# shellcheck disable=SC2116
dirNameFa=$( echo ~ )
dirName="$dirNameFa/x2ethereumlogs"
if [ ! -d "${dirName}" ]; then
# shellcheck disable=SC2086
mkdir -p ${dirName}
fi
for name in A B C D; do
cp "./$name/ebrelayer.log" "$dirName/ebrelayer$name.log"
done
docker cp "${NODE3}":/root/logs/chain33.log "$dirName/chain33.log"
exit 1
}
function kill_all_ebrelayer() { function kill_all_ebrelayer() {
for name in A B C D; do for name in A B C D; do
local ebrelayer="./../build/$name/ebrelayer" local ebrelayer="./../build/$name/ebrelayer"
...@@ -24,13 +44,13 @@ function cli_ret() { ...@@ -24,13 +44,13 @@ function cli_ret() {
set +x set +x
if [[ $# -lt 2 ]]; then if [[ $# -lt 2 ]]; then
echo -e "${RED}wrong parameter${NOC}" echo -e "${RED}wrong parameter${NOC}"
exit 1 exit_cp_file
fi fi
ok=$(echo "${1}" | jq -r .isOK) ok=$(echo "${1}" | jq -r .isOK)
if [[ ${ok} != "true" ]]; then if [[ ${ok} != "true" ]]; then
echo -e "${RED}failed to ${2}${NOC}" echo -e "${RED}failed to ${2}${NOC}"
exit 1 exit_cp_file
fi fi
local jqMsg=".msg" local jqMsg=".msg"
...@@ -42,7 +62,7 @@ function cli_ret() { ...@@ -42,7 +62,7 @@ function cli_ret() {
if [[ $# -eq 4 ]]; then if [[ $# -eq 4 ]]; then
if [ "$(echo "$msg < $4" | bc)" -eq 1 ] || [ "$(echo "$msg > $4" | bc)" -eq 1 ]; then if [ "$(echo "$msg < $4" | bc)" -eq 1 ] || [ "$(echo "$msg > $4" | bc)" -eq 1 ]; then
echo -e "${RED}The balance is not correct${NOC}" echo -e "${RED}The balance is not correct${NOC}"
exit 1 exit_cp_file
fi fi
fi fi
...@@ -55,13 +75,13 @@ function balance_ret() { ...@@ -55,13 +75,13 @@ function balance_ret() {
set +x set +x
if [[ $# -lt 2 ]]; then if [[ $# -lt 2 ]]; then
echo -e "${RED}wrong parameter${NOC}" echo -e "${RED}wrong parameter${NOC}"
exit 1 exit_cp_file
fi fi
local balance=$(echo "${1}" | jq -r ".balance") local balance=$(echo "${1}" | jq -r ".balance")
if [ "$(echo "$balance < $2" | bc)" -eq 1 ] || [ "$(echo "$balance > $2" | bc)" -eq 1 ]; then if [ "$(echo "$balance < $2" | bc)" -eq 1 ] || [ "$(echo "$balance > $2" | bc)" -eq 1 ]; then
echo -e "${RED}The balance is not correct${NOC}" echo -e "${RED}The balance is not correct${NOC}"
exit 1 exit_cp_file
fi fi
set -x set -x
...@@ -75,7 +95,7 @@ function cli_ret_err() { ...@@ -75,7 +95,7 @@ function cli_ret_err() {
echo "${ok}" echo "${ok}"
if [[ ${ok} == "true" ]]; then if [[ ${ok} == "true" ]]; then
echo -e "${RED}isOK is true${NOC}" echo -e "${RED}isOK is true${NOC}"
exit 1 exit_cp_file
fi fi
#set -x #set -x
} }
...@@ -103,13 +123,13 @@ function start_ebrelayer() { ...@@ -103,13 +123,13 @@ function start_ebrelayer() {
# 参数如果小于 2 直接报错 # 参数如果小于 2 直接报错
if [[ $# -lt 2 ]]; then if [[ $# -lt 2 ]]; then
echo -e "${RED}wrong parameter${NOC}" echo -e "${RED}wrong parameter${NOC}"
exit 1 exit_cp_file
fi fi
# 判断可执行文件是否存在 # 判断可执行文件是否存在
if [ ! -x "${1}" ]; then if [ ! -x "${1}" ]; then
echo -e "${RED}${1} not exist${NOC}" echo -e "${RED}${1} not exist${NOC}"
exit 1 exit_cp_file
fi fi
# 后台启动程序 # 后台启动程序
...@@ -126,7 +146,7 @@ function start_ebrelayer() { ...@@ -126,7 +146,7 @@ function start_ebrelayer() {
count=$((count + 1)) count=$((count + 1))
if [[ ${count} -ge 20 ]]; then if [[ ${count} -ge 20 ]]; then
echo -e "${RED}start ${1} failed${NOC}" echo -e "${RED}start ${1} failed${NOC}"
exit 1 exit_cp_file
fi fi
# shellcheck disable=SC2009 # shellcheck disable=SC2009
...@@ -150,7 +170,7 @@ function start_ebrelayer_and_unlock() { ...@@ -150,7 +170,7 @@ function start_ebrelayer_and_unlock() {
count=$((count + 1)) count=$((count + 1))
if [[ ${count} == 5 ]]; then if [[ ${count} == 5 ]]; then
echo -e "${RED}failed to unlock${NOC}" echo -e "${RED}failed to unlock${NOC}"
exit 1 exit_cp_file
fi fi
sleep 1 sleep 1
...@@ -173,7 +193,7 @@ function start_ebrelayer_and_setpwd_unlock() { ...@@ -173,7 +193,7 @@ function start_ebrelayer_and_setpwd_unlock() {
count=$((count + 1)) count=$((count + 1))
if [[ ${count} == 5 ]]; then if [[ ${count} == 5 ]]; then
echo -e "${RED}failed to set_pwd${NOC}" echo -e "${RED}failed to set_pwd${NOC}"
exit 1 exit_cp_file
fi fi
sleep 1 sleep 1
...@@ -189,7 +209,7 @@ function start_ebrelayer_and_setpwd_unlock() { ...@@ -189,7 +209,7 @@ function start_ebrelayer_and_setpwd_unlock() {
count=$((count + 1)) count=$((count + 1))
if [[ ${count} == 5 ]]; then if [[ ${count} == 5 ]]; then
echo -e "${RED}failed to unlock${NOC}" echo -e "${RED}failed to unlock${NOC}"
exit 1 exit_cp_file
fi fi
sleep 1 sleep 1
...@@ -222,7 +242,7 @@ function block_wait() { ...@@ -222,7 +242,7 @@ function block_wait() {
if [[ $# -lt 1 ]]; then if [[ $# -lt 1 ]]; then
echo -e "${RED}wrong block_wait parameter${NOC}" echo -e "${RED}wrong block_wait parameter${NOC}"
exit 1 exit_cp_file
fi fi
local cur_height=$(${CLI} block last_header | jq ".height") local cur_height=$(${CLI} block last_header | jq ".height")
...@@ -250,12 +270,12 @@ function check_tx() { ...@@ -250,12 +270,12 @@ function check_tx() {
if [[ $# -lt 2 ]]; then if [[ $# -lt 2 ]]; then
echo -e "${RED}wrong check_tx parameters${NOC}" echo -e "${RED}wrong check_tx parameters${NOC}"
exit 1 exit_cp_file
fi fi
if [[ ${2} == "" ]]; then if [[ ${2} == "" ]]; then
echo -e "${RED}wrong check_tx txHash is empty${NOC}" echo -e "${RED}wrong check_tx txHash is empty${NOC}"
exit 1 exit_cp_file
fi fi
local count=0 local count=0
...@@ -279,19 +299,19 @@ function check_tx() { ...@@ -279,19 +299,19 @@ function check_tx() {
ty=$(${CLI} tx query -s "${2}" | jq .receipt.ty) ty=$(${CLI} tx query -s "${2}" | jq .receipt.ty)
if [[ ${ty} != 2 ]]; then if [[ ${ty} != 2 ]]; then
echo -e "${RED}check tx error, hash is ${2}${NOC}" echo -e "${RED}check tx error, hash is ${2}${NOC}"
exit 1 exit_cp_file
fi fi
} }
function check_number() { function check_number() {
if [[ $# -lt 2 ]]; then if [[ $# -lt 2 ]]; then
echo -e "${RED}wrong check number parameters${NOC}" echo -e "${RED}wrong check number parameters${NOC}"
exit 1 exit_cp_file
fi fi
if [ "$(echo "$1 < $2" | bc)" -eq 1 ] || [ "$(echo "$1 > $2" | bc)" -eq 1 ]; then if [ "$(echo "$1 < $2" | bc)" -eq 1 ] || [ "$(echo "$1 > $2" | bc)" -eq 1 ]; then
echo -e "${RED}error number, expect ${1}, get ${2}${NOC}" echo -e "${RED}error number, expect ${1}, get ${2}${NOC}"
exit 1 exit_cp_file
fi fi
} }
...@@ -299,13 +319,13 @@ function check_number() { ...@@ -299,13 +319,13 @@ function check_number() {
function check_addr() { function check_addr() {
if [[ $# -lt 2 ]]; then if [[ $# -lt 2 ]]; then
echo -e "${RED}wrong check number parameters${NOC}" echo -e "${RED}wrong check number parameters${NOC}"
exit 1 exit_cp_file
fi fi
addr=$(echo "${1}" | jq -r ".acc.addr") addr=$(echo "${1}" | jq -r ".acc.addr")
if [[ ${addr} != "${2}" ]]; then if [[ ${addr} != "${2}" ]]; then
echo -e "${RED}error addr, expect ${1}, get ${2}${NOC}" echo -e "${RED}error addr, expect ${1}, get ${2}${NOC}"
exit 1 exit_cp_file
fi fi
} }
...@@ -319,7 +339,7 @@ function updata_relayer_toml() { ...@@ -319,7 +339,7 @@ function updata_relayer_toml() {
local chain33Host=$(docker inspect "${NODE3}" | jq ".[].NetworkSettings.Networks" | grep "IPAddress" | awk '{ print $2}' | sed 's/\"//g' | sed 's/,//g') local chain33Host=$(docker inspect "${NODE3}" | jq ".[].NetworkSettings.Networks" | grep "IPAddress" | awk '{ print $2}' | sed 's/\"//g' | sed 's/,//g')
if [[ ${chain33Host} == "" ]]; then if [[ ${chain33Host} == "" ]]; then
echo -e "${RED}chain33Host is empty${NOC}" echo -e "${RED}chain33Host is empty${NOC}"
exit 1 exit_cp_file
fi fi
local pushHost=$(ifconfig wlp2s0 | grep "inet " | awk '{ print $2}' | awk -F: '{print $2}') local pushHost=$(ifconfig wlp2s0 | grep "inet " | awk '{ print $2}' | awk -F: '{print $2}')
...@@ -339,7 +359,7 @@ function updata_relayer_toml() { ...@@ -339,7 +359,7 @@ function updata_relayer_toml() {
if [[ ${pushHost} == "" ]]; then if [[ ${pushHost} == "" ]]; then
echo -e "${RED}pushHost is empty${NOC}" echo -e "${RED}pushHost is empty${NOC}"
exit 1 exit_cp_file
fi fi
local line=$(delete_line_show "${file}" "chain33Host") local line=$(delete_line_show "${file}" "chain33Host")
...@@ -447,7 +467,7 @@ function wait_prophecy_finish() { ...@@ -447,7 +467,7 @@ function wait_prophecy_finish() {
count=$((count + 1)) count=$((count + 1))
if [[ ${count} == 30 ]]; then if [[ ${count} == 30 ]]; then
echo -e "${RED}failed to get balance${NOC}" echo -e "${RED}failed to get balance${NOC}"
exit 1 exit_cp_file
fi fi
sleep 1 sleep 1
...@@ -460,7 +480,7 @@ function eth_block_wait() { ...@@ -460,7 +480,7 @@ function eth_block_wait() {
set +x set +x
if [[ $# -lt 0 ]]; then if [[ $# -lt 0 ]]; then
echo -e "${RED}wrong block_wait parameter${NOC}" echo -e "${RED}wrong block_wait parameter${NOC}"
exit 1 exit_cp_file
fi fi
local cur_height="" local cur_height=""
......
...@@ -14,7 +14,7 @@ function x2ethereum() { ...@@ -14,7 +14,7 @@ function x2ethereum() {
echo "========================== x2ethereum test ==========================" echo "========================== x2ethereum test =========================="
set +e set +e
set -x set -x
AllRelayerMainTest 1 AllRelayerMainTest 10
perf_test_main 10 perf_test_main 10
echo "========================== x2ethereum test end ==========================" echo "========================== x2ethereum test end =========================="
fi fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment