Skip to content

Commit

Permalink
test/e2e: failing test for Mist segmentation
Browse files Browse the repository at this point in the history
  • Loading branch information
iameli committed Sep 25, 2023
1 parent 9e205b4 commit bdc61cd
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 4 deletions.
52 changes: 49 additions & 3 deletions test/e2e/box_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down

0 comments on commit bdc61cd

Please sign in to comment.