From e327b70778b46a2aef6e87770fb9003f4e41cb76 Mon Sep 17 00:00:00 2001 From: Victor Elias Date: Wed, 19 Jun 2024 21:34:37 +0100 Subject: [PATCH] e2e: Add test on copy-only recording (#965) * e2e: Add test on copy-only recording * e2e: Skip source playback on record-tester test * e2e: Improve parallel record-tester handling * e2e: Give box up to 3 minutes to start Improves local runs at least * manifest: Upgrade API release We only support Linux AMD64 now AFAIK * go.mod: Update stream-tester version --- go.mod | 12 +++---- go.sum | 21 +++++++------ manifest.yaml | 6 ++-- test/e2e/box_record_test.go | 62 ++++++++++++++++++++++++++----------- 4 files changed, 65 insertions(+), 36 deletions(-) diff --git a/go.mod b/go.mod index 6eb38aebb..4dd7835b4 100644 --- a/go.mod +++ b/go.mod @@ -6,8 +6,8 @@ replace github.com/testcontainers/testcontainers-go v0.26.0 => github.com/lefina require ( github.com/ProtonMail/gopenpgp/v2 v2.4.10 - github.com/golang/glog v1.1.2 - github.com/livepeer/stream-tester v0.12.30-0.20230823234013-5cfb4bbcf27d + github.com/golang/glog v1.2.1 + github.com/livepeer/stream-tester v0.12.30-0.20240619182724-f98674f33674 github.com/magicsong/color-glog v0.0.1 github.com/minio/minio-go/v7 v7.0.46 github.com/peterbourgon/ff/v3 v3.3.1 @@ -76,7 +76,7 @@ require ( github.com/klauspost/cpuid/v2 v2.2.4 // indirect github.com/kr/text v0.2.0 // indirect github.com/livepeer/catalyst-api v0.1.1 // indirect - github.com/livepeer/go-api-client v0.4.7 // indirect + github.com/livepeer/go-api-client v0.4.24-0.20240607131835-949d242a631b // indirect github.com/livepeer/joy4 v0.1.2-0.20220210094601-95e4d28f5f07 // indirect github.com/livepeer/m3u8 v0.11.1 // indirect github.com/magiconair/properties v1.8.7 // indirect @@ -114,11 +114,11 @@ require ( golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.18.0 // indirect golang.org/x/oauth2 v0.13.0 // indirect - golang.org/x/sync v0.5.0 // indirect + golang.org/x/sync v0.5.0 golang.org/x/tools v0.15.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.149.0 // indirect - google.golang.org/appengine v1.6.7 // indirect + google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20231030173426-d783a09b4405 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect @@ -136,7 +136,7 @@ require ( github.com/containerd/log v0.1.0 // indirect github.com/distribution/reference v0.5.0 // indirect github.com/go-ole/go-ole v1.3.0 // indirect - github.com/livepeer/livepeer-data v0.7.3 // indirect + github.com/livepeer/livepeer-data v0.7.5-0.20231004073737-06f1f383fb18 // indirect github.com/lufia/plan9stats v0.0.0-20231016141302-07b5767bb0ed // indirect github.com/pkg/errors v0.9.1 // indirect github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect diff --git a/go.sum b/go.sum index 3e3026c13..9249f702d 100644 --- a/go.sum +++ b/go.sum @@ -182,8 +182,8 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= -github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo= -github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ= +github.com/golang/glog v1.2.1 h1:OptwRhECazUx5ix5TTWC3EZhsZEHWcYWY4FQHTIubm4= +github.com/golang/glog v1.2.1/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -340,16 +340,16 @@ github.com/lefinal/testcontainers-go v0.0.0-20231107224233-ca049655293f h1:D+6lS github.com/lefinal/testcontainers-go v0.0.0-20231107224233-ca049655293f/go.mod h1:C1b+AP3uPSlG6aNY8icPePlED0bHR7sSTKQDh23oCdA= github.com/livepeer/catalyst-api v0.1.1 h1:WP4rHH88b+lsxo33wPCjl0yvqVDNyxkleZH1sA0M5GE= github.com/livepeer/catalyst-api v0.1.1/go.mod h1:d6XPE9ehhCutWhCqqcmlYqQa+e9bf3Ke92x+gRZlzoQ= -github.com/livepeer/go-api-client v0.4.7 h1:pJd0Ba7TtDJDUEOiPBx9KmLm+fIB8GRbAurd3lsZUVY= -github.com/livepeer/go-api-client v0.4.7/go.mod h1:Jdb+RI7JyzEZOHd1GUuKofwFDKMO/btTa80SdpUpYQw= +github.com/livepeer/go-api-client v0.4.24-0.20240607131835-949d242a631b h1:J8cWLpnTINGAWVPU503SnUhTmuDhXnm9QxpC/CFGk2k= +github.com/livepeer/go-api-client v0.4.24-0.20240607131835-949d242a631b/go.mod h1:Jdb+RI7JyzEZOHd1GUuKofwFDKMO/btTa80SdpUpYQw= github.com/livepeer/joy4 v0.1.2-0.20220210094601-95e4d28f5f07 h1:ISkFQYYDgfnM6Go+VyemF66DKFc8kNoI9SwMv7GC9sM= github.com/livepeer/joy4 v0.1.2-0.20220210094601-95e4d28f5f07/go.mod h1:RDTLvmm/NJWjzuUpEDyIWmLTqSfpZEcnPnacG8sfh34= -github.com/livepeer/livepeer-data v0.7.3 h1:m7MQ6oMqvhsP+quA9aQnLyVn8fp/as+gliyNyB/99cU= -github.com/livepeer/livepeer-data v0.7.3/go.mod h1:Jpf4jHK+fbWioBHRDRM1WadNT1qmY27g2YicTdO0Rtc= +github.com/livepeer/livepeer-data v0.7.5-0.20231004073737-06f1f383fb18 h1:4oH3NqV0NvcdS44Ld3zK2tO8IUiNozIggm74yobQeZg= +github.com/livepeer/livepeer-data v0.7.5-0.20231004073737-06f1f383fb18/go.mod h1:Jpf4jHK+fbWioBHRDRM1WadNT1qmY27g2YicTdO0Rtc= github.com/livepeer/m3u8 v0.11.1 h1:VkUJzfNTyjy9mqsgp5JPvouwna8wGZMvd/gAfT5FinU= github.com/livepeer/m3u8 v0.11.1/go.mod h1:IUqAtwWPAG2CblfQa4SVzTQoDcEMPyfNOaBSxqHMS04= -github.com/livepeer/stream-tester v0.12.30-0.20230823234013-5cfb4bbcf27d h1:kefJp8RvevkCPthCtKTFvhbBSVrddAn7NZoLdQD/llQ= -github.com/livepeer/stream-tester v0.12.30-0.20230823234013-5cfb4bbcf27d/go.mod h1:lc881i0A7AtPRsINxtoEB6B6qE0X7cglnDPU8xHQlUo= +github.com/livepeer/stream-tester v0.12.30-0.20240619182724-f98674f33674 h1:jztbUuNPVT7elLXq8uP6Vm3OFpNeQG0fzVN4CH3zI7w= +github.com/livepeer/stream-tester v0.12.30-0.20240619182724-f98674f33674/go.mod h1:gZQjy1ZbBcf6vcbwRL8poiXTmlWvOUaeZA6jSpfBSXM= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/lufia/plan9stats v0.0.0-20231016141302-07b5767bb0ed h1:036IscGBfJsFIgJQzlui7nK1Ncm0tp2ktmPj8xO4N/0= github.com/lufia/plan9stats v0.0.0-20231016141302-07b5767bb0ed/go.mod h1:ilwx/Dta8jXAgpFYFvSWEMwxmbWXyiUHkd5FwyKhb5k= @@ -746,6 +746,7 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= @@ -833,8 +834,8 @@ google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= diff --git a/manifest.yaml b/manifest.yaml index 7f1c70dc8..76ef6bd02 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -18,8 +18,10 @@ box: strategy: download: github project: livepeer/studio - commit: 66a216519b7f249e9482ca54fc90bd8e1db4010d - release: v0.16.2 + commit: 957742a723796b3e47ddd4d0ced6600771fb885e + release: v0.19.0 + srcFilenames: + linux-amd64: livepeer-api.tar.gz - name: catalyst-api strategy: download: bucket diff --git a/test/e2e/box_record_test.go b/test/e2e/box_record_test.go index 596d21027..5c2c34478 100644 --- a/test/e2e/box_record_test.go +++ b/test/e2e/box_record_test.go @@ -1,15 +1,19 @@ package e2e import ( + "bytes" "context" "fmt" "os" "os/exec" + "sync" "testing" + "time" "github.com/stretchr/testify/require" "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/wait" + "golang.org/x/sync/errgroup" ) func TestBoxRecording(t *testing.T) { @@ -30,8 +34,14 @@ func TestBoxRecording(t *testing.T) { box := startBoxWithEnv(ctx, t, boxName, network.name) defer box.Terminate(ctx) - err := startRecordTester(ctx) - require.NoError(t, err) + eg, ctx := errgroup.WithContext(ctx) + eg.Go(func() error { + return startRecordTester(ctx, false) + }) + eg.Go(func() error { + return startRecordTester(ctx, true) + }) + require.NoError(t, eg.Wait()) } func startBoxWithEnv(ctx context.Context, t *testing.T, hostname, network string) *catalystContainer { @@ -42,7 +52,7 @@ func startBoxWithEnv(ctx context.Context, t *testing.T, hostname, network string Networks: []string{network}, ExposedPorts: []string{"1935:1935/tcp", "8888:8888/tcp"}, ShmSize: 1000000000, - WaitingFor: wait.NewLogStrategy("API server listening"), + WaitingFor: wait.NewLogStrategy("API server listening").WithStartupTimeout(3 * time.Minute), Env: map[string]string{ "LP_API_FRONTEND": "false", }, @@ -87,39 +97,55 @@ func startBoxWithEnv(ctx context.Context, t *testing.T, hostname, network string return catalyst } -func startRecordTester(ctx context.Context) error { - fmt.Println("starting record tester") - err := run( - ctx, - "go", +func startRecordTester(ctx context.Context, recordingCopyOnly bool) error { + startTime := time.Now() + fmt.Printf("starting record tester copyOnly=%v\n", recordingCopyOnly) + args := []string{ "run", "github.com/livepeer/stream-tester/cmd/recordtester", "-api-server=http://127.0.0.1:8888", "-api-token=f61b3cdb-d173-4a7a-a0d3-547b871a56f9", "-test-dur=1m", "-file=https://github.com/livepeer/catalyst-api/assets/136638730/1f71068a-0396-43c2-b870-95a6ad644ffb", - ) - fmt.Println("record tester finished") - if err != nil { - return fmt.Errorf("error running recordtester: %w", err) + "-skip-source-playback", + } + if recordingCopyOnly { + args = append(args, `-recording-spec={"profiles":[]}`) } + output, err := run(ctx, "go", args...) + fmt.Printf("finished record tester copyOnly=%v duration=%s error=%v output:\n%s\n", recordingCopyOnly, time.Since(startTime), err, output) + if err != nil { + return fmt.Errorf("error running recordtester (copyOnly=%v): %w", recordingCopyOnly, err) + } return nil } -func run(ctx context.Context, prog string, args ...string) error { +type lockedBuffer struct { + mu sync.Mutex + bytes.Buffer +} + +func (lw *lockedBuffer) Write(p []byte) (n int, err error) { + lw.mu.Lock() + defer lw.mu.Unlock() + return lw.Buffer.Write(p) +} + +func run(ctx context.Context, prog string, args ...string) ([]byte, error) { cmd := exec.CommandContext(ctx, prog, args...) cmd.Stdin = os.Stdin - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr + output := &lockedBuffer{} + cmd.Stdout = output + cmd.Stderr = output err := cmd.Start() if err != nil { - return fmt.Errorf("error invoking %s: %w", prog, err) + return output.Bytes(), fmt.Errorf("error invoking %s: %w", prog, err) } err = cmd.Wait() if err != nil { - return fmt.Errorf("error running %s: %w", prog, err) + return output.Bytes(), fmt.Errorf("error running %s: %w", prog, err) } - return nil + return output.Bytes(), nil }