Skip to content

Commit 48f2c09

Browse files
committed
merge gitlab branch
Former-commit-id: a515d8150309d7d99e09dbfab9c378582f6611dd Former-commit-id: 815719c
2 parents 3a9d820 + f19c766 commit 48f2c09

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1161
-1967
lines changed

.gitignore

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ datadir*
33
*.exe
44
*.orig
55
*.bak
6-
*.log.last
76
.idea
87
.vscode
98
cmd/chain33/chain33
@@ -24,10 +23,10 @@ build/ci
2423
cmd/execblock/execblock
2524
cmd/miner_accounts/miner_accounts
2625
cmd/write/write
27-
build/tools/autotest/autotest
28-
build/tools/autotest/*.toml
29-
build/tools/autotest/chain33
30-
build/tools/autotest/chain33-cli
26+
build/autotest/autotest
27+
build/autotest/local/*.toml
28+
build/autotest/local/autotest*
29+
build/autotest/local/chain33*
3130
plugin/consensus/raft/chain33_raft-1/
3231
common/mavl/datastore
3332
.DS_Store

.gitlab-ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ autotest:
193193
- if [ -n "${onceEveryday}" ]; then
194194
- make build_ci
195195
- make autotest
196-
- cd build/tools/autotest && ./run-autotest.sh build
196+
- cd build/autotest && ./copy-autotest.sh gitlabci && cd gitlabci && ./gitlabci-autotest.sh build
197197
- cd $GO_PROJECT_PATH
198198
- fi
199199
when: always

Jenkinsfile

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pipeline {
6767
dir("${PROJ_DIR}"){
6868
gitlabCommitStatus(name: 'deploy'){
6969
sh 'make build_ci'
70+
sh "make autotest_ci proj=${env.BUILD_NUMBER}"
7071
sh "cd build && mkdir ${env.BUILD_NUMBER} && cp ci/* ${env.BUILD_NUMBER} -r && cp chain33* Dockerfile* docker* *.sh ${env.BUILD_NUMBER}/ && cd ${env.BUILD_NUMBER}/ && ./docker-compose-pre.sh run ${env.BUILD_NUMBER} all "
7172
}
7273
}

Makefile

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ APP := build/chain33
1414
CLI := build/chain33-cli
1515
SIGNATORY := build/signatory-server
1616
MINER := build/miner_accounts
17-
AUTO_TEST := build/tools/autotest/autotest
17+
AUTO_TEST := build/autotest/autotest
1818
SRC_AUTO_TEST := github.com/33cn/chain33/cmd/autotest
1919
LDFLAGS := -ldflags "-w -s"
2020
PKG_LIST := `go list ./... | grep -v "vendor" | grep -v "chain33/test" | grep -v "mocks" | grep -v "pbft"`
@@ -68,10 +68,11 @@ para:
6868

6969
autotest:## build autotest binary
7070
@go build -v -i -o $(AUTO_TEST) $(SRC_AUTO_TEST)
71-
@cp cmd/autotest/*.toml build/tools/autotest/
7271
@if [ -n "$(dapp)" ]; then \
73-
cd build/tools/autotest && bash ./local-autotest.sh $(dapp) && cd ../../../; \
72+
cd build/autotest && bash ./copy-autotest.sh local && cd local && bash ./local-autotest.sh $(dapp) && cd ../../../; \
7473
fi
74+
autotest_ci: autotest ## autotest jerkins ci
75+
@cd build/autotest && bash ./copy-autotest.sh jerkinsci/temp$(proj) && cd jerkinsci && bash ./jerkins-ci-autotest.sh $(proj) && cd ../../../
7576

7677
signatory:
7778
@cd cmd/signatory-server/signatory && bash ./create_protobuf.sh && cd ../.../..
@@ -174,7 +175,7 @@ clean: ## Remove previous build
174175
@rm -rf build/relayd*
175176
@rm -rf build/*.log
176177
@rm -rf build/logs
177-
@rm -rf build/tools/autotest/autotest
178+
@rm -rf build/autotest/autotest
178179
@rm -rf build/ci
179180
@go clean
180181

build/autotest/copy-autotest.sh

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
set -o pipefail
5+
#set -o verbose
6+
#set -o xtrace
7+
8+
# os: ubuntu16.04 x64
9+
10+
#chain33 dapp autotest root directory
11+
declare -a Chain33AutoTestDirs=("system" "plugin")
12+
13+
#copy auto test to specific directory
14+
# check args
15+
if [ "$#" -lt 1 ]; then
16+
echo "Usage: $0 directory list"
17+
exit 1
18+
fi
19+
20+
function copyAutoTestConfig() {
21+
22+
echo "#copy auto test config to path \"$1\""
23+
local AutoTestConfigFile="$1/autotest.toml"
24+
25+
#pre config auto test
26+
{
27+
28+
echo 'cliCmd="./chain33-cli"'
29+
echo "checkTimeout=60"
30+
} >"${AutoTestConfigFile}"
31+
32+
#copy all the dapp test case config file
33+
for rootDir in "${Chain33AutoTestDirs[@]}"; do
34+
35+
testDirArr=$(find ../../"${rootDir}" -type d -name autotest)
36+
37+
for autotest in ${testDirArr}; do
38+
39+
dapp=$(basename "$(dirname "${autotest}")")
40+
dappConfig=${autotest}/${dapp}.toml
41+
42+
#make sure dapp have auto test config
43+
if [ -e "${dappConfig}" ]; then
44+
45+
cp "${dappConfig}" "$1"/
46+
47+
#add dapp test case config
48+
{
49+
echo "[[TestCaseFile]]"
50+
echo "dapp=\"$dapp\""
51+
echo "filename=\"$dapp.toml\""
52+
} >>"${AutoTestConfigFile}"
53+
54+
fi
55+
56+
done
57+
done
58+
}
59+
60+
function copyChain33() {
61+
62+
echo "# copy chain33 bin to path \"$1\""
63+
cp ../chain33 ../chain33-cli ../chain33.toml ../../cmd/chain33/chain33.test.toml "$1"
64+
65+
}
66+
67+
for dir in "$@"; do
68+
69+
#check dir exist
70+
if [ ! -d "${dir}" ]; then
71+
mkdir "${dir}"
72+
fi
73+
cp autotest "${dir}"
74+
copyAutoTestConfig "${dir}"
75+
copyChain33 "${dir}"
76+
echo "# all copy have done!"
77+
78+
done

build/tools/autotest/compose-autotest.yml build/autotest/gitlabci/compose-autotest.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '3'
22

33
services:
4-
chain33:
4+
autotest:
55
build:
66
context: .
77
dockerfile: Dockerfile-autotest

build/tools/autotest/run-autotest.sh build/autotest/gitlabci/gitlab-ci-autotest.sh

+11-29
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ fi
3030

3131
function init() {
3232
# update test environment
33-
cp ../../chain33.toml ./
34-
cp ../../chain33 ./
35-
cp ../../chain33-cli ./
3633
sed -i $sedfix 's/^Title.*/Title="local"/g' chain33.toml
3734
sed -i $sedfix 's/^TestNet=.*/TestNet=true/g' chain33.toml
3835

@@ -62,7 +59,7 @@ function start() {
6259
# create and run docker-compose container
6360
docker-compose -p "${PROJECT_NAME}" -f compose-autotest.yml up --build -d
6461

65-
local SLEEP=60
62+
local SLEEP=30
6663
echo "=========== sleep ${SLEEP}s ============="
6764
sleep ${SLEEP}
6865

@@ -117,27 +114,6 @@ function start() {
117114
exit 1
118115
fi
119116

120-
echo "=========== # import test addr1 ============="
121-
result=$(${CLI} account import_key -k 0x88b2fb90411935872f0501dd13345aba19b5fac9b00eb0dddd7df977d4d5477e -l test_addr1 | jq ".label")
122-
echo "${result}"
123-
if [ -z "${result}" ]; then
124-
exit 1
125-
fi
126-
127-
echo "=========== # import test addr2 ============="
128-
result=$(${CLI} account import_key -k 0xa0c6f46de8d275ce21e935afa5363e9b8a087fe604e05f7a9eef1258dc781c3a -l test_addr2 | jq ".label")
129-
echo "${result}"
130-
if [ -z "${result}" ]; then
131-
exit 1
132-
fi
133-
134-
echo "=========== # import test addr3 ============="
135-
result=$(${CLI} account import_key -k 0x9d4f8ab11361be596468b265cb66946c87873d4a119713fd0c3d8302eae0a8e4 -l test_addr3 | jq ".label")
136-
echo "${result}"
137-
if [ -z "${result}" ]; then
138-
exit 1
139-
fi
140-
141117
echo "=========== # close auto mining ============="
142118
result=$(${CLI} wallet auto_mine -f 0 | jq ".isok")
143119
if [ "${result}" = "false" ]; then
@@ -247,19 +223,21 @@ function auto_test() {
247223
docker exec "${NODE3}" /root/autotest
248224
}
249225

250-
function stop() {
226+
function stop_chain33() {
251227

228+
rv=$?
252229
echo "=========== #stop docker-compose ============="
253-
docker cp "${NODE3}":/root/autotest.log ./
254-
docker-compose -p "${PROJECT_NAME}" -f compose-autotest.yml down && rm ./chain33* && rm ./*.toml
230+
docker-compose -p "${PROJECT_NAME}" -f compose-autotest.yml down && rm -rf ./chain33* ./*.toml ./autotest
231+
echo "=========== #remove related images ============"
232+
docker rmi "${PROJECT_NAME}"_autotest || true
233+
exit ${rv}
255234
}
256235

257236
function main() {
258237
echo "==========================================main begin========================================================"
259238
init
260239
start
261240
auto_test
262-
stop
263241
echo "==========================================main end========================================================="
264242
}
265243

@@ -268,5 +246,9 @@ if [ "$#" -ne 1 ]; then
268246
echo "Suggest Usage: $0 build"
269247
exit 1
270248
fi
249+
250+
#trap exit
251+
trap "stop_chain33" INT TERM EXIT
252+
271253
# run script
272254
main
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM ubuntu:16.04
2+
3+
WORKDIR /root
4+
COPY chain33 ./
5+
COPY chain33-cli ./
6+
COPY autotest ./
7+
COPY *.toml ./
8+
9+
CMD ["/root/chain33", "-f" , "chain33.test.toml"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: '3'
2+
3+
services:
4+
autotest:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile-autotest
8+
9+

0 commit comments

Comments
 (0)