-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathsolo_smoke_test.sh
executable file
·145 lines (122 loc) · 3.57 KB
/
solo_smoke_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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
set -eo pipefail
#
# This script should be called after solo has been deployed with mirror node and relay node deployed,
# and should be called from the root of the solo repository
#
# This uses solo account creation function to repeatedly generate background transactions
# Then run smart contract test, and also javascript sdk sample test to interact with solo network
#
source .github/workflows/script/helper.sh
function clone_smart_contract_repo ()
{
echo "Clone hedera-smart-contracts"
if [ -d "hedera-smart-contracts" ]; then
echo "Directory hedera-smart-contracts exists."
else
echo "Directory hedera-smart-contracts does not exist."
git clone https://github.com/hashgraph/hedera-smart-contracts --branch only-erc20-tests
fi
}
function setup_smart_contract_test ()
{
echo "Setup smart contract test"
cd hedera-smart-contracts
echo "Remove previous .env file"
rm -f .env
npm install
npx hardhat compile || return 1
echo "Build .env file"
echo "PRIVATE_KEYS=\"$CONTRACT_TEST_KEYS\"" > .env
echo "RETRY_DELAY=5000 # ms" >> .env
echo "MAX_RETRY=5" >> .env
cat .env
cd -
}
function check_port_forward ()
{
# run background task for few minutes
for i in {1..20}
do
echo "Check port forward"
ps -ef |grep port-forward
sleep 5
done &
}
function start_background_transactions ()
{
echo "Start background transaction"
# generate accounts as background traffic for two minutes
# so record stream files can be kept pushing to mirror node
cd solo
npm run solo-test -- account create --deployment solo-deployment --create-amount 15 > /dev/null 2>&1 &
cd -
}
function start_contract_test ()
{
cd hedera-smart-contracts
echo "Wait a few seconds for background transactions to start"
sleep 5
echo "Run smart contract test"
npm run hh:test
result=$?
cd -
return $result
}
function start_sdk_test ()
{
cd solo
node examples/create-topic.js
result=$?
cd -
return $result
}
function check_monitor_log()
{
# get the logs of mirror-monitor
kubectl get pods -n solo-e2e | grep mirror-monitor | awk '{print $1}' | xargs kubectl logs -n solo-e2e > mirror-monitor.log
if grep -q "ERROR" mirror-monitor.log; then
echo "mirror-monitor.log contains ERROR"
exit 1
fi
# any line contains "Scenario pinger published" should contain the string "Errors: {}"
if grep -q "Scenario pinger published" mirror-monitor.log; then
if grep -q "Errors: {}" mirror-monitor.log; then
echo "mirror-monitor.log contains Scenario pinger published and Errors: {}"
else
echo "mirror-monitor.log contains Scenario pinger published but not Errors: {}"
exit 1
fi
fi
}
function check_importer_log()
{
kubectl get pods -n solo-e2e | grep mirror-importer | awk '{print $1}' | xargs kubectl logs -n solo-e2e > mirror-importer.log
if grep -q "ERROR" mirror-importer.log; then
echo "mirror-importer.log contains ERROR"
exit 1
fi
}
# if first parameter equals to ACCOUNT_INIT,
# then call solo account init before deploy mirror and relay node
if [ "$1" == "ACCOUNT_INIT" ]; then
echo "Call solo account init"
npm run solo-test -- account init --deployment solo-deployment
fi
task solo:mirror-node
task solo:relay
echo "Change to parent directory"
cd ../
create_test_account
clone_smart_contract_repo
setup_smart_contract_test
start_background_transactions
check_port_forward
start_contract_test
start_sdk_test
echo "Sleep a while to wait background transactions to finish"
sleep 30
echo "Run mirror node acceptance test"
helm test mirror -n solo-e2e --timeout 10m
check_monitor_log
check_importer_log