-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
m3u8: Expose m3u8 tester for VOD (#193)
* m3u8: Create exposed m3u8 tester * m3u8: Expose InitCensus func
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |