Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: add a failing test for Mist segmentation #675

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions scripts/livepeer-nginx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ http {
proxy_pass http://127.0.0.1:9000;
}

location /stream/ {
proxy_pass http://127.0.0.1:8935;
}

location /live/ {
proxy_pass http://127.0.0.1:8935;
}

location / {
proxy_pass http://127.0.0.1:3004;
}
Expand Down
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