Skip to content

Commit

Permalink
m3u8: Expose m3u8 tester for VOD (#193)
Browse files Browse the repository at this point in the history
* m3u8: Create exposed m3u8 tester

* m3u8: Expose InitCensus func
  • Loading branch information
victorges authored Sep 9, 2022
1 parent 3330803 commit 0a47313
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions m3u8/tester.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package m3u8

import (
"context"
"fmt"
"os"
"time"

"github.com/livepeer/go-api-client"
"github.com/livepeer/stream-tester/internal/metrics"
"github.com/livepeer/stream-tester/internal/testers"
)

func InitCensus(service, version string) {
hostname, _ := os.Hostname()
metrics.InitCensus(hostname, version, service)
}

func Check(ctx context.Context, url string, expectedDuration time.Duration) error {
downloader := testers.NewM3utester2(ctx, url, false, false, false, false, 5*time.Second, nil, false)
<-downloader.Done()
stats := downloader.VODStats()
if len(stats.SegmentsNum) != len(api.StandardProfiles)+1 {
return fmt.Errorf("number of renditions doesn't match (has %d should %d)", len(stats.SegmentsNum), len(api.StandardProfiles)+1)
}
if ok, ers := stats.IsOk(expectedDuration, false); !ok {
return fmt.Errorf("playlist not ok: %s", ers)
}
return nil
}

0 comments on commit 0a47313

Please sign in to comment.