@@ -97,9 +97,8 @@ func NewRecordTester(gctx context.Context, opts RecordTesterOptions, serfOpts Se
97
97
return rt
98
98
}
99
99
100
- func (rt * recordTester ) Start (fileName string , testDuration , pauseDuration time.Duration ) (int , error ) {
100
+ func (rt * recordTester ) Start (fileName string , testDuration , pauseDuration time.Duration ) (i int , err error ) {
101
101
defer rt .cancel ()
102
- var err error
103
102
var broadcasters []string
104
103
ingest , err := rt .getIngestInfo ()
105
104
if err != nil {
@@ -142,11 +141,17 @@ func (rt *recordTester) Start(fileName string, testDuration, pauseDuration time.
142
141
}
143
142
break
144
143
}
144
+ // Make sure we include the Stream and Playback IDs on any error message
145
+ defer func () {
146
+ if err != nil {
147
+ err = fmt .Errorf ("playbackId=%s %w" , stream .PlaybackID , err )
148
+ }
149
+ }()
145
150
apiTry = 0
146
151
rt .streamID = stream .ID
147
152
rt .stream = stream
148
153
messenger .SendMessage (fmt .Sprintf (":information_source: Created stream id=%s" , stream .ID ))
149
- glog .V (model .VERBOSE ).Infof ("Created Livepeer stream id =%s streamKey=%s playbackId=%s name=%s" , stream .ID , stream .StreamKey , stream .PlaybackID , streamName )
154
+ glog .V (model .VERBOSE ).Infof ("Created Livepeer stream streamId =%s streamKey=%s playbackId=%s name=%s" , stream .ID , stream .StreamKey , stream .PlaybackID , streamName )
150
155
rtmpURL := fmt .Sprintf ("%s/%s" , ingest .Ingest , stream .StreamKey )
151
156
152
157
testerFuncs := []testers.StartTestFunc {}
@@ -169,20 +174,20 @@ func (rt *recordTester) Start(fileName string, testDuration, pauseDuration time.
169
174
serfMember := rt .serfOpts .SerfMembers [index ]
170
175
mediaURL = fmt .Sprintf ("%s/hls/%s/index.m3u8" , serfMember .Tags ["https" ], stream .PlaybackID )
171
176
}
172
- glog .V (model .SHORT ).Infof ("RTMP: %s" , rtmpURL )
173
- glog .V (model .SHORT ).Infof ("MEDIA: %s" , mediaURL )
177
+ glog .V (model .SHORT ).Infof ("RTMP: %s streamId=%s playbackId=%s " , rtmpURL , stream . ID , stream . PlaybackID )
178
+ glog .V (model .SHORT ).Infof ("MEDIA: %s streamId=%s playbackId=%s " , mediaURL , stream . ID , stream . PlaybackID )
174
179
if rt .useHTTP {
175
180
sterr := rt .doOneHTTPStream (fileName , streamName , broadcasters [0 ], testDuration , stream )
176
181
if sterr != nil {
177
- glog .Warningf ("Streaming returned error err=%v" , sterr )
182
+ glog .Warningf ("Streaming returned error err=%v streamId=%s playbackId=%s " , sterr , stream . ID , stream . PlaybackID )
178
183
return 3 , err
179
184
}
180
185
if streamTwice {
181
- glog .Infof ("Pause specified, waiting %s before streaming second time" , pauseDuration )
186
+ glog .Infof ("Pause specified, waiting %s before streaming second time. streamId=%s playbackId=%s " , pauseDuration , stream . ID , stream . PlaybackID )
182
187
time .Sleep (pauseDuration )
183
188
sterr = rt .doOneHTTPStream (fileName , streamName , broadcasters [0 ], testDuration , stream )
184
189
if sterr != nil {
185
- glog .Warningf ("Second time streaming returned error err=%v" , sterr )
190
+ glog .Warningf ("Second time streaming returned error err=%v streamId=%s playbackId=%s " , sterr , stream . ID , stream . PlaybackID )
186
191
return 3 , err
187
192
}
188
193
}
@@ -192,46 +197,46 @@ func (rt *recordTester) Start(fileName string, testDuration, pauseDuration time.
192
197
sr2 .StartStreaming (fileName , rtmpURL , mediaURL , 2 * time .Minute , testDuration )
193
198
srerr := sr2 .Err ()
194
199
195
- glog .Infof ("Streaming stream id=%s done err=%v " , stream .ID , srerr )
200
+ glog .Infof ("Streaming done err=%v streamId=%s playbackId=%s " , srerr , stream .ID , stream . PlaybackID )
196
201
var re * testers.RTMPError
197
202
if errors .As (srerr , & re ) {
198
203
return 2 , re
199
204
}
200
205
if srerr != nil {
201
- glog .Warningf ("Streaming returned error err=%v" , srerr )
206
+ glog .Warningf ("Streaming returned error err=%v streamId=%s playbackId=%s " , srerr , stream . ID , stream . PlaybackID )
202
207
return 3 , srerr
203
208
}
204
209
stats , err := sr2 .Stats ()
205
210
if err != nil {
206
- glog .Warningf ("Stats returned error err=%v" , err )
211
+ glog .Warningf ("Stats returned error err=%v streamId=%s playbackId=%s " , err , stream . ID , stream . PlaybackID )
207
212
return 21 , err
208
213
}
209
- glog .Infof ("Streaming success rate=%v" , stats .SuccessRate )
214
+ glog .Infof ("Streaming success rate=%v streamId=%s playbackId=%s " , stats .SuccessRate , stream . ID , stream . PlaybackID )
210
215
if err = rt .isCancelled (); err != nil {
211
216
return 0 , err
212
217
}
213
218
if streamTwice {
214
- glog .Infof ("Pause specified, waiting %s before streaming second time" , pauseDuration )
219
+ glog .Infof ("Pause specified, waiting %s before streaming second time. streamId=%s playbackId=%s " , pauseDuration , stream . ID , stream . PlaybackID )
215
220
time .Sleep (pauseDuration )
216
221
sr2 := testers .NewStreamer2 (rt .ctx , testers.Streamer2Options {MistMode : true }, testerFuncs ... )
217
222
go sr2 .StartStreaming (fileName , rtmpURL , mediaURL , 30 * time .Second , testDuration )
218
223
<- sr2 .Done ()
219
224
srerr := sr2 .Err ()
220
- glog .Infof ("Streaming second stream id =%s done " , stream .ID )
225
+ glog .Infof ("Streaming second done. streamId =%s playbackId=%s " , stream .ID , stream . PlaybackID )
221
226
var re * testers.RTMPError
222
227
if errors .As (srerr , & re ) {
223
228
return 2 , re
224
229
}
225
230
if srerr != nil {
226
- glog .Warningf ("Streaming second returned error err=%v" , srerr )
231
+ glog .Warningf ("Streaming second returned error err=%v streamId=%s playbackId=%s " , srerr , stream . ID , stream . PlaybackID )
227
232
return 3 , srerr
228
233
}
229
234
stats , err := sr2 .Stats ()
230
235
if err != nil {
231
- glog .Warningf ("Stats returned error err=%v" , err )
236
+ glog .Warningf ("Stats returned error err=%v streamId=%s playbackId=%s " , err , stream . ID , stream . PlaybackID )
232
237
return 21 , err
233
238
}
234
- glog .Infof ("Streaming second time success rate=%v" , stats .SuccessRate )
239
+ glog .Infof ("Streaming second time success rate=%v streamId=%s playbackId=%s " , stats .SuccessRate , stream . ID , stream . PlaybackID )
235
240
if err = rt .isCancelled (); err != nil {
236
241
return 0 , err
237
242
}
@@ -240,15 +245,15 @@ func (rt *recordTester) Start(fileName string, testDuration, pauseDuration time.
240
245
if err := rt .isCancelled (); err != nil {
241
246
return 0 , err
242
247
}
243
- glog .Infof ("Waiting 10 seconds" )
248
+ glog .Infof ("Waiting 10 seconds. streamId=%s playbackId=%s" , stream . ID , stream . PlaybackID )
244
249
time .Sleep (10 * time .Second )
245
250
// now get sessions
246
251
sessions , err := rt .lapi .GetSessionsNew (stream .ID , false )
247
252
if err != nil {
248
- glog .Errorf ("Error getting sessions for stream id =%s err=%v " , stream .ID , err )
253
+ glog .Errorf ("Error getting sessions err=%v streamId =%s playbackId=%s " , err , stream .ID , stream . PlaybackID )
249
254
return 252 , err
250
255
}
251
- glog .Infof ("Sessions: %+v" , sessions )
256
+ glog .Infof ("Sessions: %+v streamId=%s playbackId=%s " , sessions , stream . ID , stream . PlaybackID )
252
257
253
258
expectedSessions := 1
254
259
if streamTwice {
@@ -264,7 +269,7 @@ func (rt *recordTester) Start(fileName string, testDuration, pauseDuration time.
264
269
265
270
sess := sessions [0 ]
266
271
if len (sess .Profiles ) != len (stream .Profiles ) {
267
- glog .Infof ("session: %+v" , sess )
272
+ glog .Infof ("session: %+v streamId=%s playbackId=%s " , sess , stream . ID , stream . PlaybackID )
268
273
err := fmt .Errorf ("got %d profiles but should have %d" , len (sess .Profiles ), len (stream .Profiles ))
269
274
return 251 , err
270
275
}
@@ -276,7 +281,7 @@ func (rt *recordTester) Start(fileName string, testDuration, pauseDuration time.
276
281
return 0 , err
277
282
}
278
283
279
- glog .Info ("Streaming done, waiting for recording URL to appear" )
284
+ glog .Infof ("Streaming done, waiting for recording URL to appear. streamId=%s playbackId=%s" , stream . ID , stream . PlaybackID )
280
285
if rt .useForceURL {
281
286
time .Sleep (5 * time .Second )
282
287
} else {
@@ -291,7 +296,7 @@ func (rt *recordTester) Start(fileName string, testDuration, pauseDuration time.
291
296
err := fmt .Errorf ("error getting sessions for stream id=%s err=%v" , stream .ID , err )
292
297
return 252 , err
293
298
}
294
- glog .Infof ("Sessions: %+v" , sessions )
299
+ glog .Infof ("Sessions: %+v streamId=%s playbackId=%s " , sessions , stream . ID , stream . PlaybackID )
295
300
if err = rt .isCancelled (); err != nil {
296
301
return 0 , err
297
302
}
@@ -310,7 +315,7 @@ func (rt *recordTester) Start(fileName string, testDuration, pauseDuration time.
310
315
err := fmt .Errorf ("recording URL should appear by now" )
311
316
return 249 , err
312
317
}
313
- glog .Infof ("recordingURL=%s downloading now" , sess .RecordingURL )
318
+ glog .Infof ("recordingURL=%s downloading now. streamId=%s playbackId=%s " , sess .RecordingURL , stream . ID , stream . PlaybackID )
314
319
315
320
if err = rt .isCancelled (); err != nil {
316
321
return 0 , err
@@ -327,7 +332,7 @@ func (rt *recordTester) Start(fileName string, testDuration, pauseDuration time.
327
332
return es , err
328
333
}
329
334
}
330
- glog .Info ("Done Record Test" )
335
+ glog .Infof ("Done Record Test. streamId=%s playbackId=%s" , stream . ID , stream . PlaybackID )
331
336
332
337
rt .lapi .DeleteStream (stream .ID )
333
338
return 0 , nil
@@ -397,40 +402,40 @@ func (rt *recordTester) isCancelled() error {
397
402
func (rt * recordTester ) checkDownMp4 (stream * api.Stream , url string , streamDuration time.Duration ) (int , error ) {
398
403
es := 0
399
404
started := time .Now ()
400
- glog .V (model .VERBOSE ).Infof ("Downloading mp4 url=%s stream id =%s" , url , stream .ID )
405
+ glog .V (model .VERBOSE ).Infof ("Downloading mp4 url=%s streamId=%s playbackId =%s" , url , stream .ID , stream . PlaybackID )
401
406
402
407
resp , err := http .Get (url )
403
408
if err != nil {
404
- glog .Warningf ("Error downloading mp4 for manifestID =%s url =%s" , stream .ID , url )
409
+ glog .Warningf ("Error downloading mp4 url=%s streamId =%s playbackId =%s" , url , stream .ID , stream . PlaybackID )
405
410
return 3 , err
406
411
}
407
412
if resp .StatusCode != http .StatusOK {
408
- glog .Warningf ("HTTP error downloading mp4 for manifestID =%s url =%s status =%s" , stream . ID , url , resp .Status )
413
+ glog .Warningf ("HTTP error downloading mp4 url=%s status =%s streamId =%s playbackId =%s" , url , resp .Status , stream . ID , stream . PlaybackID )
409
414
return 3 , err
410
415
}
411
416
defer resp .Body .Close ()
412
417
body , err := ioutil .ReadAll (resp .Body )
413
418
if err != nil {
414
- glog .Warningf ("HTTP error downloading mp4 for manifestID =%s url=%s err=%v " , stream .ID , url , err )
419
+ glog .Warningf ("HTTP error downloading mp4 url =%s err=%v streamId=%s playbackId=%s " , url , err , stream .ID , stream . PlaybackID )
415
420
return 3 , err
416
421
}
417
- glog .Infof ("Downloaded bytes=%b manifestID =%s url =%s took =%s" , len (body ), stream . ID , url , time .Since (started ))
422
+ glog .Infof ("Downloaded bytes=%b url =%s took =%s streamId =%s playbackId=%s " , len (body ), url , time .Since (started ), stream . ID , stream . PlaybackID )
418
423
bodyR := bytes .NewReader (body )
419
424
dem := mp4 .NewDemuxer (bodyR )
420
425
streams , err := dem .Streams ()
421
426
if err != nil {
422
- glog .Warningf ("Error parsing mp4 for manifestID =%s url=%s err=%v " , stream .ID , url , err )
427
+ glog .Warningf ("Error parsing mp4 url =%s err=%v streamId=%s playbackId=%s " , url , err , stream .ID , stream . PlaybackID )
423
428
return 203 , err
424
429
}
425
430
if len (streams ) != 2 {
426
431
ers := fmt .Errorf ("expected only 2 streams (video and audio), got=%d, streams=%v" , len (streams ), streams )
427
432
glog .Error (ers )
428
433
return 203 , err
429
434
}
430
- glog .Infof ("Got %d streams in mp4 file manifestID =%s url =%s" , len (streams ), stream .ID , url )
435
+ glog .Infof ("Got %d streams in mp4 file url =%s streamId =%s playbackId=%s " , len (streams ), url , stream .ID , stream . PlaybackID )
431
436
dur , err := calcMP4FileDuration (body )
432
437
if err != nil {
433
- glog .Warningf ("Error parsing mp4 for manifestID =%s url=%s err=%v " , stream .ID , url , err )
438
+ glog .Warningf ("Error parsing mp4 url =%s err=%v streamId=%s playbackId=%s " , url , err , stream .ID , stream . PlaybackID )
434
439
return 203 , err
435
440
}
436
441
durDiff := streamDuration - dur
@@ -440,7 +445,7 @@ func (rt *recordTester) checkDownMp4(stream *api.Stream, url string, streamDurat
440
445
if durDiff > 2 * time .Second {
441
446
ers := fmt .Errorf ("duration of mp4 differ by %s (got %s, should %s)" , durDiff , dur , streamDuration )
442
447
glog .Error (ers )
443
- return 300 , err
448
+ return 300 , ers
444
449
}
445
450
return es , nil
446
451
}
@@ -450,24 +455,24 @@ func (rt *recordTester) checkDown(stream *api.Stream, url string, streamDuration
450
455
started := time .Now ()
451
456
downloader := testers .NewM3utester2 (rt .ctx , url , false , false , false , false , 5 * time .Second , nil , false )
452
457
<- downloader .Done ()
453
- glog .Infof (`Pulling for %s (%s) stopped after %s` , stream . ID , stream .PlaybackID , time . Since ( started ) )
458
+ glog .Infof (`Pulling stopped after %s. streamId=%s playbackId= %s` , time . Since ( started ) , stream .ID , stream . PlaybackID )
454
459
if err := rt .isCancelled (); err != nil {
455
460
return 0 , err
456
461
}
457
462
vs := downloader .VODStats ()
458
463
rt .vodStats = vs
459
464
if len (vs .SegmentsNum ) != len (api .StandardProfiles )+ 1 {
460
- glog .Warningf ("Number of renditions doesn't match! Has %d should %d" , len (vs .SegmentsNum ), len (api .StandardProfiles )+ 1 )
465
+ glog .Warningf ("Number of renditions doesn't match! Has %d should %d. streamId=%s playbackId=%s " , len (vs .SegmentsNum ), len (api .StandardProfiles )+ 1 , stream . ID , stream . PlaybackID )
461
466
es = 35
462
467
}
463
- glog .Infof ("Stats for %s: %s" , stream .ID , vs . String () )
464
- glog .Infof ("Stats for %s raw: %+v" , stream .ID , vs )
468
+ glog .Infof ("Stats: %s streamId=%s playbackId= %s" , vs . String (), stream .ID , stream . PlaybackID )
469
+ glog .Infof ("Stats raw: %+v streamId=%s playbackId=%s " , vs , stream .ID , stream . PlaybackID )
465
470
if ok , ers := vs .IsOk (streamDuration , false ); ! ok {
466
- glog .Warningf ("NOT OK! (%s)" , ers )
471
+ glog .Warningf ("NOT OK! (%s) streamId=%s playbackId=%s " , ers , stream . ID , stream . PlaybackID )
467
472
es = 36
468
473
return es , errors .New (ers )
469
474
} else {
470
- glog .Infoln ("All ok!" )
475
+ glog .Infof ("All ok! streamId=%s playbackId=%s" , stream . ID , stream . PlaybackID )
471
476
}
472
477
return es , nil
473
478
}
0 commit comments