diff --git a/go.mod b/go.mod index 2030f690..bd3f519f 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/golang/glog v1.0.0 github.com/gosuri/uilive v0.0.3 // indirect github.com/gosuri/uiprogress v0.0.1 - github.com/livepeer/go-api-client v0.2.9-0.20220908143323-8ff49d9fddce + github.com/livepeer/go-api-client v0.2.9-0.20220916171125-c13c05817515 github.com/livepeer/go-livepeer v0.5.31 github.com/livepeer/joy4 v0.1.2-0.20220210094601-95e4d28f5f07 github.com/livepeer/leaderboard-serverless v1.0.0 diff --git a/go.sum b/go.sum index 759089bc..f2db92d2 100644 --- a/go.sum +++ b/go.sum @@ -710,8 +710,8 @@ github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/livepeer/go-api-client v0.2.9-0.20220908143323-8ff49d9fddce h1:YbZcqp276/5Dp/ys680emXveyt2UTHAirkhg1LUF5MQ= -github.com/livepeer/go-api-client v0.2.9-0.20220908143323-8ff49d9fddce/go.mod h1:Jdb+RI7JyzEZOHd1GUuKofwFDKMO/btTa80SdpUpYQw= +github.com/livepeer/go-api-client v0.2.9-0.20220916171125-c13c05817515 h1:3UvLoSvntPi0Z/yW6zskPmZZwA+lnm0pQVIvG/uBnrE= +github.com/livepeer/go-api-client v0.2.9-0.20220916171125-c13c05817515/go.mod h1:Jdb+RI7JyzEZOHd1GUuKofwFDKMO/btTa80SdpUpYQw= github.com/livepeer/go-livepeer v0.5.31 h1:LcN+qDnqWRws7fdVYc4ucZPVcLQRs2tehUYCQVnlnRw= github.com/livepeer/go-livepeer v0.5.31/go.mod h1:cpBikcGWApkx0cyR0Ht+uAym7j3uAwXGpPbvaOA8XUU= github.com/livepeer/joy4 v0.1.2-0.20191121080656-b2fea45cbded/go.mod h1:xkDdm+akniYxVT9KW1Y2Y7Hso6aW+rZObz3nrA9yTHw= diff --git a/internal/app/vodtester/continuous_vod_tester.go b/internal/app/vodtester/continuous_vod_tester.go index ab603a89..72f23ba2 100644 --- a/internal/app/vodtester/continuous_vod_tester.go +++ b/internal/app/vodtester/continuous_vod_tester.go @@ -120,11 +120,15 @@ func (cvt *continuousVodTester) sendPagerdutyEvent(vt IVodTester, err error) { } return } + summary := fmt.Sprintf("%s:vhs: VOD %s for `%s` error: %v", lopriPrefix, cvt.pagerDutyComponent, cvt.host, err) + if len(summary) > 1024 { + summary = summary[:1021] + "..." + } event.Payload = &pagerduty.V2Payload{ Source: cvt.host, Component: cvt.pagerDutyComponent, Severity: severity, - Summary: fmt.Sprintf("%s:vhs: VOD %s for `%s` error: %v", lopriPrefix, cvt.pagerDutyComponent, cvt.host, err), + Summary: summary, Timestamp: time.Now().UTC().Format(time.RFC3339), } resp, err := pagerduty.ManageEvent(event) diff --git a/internal/app/vodtester/vodtester_app.go b/internal/app/vodtester/vodtester_app.go index 521768b8..2104a5f3 100644 --- a/internal/app/vodtester/vodtester_app.go +++ b/internal/app/vodtester/vodtester_app.go @@ -45,7 +45,7 @@ func NewVodTester(gctx context.Context, opts VodTesterOptions) IVodTester { func (vt *vodTester) Start(fileName string, vodImportUrl string, taskPollDuration time.Duration) (int, error) { defer vt.cancel() - eg, _ := errgroup.WithContext(vt.ctx) + eg, egCtx := errgroup.WithContext(vt.ctx) eg.Go(func() error { @@ -91,7 +91,6 @@ func (vt *vodTester) Start(fileName string, vodImportUrl string, taskPollDuratio }) eg.Go(func() error { - err := vt.directUploadTester(fileName, taskPollDuration) if err != nil { @@ -112,13 +111,15 @@ func (vt *vodTester) Start(fileName string, vodImportUrl string, taskPollDuratio return nil }) - + go func() { + <-egCtx.Done() + vt.cancel() + }() if err := eg.Wait(); err != nil { return 1, err } glog.Info("Done VOD Test") - return 0, nil } @@ -164,7 +165,7 @@ func (vt *vodTester) directUploadTester(fileName string, taskPollDuration time.D return fmt.Errorf("error opening file=%s: %w", fileName, err) } - err = vt.lapi.UploadAsset(uploadEndpoint, file) + err = vt.lapi.UploadAsset(vt.ctx, uploadEndpoint, file) if err != nil { glog.Errorf("Error uploading file filePath=%s err=%v", fileName, err) return fmt.Errorf("error uploading for assetId=%s taskId=%s: %w", uploadAsset.ID, uploadTask.ID, err) @@ -178,6 +179,7 @@ func (vt *vodTester) directUploadTester(fileName string, taskPollDuration time.D } func (vt *vodTester) resumableUploadTester(fileName string, taskPollDuration time.Duration) error { + hostName, _ := os.Hostname() assetName := fmt.Sprintf("vod_test_upload_resumable_%s_%s", hostName, time.Now().Format("2006-01-02T15:04:05Z07:00")) requestUpload, err := vt.lapi.RequestUpload(assetName)