You need to sign in or sign up before continuing.
Newer
Older
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
#!/usr/bin/env bash
# Copyright 2015, 2016 Eris Industries (UK) Ltd.
# This file is part of Eris-RT
# Eris-RT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# Eris-RT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with Eris-RT. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------
# PURPOSE
# This is the integration test manager for eris-db. It will
# run the integration testing sequence for eris-db using docker
# and the dependent eris components within the eris platform
# for eris-db. Specifically eris-db and the eris-db client
# require a key management component for signing transactions
# and validating blocks.
# ----------------------------------------------------------
# REQUIREMENTS
# eris installed locally
# ----------------------------------------------------------
# USAGE
# test.sh
# ----------------------------------------------------------
# Set defaults
# Where are the Things?
name=eris-db
base=github.com/eris-ltd/$name
repo=`pwd`
if [ "$CIRCLE_BRANCH" ]
then
ci=true
linux=true
elif [ "$TRAVIS_BRANCH" ]
then
ci=true
osx=true
elif [ "$APPVEYOR_REPO_BRANCH" ]
then
ci=true
win=true
else
repo=$GOPATH/src/$base
ci=false
fi
branch=${CIRCLE_BRANCH:=master}
branch=${branch/-/_}
branch=${branch/\//_}
# Other variables
was_running=0
test_exit=0
chains_dir=$HOME/.eris/chains
export ERIS_PULL_APPROVE="true"
export ERIS_MIGRATE_APPROVE="true"
# ---------------------------------------------------------------------------
# Needed functionality
ensure_running(){
if [[ "$(eris services ls -qr | grep $1)" == "$1" ]]
then
echo "$1 already started. Not starting."
was_running=1
else
echo "Starting service: $1"
eris services start $1 1>/dev/null
early_exit
sleep 3 # boot time
fi
}
early_exit(){
if [ $? -eq 0 ]
then
return 0
fi
echo "There was an error duing setup; keys were not properly imported. Exiting."
if [ "$was_running" -eq 0 ]
then
if [ "$ci" = true ]
then
eris services stop keys
else
eris services stop -r keys
fi
fi
exit 1
}
get_uuid() {
if [[ "$(uname -s)" == "Linux" ]]
then
uuid=$(cat /proc/sys/kernel/random/uuid | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1)
elif [[ "$(uname -s)" == "Darwin" ]]
then
uuid=$(uuidgen | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1)
else
uuid="2231587f0fe5"
fi
echo $uuid
}
test_build() {
echo ""
echo "Building eris-cm in a docker container."
set -e
tests/build_tool.sh 1>/dev/null
set +e
if [ $? -ne 0 ]
then
echo "Could not build eris-cm. Debug via by directly running [`pwd`/tests/build_tool.sh]"
exit 1
fi
echo "Build complete."
echo ""
}
test_setup(){
echo "Getting Setup"
if [ "$ci" = true ]
then
eris init --yes --pull-images=true --testing=true 1>/dev/null
fi
ensure_running keys
echo "Setup complete"
}
check_test(){
# check chain is running
chain=( $(eris chains ls --quiet --running | grep $uuid) )
if [ ${#chain[@]} -ne 1 ]
then
echo "chain does not appear to be running"
echo
ls -la $dir_to_use
test_exit=1
return 1
fi
# check results file exists
if [ ! -e "$chains_dir/$uuid/accounts.csv" ]
then
echo "accounts.csv not present"
ls -la $chains_dir/$uuid
pwd
ls -la $chains_dir
test_exit=1
return 1
fi
# check genesis.json
genOut=$(cat $dir_to_use/genesis.json | sed 's/[[:space:]]//g')
genIn=$(eris chains plop $uuid genesis | sed 's/[[:space:]]//g')
if [[ "$genOut" != "$genIn" ]]
then
test_exit=1
echo "genesis.json's do not match"
echo
echo "expected"
echo
echo -e "$genOut"
echo
echo "received"
echo
echo -e "$genIn"
echo
echo "difference"
echo
diff <(echo "$genOut" ) <(echo "$genIn") | colordiff
return 1
fi
# check priv_validator
privOut=$(cat $dir_to_use/priv_validator.json | tr '\n' ' ' | sed 's/[[:space:]]//g' | set 's/(,\"last_height\":[^0-9]+,\"last_round\":[^0-9]+,\"last_step\":[^0-9]+//g' )
privIn=$(eris data exec $uuid "cat /home/eris/.eris/chains/$uuid/priv_validator.json" | tr '\n' ' ' | sed 's/[[:space:]]//g' | set 's/(,\"last_height\":[^0-9]+,\"last_round\":[^0-9]+,\"last_step\":[^0-9]+//g' )
if [[ "$privOut" != "$privIn" ]]
then
test_exit=1
echo "priv_validator.json's do not match"
echo
echo "expected"
echo
echo -e "$privOut"
echo
echo "received"
echo
echo -e "$privIn"
echo
echo "difference"
echo
diff <(echo "$privOut" ) <(echo "$privIn") | colordiff
return 1
fi
}
# ---------------------------------------------------------------------------
# Get the things build and dependencies turned on
echo "Hello! I'm the marmot that tests the eris-db tooling"
start=`pwd`
cd $repo
test_setup
test_build
echo
# ---------------------------------------------------------------------------
# Go ahead with node integration tests
# TODO
# ---------------------------------------------------------------------------
# Go ahead with client integration tests !
echo "Running Client Tests..."
perform_client_tests
# ---------------------------------------------------------------------------
# Cleaning up
test_teardown