Commit 65363515 authored by harrylee's avatar harrylee Committed by vipwzw

add copy-autotest.sh

parent 8d031c0f
......@@ -26,7 +26,12 @@ build/para.sh
build/system-test-rpc.sh
build/ci
build/autotest/*
!build/autotest/copy-autotest.sh
!build/autotest/build.sh
!build/autotest/local/local-autotest.sh
!build/autotest/jerkinsci/*.yml
!build/autotest/jerkinsci/*.sh
!build/autotest/jerkinsci/Dockerfile-autotest
.DS_Store
logs/
build/wallet
......
......@@ -10,7 +10,7 @@ SRC_CLI := github.com/33cn/plugin/cli
APP := build/chain33
CHAIN33=github.com/33cn/chain33
CHAIN33_VERSION=$(shell nl go.mod |grep "github.com/33cn/chain33" |awk '{print $$3}')
CHAIN33_PATH=${GOPATH}/pkg/mod/github.com/33cn/chain33@${CHAIN33_VERSION}
export CHAIN33_PATH=${GOPATH}/pkg/mod/github.com/33cn/chain33@${CHAIN33_VERSION}
BUILD_FLAGS = -ldflags "-X ${CHAIN33_PATH}/common/version.GitCommit=`git rev-parse --short=8 HEAD`"
LDFLAGS := -ldflags "-w -s"
PKG_LIST_VET := `go list ./... | grep -v "vendor" | grep -v plugin/dapp/evm/executor/vm/common/crypto/bn256`
......@@ -46,13 +46,15 @@ vet:
autotest: ## build autotest binary
@cd build/autotest && bash ./build.sh ${CHAIN33_PATH} && cd ../../
@if [ -n "$(dapp)" ]; then \
rm -rf build/autotest/local \
&& cp -r $(CHAIN33_PATH)/build/autotest/local $(CHAIN33_PATH)/build/autotest/*.sh build/autotest/ \
&& cd build/autotest && bash ./copy-autotest.sh local && cd local && bash ./local-autotest.sh $(dapp) && cd ../../../; fi
# && rm -rf build/autotest/local \
# && cp -r $(CHAIN33_PATH)/build/autotest/local $(CHAIN33_PATH)/build/autotest/*.sh build/autotest \
cd build/autotest && chmod 755 local && bash ./copy-autotest.sh local \
&& cd local && chmod 640 *.toml && bash ./local-autotest.sh $(dapp) \
&& cd ../../../; fi
autotest_ci: autotest ## autotest ci
@rm -rf build/autotest/jerkinsci \
&& cp -r $(CHAIN33_PATH)/build/autotest/jerkinsci $(CHAIN33_PATH)/build/autotest/*.sh build/autotest/ \
&& cd build/autotest && bash ./copy-autotest.sh jerkinsci/temp$(proj) \
# @rm -rf build/autotest/jerkinsci \
# && cp -r $(CHAIN33_PATH)/build/autotest/jerkinsci $(CHAIN33_PATH)/build/autotest/*.sh build/autotest/ \
cd build/autotest && bash ./copy-autotest.sh jerkinsci/temp$(proj) \
&& cd jerkinsci && bash ./jerkins-ci-autotest.sh $(proj) && cd ../../../
autotest_tick: autotest ## run with ticket mining
@rm -rf build/autotest/gitlabci \
......
#!/usr/bin/env bash
set -e
set -o pipefail
#set -o verbose
#set -o xtrace
# os: ubuntu16.04 x64
#chain33 dapp autotest root directory
declare -a Chain33AutoTestDirs=("system" "plugin" "vendor/github.com/33cn/chain33/system" "vendor/github.com/33cn/plugin/plugin")
#copy auto test to specific directory
# check args
if [ "$#" -lt 1 ]; then
echo "Usage: $0 directory list"
exit 1
fi
function copyAutoTestConfig() {
echo "#copy auto test config to path \"$1\""
local AutoTestConfigFile="$1/autotest.toml"
#pre config auto test
{
echo 'cliCmd="./chain33-cli"'
echo "checkTimeout=60"
} >"${AutoTestConfigFile}"
#copy all the dapp test case config file
for rootDir in "${Chain33AutoTestDirs[@]}"; do
if [ ! -d ../../"${rootDir}" ]; then
continue
fi
testDirArr=$(find ../../"${rootDir}" -type d -name autotest)
for autotest in ${testDirArr}; do
dapp=$(basename "$(dirname "${autotest}")")
dappConfig=${autotest}/${dapp}.toml
#make sure dapp have auto test config
if [ -e "${dappConfig}" ]; then
cp "${dappConfig}" "$1"/
#add dapp test case config
{
echo "[[TestCaseFile]]"
echo "dapp=\"$dapp\""
echo "filename=\"$dapp.toml\""
} >>"${AutoTestConfigFile}"
fi
done
done
}
function copyChain33() {
echo "# copy chain33 bin to path \"$1\", make sure build chain33"
cp ../chain33 ../chain33-cli ../chain33.toml "$1"
cp "${CHAIN33_PATH}"/cmd/chain33/chain33.test.toml "$1"
}
echo "=======CHAIN33_PATH:${CHAIN33_PATH}===="
for dir in "$@"; do
#check dir exist
if [ ! -d "${dir}" ]; then
mkdir "${dir}"
fi
cp autotest "${dir}"
copyAutoTestConfig "${dir}"
copyChain33 "${dir}"
echo "# all copy have done!"
done
......@@ -173,8 +173,8 @@ func TestKvmvccMavlCommit(t *testing.T) {
for i := 0; i < 30; i++ {
key = GetRandomString(MaxKeylenth)
value = fmt.Sprintf("v%d", i)
keys = append(keys, []byte(string(key)))
kv = append(kv, &types.KeyValue{Key: []byte(string(key)), Value: []byte(string(value))})
keys = append(keys, []byte(key))
kv = append(kv, &types.KeyValue{Key: []byte(key), Value: []byte(value)})
}
datas := &types.StoreSet{
StateHash: drivers.EmptyRoot[:],
......@@ -623,8 +623,8 @@ func TestPruning(t *testing.T) {
for i := 0; i < 30; i++ {
key = GetRandomString(MaxKeylenth)
value = fmt.Sprintf("v%d", i)
keys = append(keys, []byte(string(key)))
kv = append(kv, &types.KeyValue{Key: []byte(string(key)), Value: []byte(string(value))})
keys = append(keys, []byte(key))
kv = append(kv, &types.KeyValue{Key: []byte(key), Value: []byte(value)})
}
datas := &types.StoreSet{
StateHash: drivers.EmptyRoot[:],
......@@ -796,8 +796,8 @@ func benchmarkGet(b *testing.B, isResetForkHeight bool) {
for i := 0; i < b.N; i++ {
key := GetRandomString(MaxKeylenth)
value := fmt.Sprintf("%s%d", key, i)
keys = append(keys, []byte(string(key)))
kv = append(kv, &types.KeyValue{Key: []byte(string(key)), Value: []byte(string(value))})
keys = append(keys, []byte(key))
kv = append(kv, &types.KeyValue{Key: []byte(key), Value: []byte(value)})
if i%10000 == 0 {
datas := &types.StoreSet{StateHash: hash, KV: kv, Height: 0}
hash, err = store.Set(datas, true)
......@@ -853,8 +853,8 @@ func benchmarkStoreGetKvs4N(b *testing.B, isResetForkHeight bool) {
for i := 0; i < kvnum; i++ {
key = GetRandomString(MaxKeylenth)
value = fmt.Sprintf("v%d", i)
keys = append(keys, []byte(string(key)))
kv = append(kv, &types.KeyValue{Key: []byte(string(key)), Value: []byte(string(value))})
keys = append(keys, []byte(key))
kv = append(kv, &types.KeyValue{Key: []byte(key), Value: []byte(value)})
}
datas := &types.StoreSet{
StateHash: drivers.EmptyRoot[:],
......@@ -907,8 +907,8 @@ func benchmarkStoreGetKvsForNN(b *testing.B, isResetForkHeight bool) {
for i := 0; i < 30; i++ {
key = GetRandomString(MaxKeylenth)
value = fmt.Sprintf("v%d", i)
keys = append(keys, []byte(string(key)))
kv = append(kv, &types.KeyValue{Key: []byte(string(key)), Value: []byte(string(value))})
keys = append(keys, []byte(key))
kv = append(kv, &types.KeyValue{Key: []byte(key), Value: []byte(value)})
}
datas := &types.StoreSet{
StateHash: drivers.EmptyRoot[:],
......@@ -977,8 +977,8 @@ func benchmarkStoreGetKvsFor10000(b *testing.B, isResetForkHeight bool) {
for i := 0; i < 30; i++ {
key = GetRandomString(MaxKeylenth)
value = fmt.Sprintf("v%d", i)
keys = append(keys, []byte(string(key)))
kv = append(kv, &types.KeyValue{Key: []byte(string(key)), Value: []byte(string(value))})
keys = append(keys, []byte(key))
kv = append(kv, &types.KeyValue{Key: []byte(key), Value: []byte(value)})
}
datas := &types.StoreSet{
StateHash: drivers.EmptyRoot[:],
......@@ -1050,8 +1050,8 @@ func benchmarkGetIter(b *testing.B, isResetForkHeight bool) {
for i := 0; i < b.N; i++ {
key := GetRandomString(MaxKeylenth)
value := fmt.Sprintf("%s%d", key, i)
keys = append(keys, []byte(string(key)))
kv = append(kv, &types.KeyValue{Key: []byte(string(key)), Value: []byte(string(value))})
keys = append(keys, []byte(key))
kv = append(kv, &types.KeyValue{Key: []byte(key), Value: []byte(value)})
if i%10000 == 0 {
datas := &types.StoreSet{StateHash: hash, KV: kv, Height: 0}
hash, err = store.Set(datas, true)
......@@ -1105,8 +1105,8 @@ func benchmarkSet(b *testing.B, isResetForkHeight bool) {
for i := 0; i < b.N; i++ {
key := GetRandomString(MaxKeylenth)
value := fmt.Sprintf("%s%d", key, i)
keys = append(keys, []byte(string(key)))
kv = append(kv, &types.KeyValue{Key: []byte(string(key)), Value: []byte(string(value))})
keys = append(keys, []byte(key))
kv = append(kv, &types.KeyValue{Key: []byte(key), Value: []byte(value)})
if i%10000 == 0 {
datas := &types.StoreSet{StateHash: hash, KV: kv, Height: 0}
hash, err = store.Set(datas, true)
......@@ -1152,8 +1152,8 @@ func benchmarkStoreSet(b *testing.B, isResetForkHeight bool) {
for i := 0; i < 30; i++ {
key = GetRandomString(MaxKeylenth)
value = fmt.Sprintf("v%d", i)
keys = append(keys, []byte(string(key)))
kv = append(kv, &types.KeyValue{Key: []byte(string(key)), Value: []byte(string(value))})
keys = append(keys, []byte(key))
kv = append(kv, &types.KeyValue{Key: []byte(key), Value: []byte(value)})
}
datas := &types.StoreSet{
StateHash: drivers.EmptyRoot[:],
......@@ -1197,8 +1197,8 @@ func benchmarkSetIter(b *testing.B, isResetForkHeight bool) {
for i := 0; i < b.N; i++ {
key := GetRandomString(MaxKeylenth)
value := fmt.Sprintf("%s%d", key, i)
keys = append(keys, []byte(string(key)))
kv = append(kv, &types.KeyValue{Key: []byte(string(key)), Value: []byte(string(value))})
keys = append(keys, []byte(key))
kv = append(kv, &types.KeyValue{Key: []byte(key), Value: []byte(value)})
if i%10000 == 0 {
datas := &types.StoreSet{StateHash: hash, KV: kv, Height: 0}
hash, err = store.Set(datas, true)
......@@ -1244,8 +1244,8 @@ func benchmarkMemSet(b *testing.B, isResetForkHeight bool) {
for i := 0; i < b.N; i++ {
key = GetRandomString(MaxKeylenth)
value = fmt.Sprintf("v%d", i)
keys = append(keys, []byte(string(key)))
kv = append(kv, &types.KeyValue{Key: []byte(string(key)), Value: []byte(string(value))})
keys = append(keys, []byte(key))
kv = append(kv, &types.KeyValue{Key: []byte(key), Value: []byte(value)})
}
datas := &types.StoreSet{
StateHash: drivers.EmptyRoot[:],
......@@ -1288,8 +1288,8 @@ func benchmarkStoreMemSet(b *testing.B, isResetForkHeight bool) {
for i := 0; i < 30; i++ {
key = GetRandomString(MaxKeylenth)
value = fmt.Sprintf("v%d", i)
keys = append(keys, []byte(string(key)))
kv = append(kv, &types.KeyValue{Key: []byte(string(key)), Value: []byte(string(value))})
keys = append(keys, []byte(key))
kv = append(kv, &types.KeyValue{Key: []byte(key), Value: []byte(value)})
}
datas := &types.StoreSet{
StateHash: drivers.EmptyRoot[:],
......@@ -1335,8 +1335,8 @@ func benchmarkCommit(b *testing.B, isResetForkHeight bool) {
for i := 0; i < b.N; i++ {
key = GetRandomString(MaxKeylenth)
value = fmt.Sprintf("v%d", i)
keys = append(keys, []byte(string(key)))
kv = append(kv, &types.KeyValue{Key: []byte(string(key)), Value: []byte(string(value))})
keys = append(keys, []byte(key))
kv = append(kv, &types.KeyValue{Key: []byte(key), Value: []byte(value)})
}
datas := &types.StoreSet{
StateHash: drivers.EmptyRoot[:],
......@@ -1440,8 +1440,8 @@ func benchmarkIterMemSet(b *testing.B, isResetForkHeight bool) {
for i := 0; i < b.N; i++ {
key = GetRandomString(MaxKeylenth)
value = fmt.Sprintf("v%d", i)
keys = append(keys, []byte(string(key)))
kv = append(kv, &types.KeyValue{Key: []byte(string(key)), Value: []byte(string(value))})
keys = append(keys, []byte(key))
kv = append(kv, &types.KeyValue{Key: []byte(key), Value: []byte(value)})
}
datas := &types.StoreSet{
StateHash: drivers.EmptyRoot[:],
......@@ -1483,8 +1483,8 @@ func benchmarkIterCommit(b *testing.B, isResetForkHeight bool) {
for i := 0; i < b.N; i++ {
key = GetRandomString(MaxKeylenth)
value = fmt.Sprintf("v%d", i)
keys = append(keys, []byte(string(key)))
kv = append(kv, &types.KeyValue{Key: []byte(string(key)), Value: []byte(string(value))})
keys = append(keys, []byte(key))
kv = append(kv, &types.KeyValue{Key: []byte(key), Value: []byte(value)})
}
datas := &types.StoreSet{
StateHash: drivers.EmptyRoot[:],
......
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