forked from klaytn/klaytn-deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
migration_test.sh
executable file
·67 lines (57 loc) · 1.39 KB
/
migration_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
timeout=120
nodeType="en"
nodeNumber=1
function waitNewBlock() {
blockNum=`./deploy $nodeType jsexec --id $nodeNumber 'klay.blockNumber'`
echo "Start to wait greater block than "$blockNum" "
startTime=`date +%s`
i=1
while :
do
sleep 1
sp="/-\|"
printf "please wait for making block... ${sp:i++%${#sp}:1} \r"
curBlkNum=`./deploy $nodeType jsexec --id $nodeNumber 'klay.blockNumber'`
if [ $curBlkNum -gt $blockNum ];
then
echo "Found greater block "$curBlkNum" "
break
fi
currentTime=`date +%s`
runtime=$((currentTime-startTime))
if [ $runtime -gt $timeout ];
then
echo "Timeout!!! block hasn't been made by "$timeout" sec"
return 0 # exit 1
fi
done
printf "Thanks for your waiting. \n"
return 1
}
testCnt=0
while :
do
((testCnt++))
echo "TEST CNT # "$testCnt" "
./deploy en jsexec "admin.startStateMigration(false)" --id 1
sleep 500
waitNewBlock
res=$?
if [ $res -eq 0 ];
then
echo "Migration timeout!!! block hasn't been made by "$timeout" sec"
exit 1
fi
./deploy en stop --id 1
sleep 10
./deploy en start --id 1
sleep 500
waitNewBlock
res=$?
if [ $res -eq 0 ];
then
echo "timeout after start!!! block hasn't been made by "$timeout" sec"
exit 1
fi
done