forked from livepeer/go-livepeer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_args.sh
executable file
·296 lines (234 loc) · 11.2 KB
/
test_args.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
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
#!/usr/bin/env bash
set -eux
# set a clean slate "home dir" for testing
TMPDIR=$PWD/tmp/livepeer-test-"$RANDOM"
DEFAULT_DATADIR="$TMPDIR"/.lpData
CUSTOM_DATADIR="$TMPDIR"/customDatadir
rm -rf "$DEFAULT_DATADIR"
mkdir -p $TMPDIR # goclient should make the lpData datadir
# build the binary
HIGHEST_CHAIN_TAG=mainnet
go build -tags "$HIGHEST_CHAIN_TAG" -o $TMPDIR/livepeer cmd/livepeer/*.go
# Set up ethereum key
cat > $TMPDIR/key <<ETH_KEY
{"address":"089d8ab6752bac616a1f17246294eb068ee23d3e","crypto":{"cipher":"aes-128-ctr","ciphertext":"e868446e99842291b4991ae2c8e6c6834296c81937c4182e45af2edf0af61968","cipherparams":{"iv":"62205b25b7c4b2c35717128d9702f3c8"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"dfa46628fec666ebd46d21d59cd3cbad0039d13f3c09dd5304128e32edfdec57"},"mac":"a5d4cde1863803a2b17718eb6b0770c0e7fcdfcf3659c9bd24f033d4529a5af3"},"id":"b84a7400-5fbd-4397-894e-c59403663b88","version":3}
ETH_KEY
ETH_ARGS="-ethKeystorePath $TMPDIR/key"
SLEEP=0.25
export HOME=$TMPDIR
run_lp () {
$TMPDIR/livepeer "$@" &
pid=$!
sleep $SLEEP
}
# sanity check that default datadir does not exist
[ ! -d "$DEFAULT_DATADIR" ]
# check that we exit early if no services are enabled
res=0
$TMPDIR/livepeer || res=$?
[ $res -ne 0 ]
run_lp -broadcaster
[ -d "$DEFAULT_DATADIR"/offchain ]
kill $pid
# sanity check that custom datadir does not exist
[ ! -d "$CUSTOM_DATADIR" ]
# check custom datadir without a network (offchain)
run_lp -broadcaster -dataDir "$CUSTOM_DATADIR"
[ -d "$CUSTOM_DATADIR" ]
[ ! -d "$CUSTOM_DATADIR"/offchain ] # sanity check that network isn't included
kill $pid
CUSTOM_DATADIR="$TMPDIR"/customDatadir2
# sanity check that custom datadir does not exist
[ ! -d "$CUSTOM_DATADIR" ]
# check invalid service address via inserting control character
$TMPDIR/livepeer -orchestrator -orchSecret asdf -serviceAddr "hibye" 2>&1 | grep "Error getting service URI"
[ ${PIPESTATUS[0]} -ne 0 ]
# check missing service address via failed availability check
# Testing these isn't quite reliable enough (slow)
# XXX currently returns zero; should be nonzero
#$TMPDIR/livepeer -orchestrator -orchSecret asdf 2>&1 | grep "Orchestrator not available"
#$TMPDIR/livepeer -orchestrator -orchSecret asdf -serviceAddr livepeer.org 2>&1 | grep "Orchestrator not available"
# check that orchestrators require -orchSecret or -transcoder
# sanity check with -transcoder
run_lp -orchestrator -serviceAddr 127.0.0.1:8935 -transcoder
kill $pid
# sanity check with -orchSecret
run_lp -orchestrator -serviceAddr 127.0.0.1:8935 -orchSecret asdf
kill $pid
# XXX need a better way of confirming the error type. specialized exit code?
res=0
$TMPDIR/livepeer -orchestrator -serviceAddr 127.0.0.1:8935 || res=$?
[ $res -ne 0 ]
# Run mainnet tests
if [ -z ${MAINNET_ETH_URL+x} ]
then
echo "MAINNET_ETH_URL is not set - skipping mainnet tests"
else
# Exit early if -ethUrl is missing
res=0
$TMPDIR/livepeer -broadcaster -network mainnet $ETH_ARGS || res=$?
[ $res -ne 0 ]
OLD_ETH_ARGS=$ETH_ARGS
ETH_ARGS="${ETH_ARGS} -ethUrl ${MAINNET_ETH_URL}"
run_lp -broadcaster -network mainnet $ETH_ARGS
[ -d "$DEFAULT_DATADIR"/mainnet ]
kill $pid
ETH_ARGS=$OLD_ETH_ARGS
fi
# Run Rinkeby tests
if [ -z ${RINKEBY_ETH_URL+x} ]
then
echo "RINKEBY_ETH_URL is not set - skipping Rinkeby tests"
else
# Exit early if -ethUrl is missing
res=0
$TMPDIR/livepeer -broadcaster -network rinkeby $ETH_ARGS || res=$?
[ $res -ne 0 ]
OLD_ETH_ARGS=$ETH_ARGS
ETH_ARGS="${ETH_ARGS} -ethUrl ${RINKEBY_ETH_URL}"
run_lp -broadcaster -network rinkeby $ETH_ARGS
[ -d "$DEFAULT_DATADIR"/rinkeby ]
kill $pid
# Error if flags to set MaxBroadcastPrice aren't provided correctly
res=0
$TMPDIR/livepeer -broadcaster -network rinkeby $ETH_ARGS -maxPricePerUnit 0 -pixelsPerUnit -5 || res=$?
[ $res -ne 0 ]
run_lp -broadcaster -network anyNetwork $ETH_ARGS -v 99
[ -d "$DEFAULT_DATADIR"/anyNetwork ]
kill $pid
# check custom datadir with a network
run_lp -broadcaster -dataDir "$CUSTOM_DATADIR" -network rinkeby $ETH_ARGS
[ ! -d "$CUSTOM_DATADIR"/rinkeby ] # sanity check that network isn't included
kill $pid
# Check that -pricePerUnit needs to be set
$TMPDIR/livepeer -orchestrator -serviceAddr 127.0.0.1:8935 -transcoder -network rinkeby $ETH_ARGS 2>&1 | grep -e "-pricePerUnit must be set"
# Orchestrator needs PricePerUnit > 0
$TMPDIR/livepeer -orchestrator -serviceAddr 127.0.0.1:8935 -transcoder -pricePerUnit -5 -network rinkeby $ETH_ARGS 2>&1 | grep -e "-pricePerUnit must be >= 0, provided -5"
# Orchestrator needs PixelsPerUnit > 0
$TMPDIR/livepeer -orchestrator -serviceAddr 127.0.0.1:8935 -transcoder -pixelsPerUnit 0 -pricePerUnit 5 -network rinkeby $ETH_ARGS 2>&1 | grep -e "-pixelsPerUnit must be > 0, provided 0"
$TMPDIR/livepeer -orchestrator -serviceAddr 127.0.0.1:8935 -transcoder -pixelsPerUnit -5 -pricePerUnit 5 -network rinkeby $ETH_ARGS 2>&1 | grep -e "-pixelsPerUnit must be > 0, provided -5"
# Check that price can be set to 0 with -pricePerUnit 0
res=0
$TMPDIR/livepeer -orchestrator -serviceAddr 127.0.0.1:8935 -transcoder -pricePerUnit 0 -network rinkeby $ETH_ARGS || res=$?
[ $res -ne 0 ]
# Broadcaster needs a valid rational number for -maxTicketEV
res=0
$TMPDIR/livepeer -broadcaster -maxTicketEV abcd -network rinkeby $ETH_ARGS || res=$?
[ $res -ne 0 ]
# Broadcaster needs a non-negative number for -maxTicketEV
res=0
$TMPDIR/livepeer -broadcaster -maxTicketEV -1 -network rinkeby $ETH_ARGS || res=$?
[ $res -ne 0 ]
# Broadcaster needs a postive number for -depositMultiplier
res=0
$TMPDIR/livepeer -broadcaster -depositMultiplier 0 -network rinkeby $ETH_ARGS || res=$?
[ $res -ne 0 ]
# Check that local verification is enabled by default in on-chain mode
$TMPDIR/livepeer -broadcaster -transcodingOptions invalid -network rinkeby $ETH_ARGS 2>&1 | grep "Local verification enabled"
# Check that local verification is disabled via -localVerify in on-chain mode
$TMPDIR/livepeer -broadcaster -transcodingOptions invalid -localVerify=false -network rinkeby $ETH_ARGS 2>&1 | grep -v "Local verification enabled"
ETH_ARGS=$OLD_ETH_ARGS
fi
# transcoder needs -orchSecret
res=0
$TMPDIR/livepeer -transcoder || res=$?
[ $res -ne 0 ]
# exit early if webhook url is not http
res=0
$TMPDIR/livepeer -broadcaster -authWebhookUrl tcp://host/ || res=$?
[ $res -ne 0 ]
# exit early if webhook url is not properly formatted
res=0
$TMPDIR/livepeer -broadcaster -authWebhookUrl http\\://host/ || res=$?
[ $res -ne 0 ]
# exit early if orchestrator webhook URL is not http
res=0
$TMPDIR/livepeer -broadcaster -orchWebhookUrl tcp://host/ || res=$?
[ $res -ne 0 ]
# exit early if orchestrator webhook URL is not properly formatted
res=0
$TMPDIR/livepeer -broadcaster -orchWebhookUrl http\\://host/ || res=$?
[ $res -ne 0 ]
# exit early if maxSessions less or equal to zero
res=0
$TMPDIR/livepeer -broadcaster -maxSessions -1 || res=$?
[ $res -ne 0 ]
res=0
$TMPDIR/livepeer -broadcaster -maxSessions 0 || res=$?
[ $res -ne 0 ]
# Check that pprof is running on CLI port
run_lp -broadcaster
curl -sI http://127.0.0.1:7935/debug/pprof/allocs | grep "200 OK"
kill $pid
# exit early if verifier URL is not http
res=0
$TMPDIR/livepeer -broadcaster -verifierUrl tcp://host/ || res=$?
[ $res -ne 0 ]
# exit early if verifier URL is not properly formatted
res=0
$TMPDIR/livepeer -broadcaster -verifierUrl http\\://host/ || res=$?
[ $res -ne 0 ]
# Check that verifier shared path is required
$TMPDIR/livepeer -broadcaster -verifierUrl http://host 2>&1 | grep "Requires a path to the"
# Check OK with verifier shared path
run_lp -broadcaster -verifierUrl http://host -verifierPath path
kill $pid
# Check OK with verifier + external storage
run_lp -broadcaster -verifierUrl http://host -objectStore s3+https://ACCESS_KEY_ID:[email protected]/bucket-name
kill $pid
# Check that HTTP ingest is disabled when -httpAddr is publicly accessible and there is no auth webhook URL and -httpIngest defaults to false
run_lp -broadcaster -httpAddr 0.0.0.0
curl -X PUT http://localhost:8935/live/movie/0.ts | grep "404 page not found"
kill $pid
# Check that HTTP ingest is disabled when -httpAddr is not publicly accessible and -httpIngest is set to false
run_lp -broadcaster -httpIngest=false
curl -X PUT http://localhost:8935/live/movie/0.ts | grep "404 page not found"
kill $pid
# Check that HTTP ingest is disabled when -httpAddr is publicly accessible and there is a auth webhook URL and -httpIngest is set to false
run_lp -broadcaster -httpAddr 0.0.0.0 -authWebhookUrl http://foo.com -httpIngest=false
curl -X PUT http://localhost:8935/live/movie/0.ts | grep "404 page not found"
kill $pid
# Check that HTTP ingest is enabled when -httpIngest is true
run_lp -broadcaster -httpAddr 0.0.0.0 -httpIngest
curl -X PUT http://localhost:8935/live/movie/0.ts | grep -v "404 page not found"
kill $pid
# Check that HTTP ingest is enabled when -httpAddr sets the hostname to 127.0.0.1
run_lp -broadcaster -httpAddr 127.0.0.1
curl -X PUT http://localhost:8935/live/movie/0.ts | grep -v "404 page not found"
kill $pid
# Check that HTTP ingest is enabled when -httpAddr sets the hostname to localhost
run_lp -broadcaster -httpAddr localhost
curl -X PUT http://localhost:8935/live/movie/0.ts | grep -v "404 page not found"
kill $pid
# Check that HTTP ingest is enabled when there is an auth webhook URL
run_lp -broadcaster -httpAddr 0.0.0.0 -authWebhookUrl http://foo.com
curl -X PUT http://localhost:8935/live/movie/0.ts | grep -v "404 page not found"
kill $pid
# Check that the default presets are used
run_lp -broadcaster
curl -s --stderr - http://localhost:7935/getBroadcastConfig | grep P240p30fps16x9,P360p30fps16x9
kill $pid
# Check that the presets passed in are used
run_lp -broadcaster -transcodingOptions P144p30fps16x9,P720p30fps16x9
curl -s --stderr - http://localhost:7935/getBroadcastConfig | grep P144p30fps16x9,P720p30fps16x9
kill $pid
# Check that config file profiles passed in are used
cat > $TMPDIR/profile.json <<PROFILE_JSON
[{"name":"abc","width":1,"height":2},{"name":"def","width":1,"height":2}]
PROFILE_JSON
run_lp -broadcaster -transcodingOptions $TMPDIR/profile.json
curl -s --stderr - http://localhost:7935/getBroadcastConfig | grep abc,def
kill $pid
# Check nonexistent profile config file
$TMPDIR/livepeer -broadcaster -transcodingOptions notarealfile 2>&1 | grep "No transcoding profiles found"
# Check that it fails out on an malformed profiles json
echo "not json" > $TMPDIR/invalid.json
$TMPDIR/livepeer -broadcaster -transcodingOptions $TMPDIR/invalid.json 2>&1 | grep "invalid character"
# Check that it fails out on an invalid schema - width / height as strings
echo '[{"width":"1","height":"2"}]' > $TMPDIR/schema.json
$TMPDIR/livepeer -broadcaster -transcodingOptions $TMPDIR/schema.json 2>&1 | grep "cannot unmarshal string into Go struct field JsonProfile.width of type int"
# Check that local verification is disabled by default in off-chain mode
$TMPDIR/livepeer -broadcaster -transcodingOptions invalid 2>&1 | grep -v "Local verification enabled"
# Check that local verification is enabled via -localVerify in off-chain mode
$TMPDIR/livepeer -broadcaster -transcodingOptions invalid -localVerify=true 2>&1 | grep "Local verification enabled"
rm -rf $TMPDIR