Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recordtester: implement polling #317

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,3 @@ require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
lukechampine.com/blake3 v1.2.1 // indirect
)

exclude github.com/gosuri/uilive v0.0.4 // cause memory corruption
93 changes: 53 additions & 40 deletions internal/app/recordtester/recordtester_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,60 +282,73 @@ func (rt *recordTester) Start(fileName string, testDuration, pauseDuration time.
}

glog.Infof("Streaming done, waiting for recording URL to appear. streamId=%s playbackId=%s", stream.ID, stream.PlaybackID)
if rt.useForceURL {
time.Sleep(5 * time.Second)
} else {
time.Sleep(rt.recordingWaitTime)
}
if err = rt.isCancelled(); err != nil {
return 0, err
}

sessions, err = rt.lapi.GetSessionsNew(stream.ID, rt.useForceURL)
if err != nil {
err := fmt.Errorf("error getting sessions for stream id=%s err=%v", stream.ID, err)
return 252, err
}
glog.Infof("Sessions: %+v streamId=%s playbackId=%s", sessions, stream.ID, stream.PlaybackID)
if err = rt.isCancelled(); err != nil {
return 0, err
}

for _, sess := range sessions {
sess = sessions[0]
statusShould := api.RecordingStatusReady
if rt.useForceURL {
statusShould = api.RecordingStatusWaiting
}
if sess.RecordingStatus != statusShould {
err := fmt.Errorf("recording status is %s but should be %s", sess.RecordingStatus, statusShould)
return 240, err
}
if sess.RecordingURL == "" {
err := fmt.Errorf("recording URL should appear by now")
return 249, err
poll := func() (int, error) {
if err = rt.isCancelled(); err != nil {
return 0, err
}
glog.Infof("recordingURL=%s downloading now. streamId=%s playbackId=%s", sess.RecordingURL, stream.ID, stream.PlaybackID)

sessions, err = rt.lapi.GetSessionsNew(stream.ID, rt.useForceURL)
if err != nil {
err := fmt.Errorf("error getting sessions for stream id=%s err=%v", stream.ID, err)
return 252, err
}
glog.Infof("Sessions: %+v streamId=%s playbackId=%s", sessions, stream.ID, stream.PlaybackID)
if err = rt.isCancelled(); err != nil {
return 0, err
}
if rt.mp4 {
es, err := rt.checkDownMp4(stream, sess.Mp4Url, testDuration)

for _, sess := range sessions {
sess = sessions[0]
statusShould := api.RecordingStatusReady
if rt.useForceURL {
statusShould = api.RecordingStatusWaiting
}
if sess.RecordingStatus != statusShould {
err := fmt.Errorf("recording status is %s but should be %s", sess.RecordingStatus, statusShould)
return 240, err
}
if sess.RecordingURL == "" {
err := fmt.Errorf("recording URL should appear by now")
return 249, err
}
glog.Infof("recordingURL=%s downloading now. streamId=%s playbackId=%s", sess.RecordingURL, stream.ID, stream.PlaybackID)

if err = rt.isCancelled(); err != nil {
return 0, err
}
if rt.mp4 {
es, err := rt.checkDownMp4(stream, sess.Mp4Url, testDuration)
if err != nil {
return es, err
}
}

es, err := rt.checkDown(stream, sess.RecordingURL, testDuration)
if err != nil {
return es, err
}
}

es, err := rt.checkDown(stream, sess.RecordingURL, testDuration)
if err != nil {
return es, err
return 0, nil
}
var giveup time.Time
if rt.useForceURL {
giveup = time.Now().Add(5 * time.Second)
} else {
giveup = time.Now().Add(rt.recordingWaitTime)
}
var ret int
for time.Now().Before(giveup) {
ret, err = poll()
if ret == 0 {
break
}
time.Sleep(5 * time.Second)
}

glog.Infof("Done Record Test. streamId=%s playbackId=%s", stream.ID, stream.PlaybackID)

rt.lapi.DeleteStream(stream.ID)
return 0, nil
return ret, err
}

func (rt *recordTester) getIngestInfo() (*api.Ingest, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/testers/m3utester2.go
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ func (ms *m3uMediaStream) manifestPullerLoop(wowzaMode bool) {
ms.savePlayList.SeqNo = pl.SeqNo
gotManifest = true
}
glog.Infof("Got media playlist %s with %d (really %d (%d)) segments of url %s: %s", ms.resolution, len(pl.Segments), countSegments(pl), pl.Len(), surl, pl.String())
glog.Infof("Got media playlist %s with %d (really %d (%d)) segments of url %s", ms.resolution, len(pl.Segments), countSegments(pl), pl.Len(), surl)
glog.V(model.INSANE2).Info(string(b))
now := time.Now()
var lastTimeDownloadStarted time.Time
Expand Down
Loading