Commit 9e7995d5 authored by mdj33's avatar mdj33 Committed by vipwzw

1, ignore email send fail

2, add para docker exit check
parent 5e735848
...@@ -47,17 +47,34 @@ pipeline { ...@@ -47,17 +47,34 @@ pipeline {
success { success {
echo 'I succeeeded!' echo 'I succeeeded!'
echo "email user: ${ghprbActualCommitAuthorEmail}" echo "email user: ${ghprbActualCommitAuthorEmail}"
mail to: "${ghprbActualCommitAuthorEmail}", script{
subject: "Successed Pipeline: ${currentBuild.fullDisplayName}", try {
body: "this is success with ${env.BUILD_URL}" mail to: "${ghprbActualCommitAuthorEmail}",
subject: "Successed Pipeline: ${currentBuild.fullDisplayName}",
body: "this is success with ${env.BUILD_URL}"
}
catch (err){
echo "email err"
}
}
echo currentBuild.result
} }
failure { failure {
echo 'I failed ' echo 'I failed '
echo "email user: ${ghprbActualCommitAuthorEmail}" echo "email user: ${ghprbActualCommitAuthorEmail}"
mail to: "${ghprbActualCommitAuthorEmail}", script{
subject: "Failed Pipeline: ${currentBuild.fullDisplayName}", try {
body: "Something is wrong with ${env.BUILD_URL}" mail to: "${ghprbActualCommitAuthorEmail}",
subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
body: "Something is wrong with ${env.BUILD_URL}"
}catch (err){
echo "email err"
}
}
echo currentBuild.result
} }
} }
} }
...@@ -215,7 +215,8 @@ function block_wait() { ...@@ -215,7 +215,8 @@ function block_wait() {
function check_docker_status() { function check_docker_status() {
status=$(docker-compose ps | grep chain33_1 | awk '{print $6}') status=$(docker-compose ps | grep chain33_1 | awk '{print $6}')
if [ "${status}" == "Exit" ]; then statusPara=$(docker-compose ps | grep chain33_1 | awk '{print $3}')
if [ "${status}" == "Exit" or "${statusPara}" == "Exit" ]; then
echo "=========== chain33 service Exit logs ========== " echo "=========== chain33 service Exit logs ========== "
docker-compose logs chain33 docker-compose logs chain33
echo "=========== chain33 service Exit logs End========== " echo "=========== chain33 service Exit logs End========== "
......
FROM ubuntu:16.04
WORKDIR /root
COPY chain33 ./
COPY chain33-cli ./
COPY autotest ./
COPY *.toml ./
CMD ["/root/chain33", "-f", "/root/chain33.toml"]
version: '3'
services:
chain33:
build:
context: .
dockerfile: Dockerfile-autotest
container_name: autotest-chain33
chain32:
build:
context: .
dockerfile: Dockerfile-autotest
container_name: autotest-chain32
#!/usr/bin/env bash
set -e
set -o pipefail
#set -o verbose
#set -o xtrace
# os: ubuntu16.04 x64
# first, you must install jq tool of json
# sudo apt-get install jq
# sudo apt-get install shellcheck, in order to static check shell script
# sudo apt-get install parallel
PWD=$(cd "$(dirname "$0")" && pwd)
export PATH="$PWD:$PATH"
CLI="./chain33-cli"
sedfix=""
if [ "$(uname)" == "Darwin" ]; then
sedfix=".bak"
fi
chain33Config="chain33.test.toml"
chain33BlockTime=2
function init() {
# update test environment
echo "# copy chain33 for solo test"
cp ../../chain33 ./
cp ../../chain33-cli ./
cp ../../../cmd/chain33/chain33.test.toml ./
}
function config_chain33() {
# shellcheck disable=SC2015
echo "# config chain33 solo test"
# update test environment
sed -i $sedfix 's/^Title.*/Title="local"/g' ${chain33Config}
# grep -q '^TestNet' ${chain33Config} && sed -i $sedfix 's/^TestNet.*/TestNet=true/' ${chain33Config} || sed -i '/^Title/a TestNet=true' ${chain33Config}
if grep -q '^TestNet' ${chain33Config}; then
sed -i $sedfix 's/^TestNet.*/TestNet=true/' ${chain33Config}
else
sed -i $sedfix '/^Title/a TestNet=true' ${chain33Config}
fi
#update fee
sed -i $sedfix 's/Fee=.*/Fee=100000/' ${chain33Config}
#update block time
#update wallet store driver
sed -i $sedfix '/^\[wallet\]/,/^\[wallet./ s/^driver.*/driver="leveldb"/' ${chain33Config}
}
autotestConfig="autotest.toml"
autotestTempConfig="autotest.temp.toml"
function config_autotest() {
#delete all blank lines
echo "# config autotest"
sed -i $sedfix '/^\s*$/d' ${autotestConfig}
if [[ $1 == "" ]] || [[ $1 == "all" ]]; then
cp ${autotestConfig} ${autotestTempConfig}
else
#copy config before [
sed -n '/^\[/!p;//q' ${autotestConfig} >${autotestTempConfig}
#copy specific dapp cofig
for dapp in "$@"; do
{
echo "[[TestCaseFile]]"
echo "contract=\"$dapp\""
echo "filename=\"$dapp.toml\""
} >>${autotestTempConfig}
done
fi
sed -i $sedfix 's/^checkSleepTime.*/checkSleepTime='${chain33BlockTime}'/' ${autotestTempConfig}
}
function start_chain33() {
echo "# start solo chain33, make sure there is no chain33 instance running"
rm -rf ../autotest/datadir ../autotest/logs ../autotest/grpc33.log
./chain33 -f chain33.test.toml >/dev/null 2>&1 &
local SLEEP=5
echo "=========== sleep ${SLEEP}s ============="
sleep ${SLEEP}
# query node run status
${CLI} block last_header
echo "=========== # save seed to wallet ============="
result=$(${CLI} seed save -p 1314 -s "tortoise main civil member grace happy century convince father cage beach hip maid merry rib" | jq ".isok")
if [ "${result}" = "false" ]; then
echo "save seed to wallet error seed, result: ${result}"
exit 1
fi
echo "=========== # unlock wallet ============="
result=$(${CLI} wallet unlock -p 1314 -t 0 | jq ".isok")
if [ "${result}" = "false" ]; then
exit 1
fi
echo "=========== # import private key returnAddr ============="
result=$(${CLI} account import_key -k CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944 -l returnAddr | jq ".label")
echo "${result}"
if [ -z "${result}" ]; then
exit 1
fi
echo "=========== # import private key mining ============="
result=$(${CLI} account import_key -k 4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01 -l minerAddr | jq ".label")
echo "${result}"
if [ -z "${result}" ]; then
exit 1
fi
echo "=========== # import test addr1 ============="
result=$(${CLI} account import_key -k 0x88b2fb90411935872f0501dd13345aba19b5fac9b00eb0dddd7df977d4d5477e -l test_addr1 | jq ".label")
echo "${result}"
if [ -z "${result}" ]; then
exit 1
fi
echo "=========== # import test addr2 ============="
result=$(${CLI} account import_key -k 0xa0c6f46de8d275ce21e935afa5363e9b8a087fe604e05f7a9eef1258dc781c3a -l test_addr2 | jq ".label")
echo "${result}"
if [ -z "${result}" ]; then
exit 1
fi
echo "=========== # import test addr3 ============="
result=$(${CLI} account import_key -k 0x9d4f8ab11361be596468b265cb66946c87873d4a119713fd0c3d8302eae0a8e4 -l test_addr3 | jq ".label")
echo "${result}"
if [ -z "${result}" ]; then
exit 1
fi
echo "=========== #transfer to miner addr ============="
hash=$(${CLI} send coins transfer -a 10000 -n test -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -k CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944)
sleep ${chain33BlockTime}
txs=$(${CLI} tx query_hash -s "${hash}" | jq ".txs")
if [ "${txs}" == "null" ]; then
echo "transferTokenAdmin cannot find tx"
exit 1
fi
echo "=========== #transfer to token amdin ============="
hash=$(${CLI} send coins transfer -a 10 -n test -t 1Q8hGLfoGe63efeWa8fJ4Pnukhkngt6poK -k CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944)
sleep ${chain33BlockTime}
txs=$(${CLI} tx query_hash -s "${hash}" | jq ".txs")
if [ "${txs}" == "null" ]; then
echo "transferTokenAdmin cannot find tx"
exit 1
fi
echo "=========== #config token blacklist ============="
rawData=$(${CLI} config config_tx -k token-blacklist -o add -v BTC)
signData=$(${CLI} wallet sign -d "${rawData}" -k 0xc34b5d9d44ac7b754806f761d3d4d2c4fe5214f6b074c19f069c4f5c2a29c8cc)
hash=$(${CLI} wallet send -d "${signData}")
sleep ${chain33BlockTime}
txs=$(${CLI} tx query_hash -s "${hash}" | jq ".txs")
if [ "${txs}" == "null" ]; then
echo "transferTokenAdmin cannot find tx"
exit 1
fi
${CLI} wallet status
${CLI} account list
${CLI} mempool list
}
function start_autotest() {
echo "=========== #run autotest, make sure saving autotest.log.last file============="
if [ -e autotest.log ]; then
cat autotest.log >autotest.log.last
rm autotest.log
fi
./autotest -f ${autotestTempConfig}
}
function stop_chain33() {
echo "=========== #stop chain33 ============="
${CLI} close
#wait close
sleep ${chain33BlockTime}
}
function main() {
echo "==========================================main begin========================================================"
config_autotest "$@"
init
config_chain33
start_chain33
start_autotest
stop_chain33
echo "==========================================main end========================================================="
}
main "$@"
#!/usr/bin/env bash
set -e
set -o pipefail
#set -o verbose
#set -o xtrace
# os: ubuntu16.04 x64
# first, you must install jq tool of json
# sudo apt-get install jq
# sudo apt-get install shellcheck, in order to static check shell script
# sudo apt-get install parallel
# ./run-autotest.sh build
PWD=$(cd "$(dirname "$0")" && pwd)
export PATH="$PWD:$PATH"
PROJECT_NAME="${1}"
NODE3="autotest-chain33"
CLI="docker exec ${NODE3} /root/chain33-cli"
NODE2="autotest-chain32"
CLI2="docker exec ${NODE2} /root/chain33-cli"
sedfix=""
if [ "$(uname)" == "Darwin" ]; then
sedfix=".bak"
fi
function init() {
# update test environment
cp ../../chain33.toml ./
cp ../../chain33 ./
cp ../../chain33-cli ./
sed -i $sedfix 's/^Title.*/Title="local"/g' chain33.toml
sed -i $sedfix 's/^TestNet=.*/TestNet=true/g' chain33.toml
# p2p
sed -i $sedfix 's/^seeds=.*/seeds=["chain33:13802","chain32:13802"]/g' chain33.toml
#sed -i $sedfix 's/^enable=.*/enable=true/g' chain33.toml
sed -i $sedfix '0,/^enable=.*/s//enable=true/' chain33.toml
sed -i $sedfix 's/^isSeed=.*/isSeed=true/g' chain33.toml
sed -i $sedfix 's/^innerSeedEnable=.*/innerSeedEnable=false/g' chain33.toml
sed -i $sedfix 's/^useGithub=.*/useGithub=false/g' chain33.toml
# rpc
sed -i $sedfix 's/^jrpcBindAddr=.*/jrpcBindAddr="0.0.0.0:8801"/g' chain33.toml
sed -i $sedfix 's/^grpcBindAddr=.*/grpcBindAddr="0.0.0.0:8802"/g' chain33.toml
sed -i $sedfix 's/^whitelist=.*/whitelist=["localhost","127.0.0.1","0.0.0.0"]/g' chain33.toml
# wallet
sed -i $sedfix 's/^minerdisable=.*/minerdisable=false/g' chain33.toml
}
function start() {
# remove exsit container
docker-compose -p "${PROJECT_NAME}" -f compose-autotest.yml down --remove-orphans
# create and run docker-compose container
docker-compose -p "${PROJECT_NAME}" -f compose-autotest.yml up --build -d
local SLEEP=60
echo "=========== sleep ${SLEEP}s ============="
sleep ${SLEEP}
# docker-compose ps
docker-compose -p "${PROJECT_NAME}" -f compose-autotest.yml ps
# query node run status
${CLI} block last_header
${CLI} net info
${CLI} net peer_info
peersCount=$(${CLI} net peer_info | jq '.[] | length')
echo "${peersCount}"
if [ "${peersCount}" -lt 2 ]; then
echo "peers error"
exit 1
fi
#echo "=========== # create seed for wallet ============="
#seed=$(${CLI} seed generate -l 0 | jq ".seed")
#if [ -z "${seed}" ]; then
# echo "create seed error"
# exit 1
#fi
echo "=========== # save seed to wallet ============="
result=$(${CLI} seed save -p 1314 -s "tortoise main civil member grace happy century convince father cage beach hip maid merry rib" | jq ".isok")
if [ "${result}" = "false" ]; then
echo "save seed to wallet error seed, result: ${result}"
exit 1
fi
sleep 1
echo "=========== # unlock wallet ============="
result=$(${CLI} wallet unlock -p 1314 -t 0 | jq ".isok")
if [ "${result}" = "false" ]; then
exit 1
fi
echo "=========== # import private key returnAddr ============="
result=$(${CLI} account import_key -k CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944 -l returnAddr | jq ".label")
echo "${result}"
if [ -z "${result}" ]; then
exit 1
fi
echo "=========== # import private key mining ============="
result=$(${CLI} account import_key -k 4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01 -l minerAddr | jq ".label")
echo "${result}"
if [ -z "${result}" ]; then
exit 1
fi
echo "=========== # import test addr1 ============="
result=$(${CLI} account import_key -k 0x88b2fb90411935872f0501dd13345aba19b5fac9b00eb0dddd7df977d4d5477e -l test_addr1 | jq ".label")
echo "${result}"
if [ -z "${result}" ]; then
exit 1
fi
echo "=========== # import test addr2 ============="
result=$(${CLI} account import_key -k 0xa0c6f46de8d275ce21e935afa5363e9b8a087fe604e05f7a9eef1258dc781c3a -l test_addr2 | jq ".label")
echo "${result}"
if [ -z "${result}" ]; then
exit 1
fi
echo "=========== # import test addr3 ============="
result=$(${CLI} account import_key -k 0x9d4f8ab11361be596468b265cb66946c87873d4a119713fd0c3d8302eae0a8e4 -l test_addr3 | jq ".label")
echo "${result}"
if [ -z "${result}" ]; then
exit 1
fi
echo "=========== # close auto mining ============="
result=$(${CLI} wallet auto_mine -f 0 | jq ".isok")
if [ "${result}" = "false" ]; then
exit 1
fi
echo "=========== sleep ${SLEEP}s ============="
sleep ${SLEEP}
echo "=========== check genesis hash ========== "
${CLI} block hash -t 0
res=$(${CLI} block hash -t 0 | jq ".hash")
count=$(echo "$res" | grep -c "0x67c58d6ba9175313f0468ae4e0ddec946549af7748037c2fdd5d54298afd20b6")
if [ "${count}" != 1 ]; then
echo "genesis hash error!"
exit 1
fi
echo "=========== query height ========== "
${CLI} block last_header
result=$(${CLI} block last_header | jq ".height")
if [ "${result}" -lt 1 ]; then
exit 1
fi
sync_status "${CLI}"
${CLI} wallet status
${CLI} account list
${CLI} mempool list
}
function block_wait() {
if [ "$#" -lt 2 ]; then
echo "wrong block_wait params"
exit 1
fi
cur_height=$(${1} block last_header | jq ".height")
expect=$((cur_height + ${2}))
count=0
while true; do
new_height=$(${1} block last_header | jq ".height")
if [ "${new_height}" -ge "${expect}" ]; then
break
fi
count=$((count + 1))
sleep 1
done
echo "wait new block $count s"
}
function sync_status() {
echo "=========== query sync status========== "
local sync_status
local count=100
local wait_sec=0
while [ $count -gt 0 ]; do
sync_status=$(${1} net is_sync)
if [ "${sync_status}" = "true" ]; then
break
fi
((count--))
wait_sec=$((wait_sec + 1))
sleep 1
done
echo "sync wait ${wait_sec} s"
echo "=========== query clock sync status========== "
sync_status=$(${1} net is_clock_sync)
if [ "${sync_status}" = "false" ]; then
exit 1
fi
}
function sync() {
echo "=========== stop ${NODE2} node========== "
docker stop "${NODE2}"
sleep 20
echo "=========== start ${NODE2} node========== "
docker start "${NODE2}"
sleep 1
sync_status "${CLI2}"
}
function auto_test() {
echo "=========== #run auto test ============="
echo "=========== #transfer to token amdin ============="
hash=$(${CLI} send coins transfer -a 10 -n test -t 1Q8hGLfoGe63efeWa8fJ4Pnukhkngt6poK -k 4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01)
block_wait "${CLI}" 2
txs=$(${CLI} tx query_hash -s "${hash}" | jq ".txs")
if [ "${txs}" == "null" ]; then
echo "transferTokenAdmin cannot find tx"
exit 1
fi
echo "=========== #config token blacklist ============="
rawData=$(${CLI} config config_tx -k token-blacklist -o add -v BTC)
signData=$(${CLI} wallet sign -d "${rawData}" -k 0xc34b5d9d44ac7b754806f761d3d4d2c4fe5214f6b074c19f069c4f5c2a29c8cc)
hash=$(${CLI} wallet send -d "${signData}")
block_wait "${CLI}" 2
echo "=========== #start auto-test program ============="
docker exec "${NODE3}" /root/autotest
}
function stop() {
echo "=========== #stop docker-compose ============="
docker cp "${NODE3}":/root/autotest.log ./
docker-compose -p "${PROJECT_NAME}" -f compose-autotest.yml down && rm ./chain33* && rm ./*.toml
}
function main() {
echo "==========================================main begin========================================================"
init
start
auto_test
stop
echo "==========================================main end========================================================="
}
# check args
if [ "$#" -ne 1 ]; then
echo "Suggest Usage: $0 build"
exit 1
fi
# run script
main
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