From bdc61cde86c6b162b7897cecd4575f5392f897a6 Mon Sep 17 00:00:00 2001 From: Eli Mallon Date: Mon, 25 Sep 2023 16:24:08 -0700 Subject: [PATCH] test/e2e: failing test for Mist segmentation --- test/e2e/box_record_test.go | 52 ++++++++++++++++++++++++++++++++++--- test/e2e/e2e_test.go | 10 ++++++- 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/test/e2e/box_record_test.go b/test/e2e/box_record_test.go index d7a2dd6b9..c26a1f929 100644 --- a/test/e2e/box_record_test.go +++ b/test/e2e/box_record_test.go @@ -27,14 +27,36 @@ func TestBoxRecording(t *testing.T) { boxName := randomString("box-") // when - box := startBoxWithEnv(ctx, t, boxName, network.name) + box := startBoxWithEnv(ctx, t, boxName, network.name, []string{}) defer box.Terminate(ctx) err := startRecordTester(ctx) require.NoError(t, err) } -func startBoxWithEnv(ctx context.Context, t *testing.T, hostname, network string) *catalystContainer { +func TestMistSegmentation(t *testing.T) { + if testing.Short() { + t.Skip("skipping testing in short mode") + } + + // given + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + network := createNetwork(ctx, t) + defer network.Remove(ctx) + + boxName := randomString("box-") + + // when + box := startBoxWithEnv(ctx, t, boxName, network.name, []string{"Transcode failed"}) + defer box.Terminate(ctx) + + err := streamMissingHeaders(ctx) + require.NoError(t, err) +} + +func startBoxWithEnv(ctx context.Context, t *testing.T, hostname, network string, failLogs []string) *catalystContainer { req := testcontainers.ContainerRequest{ Image: "livepeer/in-a-box", Hostname: hostname, @@ -51,7 +73,11 @@ func startBoxWithEnv(ctx context.Context, t *testing.T, hostname, network string require.NoError(t, err) // Redirect container logs to the standard logger - lc := logConsumer{name: hostname} + lc := logConsumer{ + name: hostname, + t: t, + failLogs: failLogs, + } err = container.StartLogProducer(ctx) require.NoError(t, err) container.FollowOutput(&lc) @@ -102,6 +128,26 @@ func startRecordTester(ctx context.Context) error { return nil } +func streamMissingHeaders(ctx context.Context) error { + err := run( + ctx, + "ffmpeg", + "-re", + "-i", + "https://storage.googleapis.com/lp_testharness_assets/missing-ts-headers.mkv", + "-c", + "copy", + "-f", + "flv", + "rtmp://127.0.0.1/live/4444-4444-4444-4444", + ) + if err != nil { + return fmt.Errorf("error running ffmpeg: %w", err) + } + + return nil +} + func run(ctx context.Context, prog string, args ...string) error { cmd := exec.CommandContext(ctx, prog, args...) cmd.Stdin = os.Stdin diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 4ee3570d1..6afa5a04a 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -131,10 +131,18 @@ func mistConfigConnectTo(host string, connectToHost string) mistConfig { } type logConsumer struct { - name string + name string + failLogs []string + t *testing.T } func (lc *logConsumer) Accept(l testcontainers.Log) { + content := string(l.Content) + for _, failLog := range lc.failLogs { + if strings.Contains(content, failLog) { + require.Fail(lc.t, fmt.Sprintf(`Found the phrase "%s" in this log line, indicating failure: %s`, failLog, content)) + } + } glog.Infof("[%s] %s", lc.name, string(l.Content)) }