From 0a4731375c401d635e71224929dc400d5f8cc9a4 Mon Sep 17 00:00:00 2001 From: Victor Elias Date: Fri, 9 Sep 2022 17:39:44 -0300 Subject: [PATCH] m3u8: Expose m3u8 tester for VOD (#193) * m3u8: Create exposed m3u8 tester * m3u8: Expose InitCensus func --- m3u8/tester.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 m3u8/tester.go diff --git a/m3u8/tester.go b/m3u8/tester.go new file mode 100644 index 00000000..1111938b --- /dev/null +++ b/m3u8/tester.go @@ -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 +}