Newer
Older
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
set -e
while [ $# -gt 1 ]; do
if [[ $1 == "--"* ]]; then
v="${1/--/}"
declare "$v"="$2"
shift
fi
shift
done
if [[ $1 == "help" ]]; then
echo "usage: ./run.sh [--run testname,testname,...] [environment]"
echo "Basic runner for integration tests, this script will run the test suite,"
echo "pointed at the specified environment. Environment can be blank to use a "
echo "local network, or one of [devnet|betanet|mainnet]."
echo " --run run one or more specified tests, input is a comma-separated list"
exit
fi
if [ $# -gt 1 ]
then
echo "usage: $0 [gatewayip:port]"
exit
fi
NETWORKENTRYPOINT=$1
DEBUGLEVEL=${DEBUGLEVEL-1}
rm -fr blobs || true
rm -fr results.bak || true
mv results results.bak || rm -fr results || true
mkdir -p blobs
mkdir -p results
################################################################################
## Network Set Up
################################################################################
if [ "$NETWORKENTRYPOINT" == "betanet" ]
then
NETWORKENTRYPOINT=$(sort -R network/betanet.txt | head -1)
elif [ "$NETWORKENTRYPOINT" == "mainnet" ]
then
NETWORKENTRYPOINT=$(sort -R network/mainnet.txt | head -1)
elif [ "$NETWORKENTRYPOINT" == "release" ]
then
NETWORKENTRYPOINT=$(sort -R network/release.txt | head -1)
elif [ "$NETWORKENTRYPOINT" == "devnet" ]
then
NETWORKENTRYPOINT=$(sort -R network/devnet.txt | head -1)
elif [ "$NETWORKENTRYPOINT" == "" ]
then
NETWORKENTRYPOINT=$(head -1 network/network.config)
fi
echo "NETWORK: $NETWORKENTRYPOINT"
if [ "$NETWORKENTRYPOINT" == "localhost:1060" ]
then
source network/network.sh results bin
source network/cleanup.sh results
donefunc() {
finish
exit $rc
}
trap donefunc EXIT
trap donefunc INT
else
echo "Connecting to network defined at $NETWORKENTRYPOINT"
echo $NETWORKENTRYPOINT > results/startgwserver.txt
fi
echo "DONE LETS DO STUFF"
echo "DOWNLOADING TLS Cert..."
# -alpn h2 added to mimic grpc headers
CMD="openssl s_client -alpn h2 -showcerts -connect $(tr -d '[:space:]' < results/startgwserver.txt)"
echo $CMD
eval $CMD < /dev/null 2>&1 > "results/startgwcert.bin"
CMD="cat results/startgwcert.bin | openssl x509 -outform PEM"
echo $CMD
eval $CMD > "results/startgwcert.pem"
head "results/startgwcert.pem"
echo "DOWNLOADING NDF..."
CLIENTCMD="bin/client getndf --gwhost $(tr -d '[:space:]' < results/startgwserver.txt) --cert results/startgwcert.pem"
eval $CLIENTCMD >> results/ndf.json 2>&1 &
PIDVAL=$!
echo "$CLIENTCMD -- $PIDVAL"
wait $PIDVAL
cat results/ndf.json | jq . | head -5
file results/ndf.json
if [ ! -s results/ndf.json ]
then
echo "results/ndf.json is empty, cannot proceed"
exit -1
fi
################################################################################
## Run tests
################################################################################
testreport=results/testreport.txt
timestamp=$(date +%s)
echo "Test report $timestamp" >> $testreport
if [ -z $run ]
then
TESTS=("basice2e" "backup" "dm" "historical" "channels" "fileTransfer" "connect" "broadcast" "groupChat" "ephemeralRegistration" "rekey" "singleUse" "channelsFileTransfer" "remoteSync")
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
LOCALTESTS=("basice2e_local" "ud")
else
TESTS=(${run//,/ })
fi
set +e
set -o pipefail
if [ "$NETWORKENTRYPOINT" == "localhost:1060" ]
then
for i in ${LOCALTESTS[@]} ; do
testresults=results/$i
mkdir -p $testresults && touch $testresults/testout.txt
/bin/bash tests/$i/run.sh $testresults tests/$i/clients.goldoutput results/ndf.json 2>&1 | tee $testresults/testout.txt
if [ $? -eq 0 ]
then
echo "$i - SUCCESS" >> $testreport
else
echo "$i - FAILED" >> $testreport
fi
done
fi
if [ ${#TESTS[@]} -eq 1 ]
then
/bin/bash tests/${TESTS[0]}/run.sh results/${TESTS[0]} tests/${TESTS[0]}/clients.goldoutput results/ndf.json
rc=$?
else
errs=0
for i in ${TESTS[@]} ; do
testresults=results/$i
mkdir -p $testresults && touch $testresults/testout.txt
/bin/bash tests/$i/run.sh $testresults tests/$i/clients.goldoutput results/ndf.json 2>&1 | tee $testresults/testout.txt
rc=$?
if [ $rc -eq 0 ]
then
echo "$i - SUCCESS" >> $testreport
else
echo "$i - FAILED" >> $testreport
fi
errs=$(($errs+$rc))
done
if [ $errs -gt 1 ]
then
rc=1
fi
fi
cat $testreport
# View result logs
# Not using $EDITOR or $VISUAL because many editors that people set those to
# don't have as easy support for viewing multiple files
${INTEGRATION_EDITOR:-gedit} ./basice2e/results/clients/*.out ./basice2e/results/servers/*.console ./basice2e/results/*.log ./basice2e/results/*.console&