1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

SRS5: Test: Add blackbox for HLS.

PICK 30779f3b5a
This commit is contained in:
winlin 2023-01-02 22:47:51 +08:00
parent 4c2db0073a
commit 2cab98aa68
3 changed files with 231 additions and 48 deletions

View file

@ -42,9 +42,9 @@ func TestRtmpPublish_RtmpPlay_Basic(t *testing.T) {
defer cancel()
// Check a set of errors.
var r0, r1, r2, r3 error
var r0, r1, r2, r3, r4, r5 error
defer func(ctx context.Context) {
if err := filterTestError(ctx.Err(), r0, r1, r2, r3); err != nil {
if err := filterTestError(ctx.Err(), r0, r1, r2, r3, r4, r5); err != nil {
t.Errorf("Fail for err %+v", err)
} else {
logger.Tf(ctx, "test done with err %+v", err)
@ -55,11 +55,7 @@ func TestRtmpPublish_RtmpPlay_Basic(t *testing.T) {
defer wg.Wait()
// Start SRS server and wait for it to be ready.
svr := NewSRSServer(func(v *srsServer) {
v.envs = []string{
fmt.Sprintf("SRS_LISTEN=%v", v.rtmpListen),
}
})
svr := NewSRSServer()
wg.Add(1)
go func() {
defer wg.Done()
@ -84,7 +80,7 @@ func TestRtmpPublish_RtmpPlay_Basic(t *testing.T) {
// Start FFprobe to detect and verify stream.
duration := time.Duration(*srsFFprobeDuration) * time.Millisecond
ffprobe := NewFFprobe(func(v *ffprobeClient) {
v.dvrFile = path.Join(svr.WorkDir(), "objs", fmt.Sprintf("srs-ffprobe-%v.mp4", streamID))
v.dvrFile = path.Join(svr.WorkDir(), "objs", fmt.Sprintf("srs-ffprobe-%v.flv", streamID))
v.streamURL, v.duration, v.timeout = streamURL, duration, time.Duration(*srsFFprobeTimeout)*time.Millisecond
})
wg.Add(1)
@ -104,6 +100,13 @@ func TestRtmpPublish_RtmpPlay_Basic(t *testing.T) {
if len(m.Streams) != 2 {
r3 = errors.Errorf("invalid streams=%v, %v, %v", len(m.Streams), m.String(), str)
}
if ts := 90; m.Format.ProbeScore < ts {
r4 = errors.Errorf("low score=%v < %v, %v, %v", m.Format.ProbeScore, ts, m.String(), str)
}
if dv := m.Duration(); dv < duration {
r5 = errors.Errorf("short duration=%v < %v, %v, %v", dv, duration, m.String(), str)
}
}
}
@ -116,9 +119,9 @@ func TestRtmpPublish_FlvPlay_Basic(t *testing.T) {
defer cancel()
// Check a set of errors.
var r0, r1, r2, r3 error
var r0, r1, r2, r3, r4, r5 error
defer func(ctx context.Context) {
if err := filterTestError(ctx.Err(), r0, r1, r2, r3); err != nil {
if err := filterTestError(ctx.Err(), r0, r1, r2, r3, r4, r5); err != nil {
t.Errorf("Fail for err %+v", err)
} else {
logger.Tf(ctx, "test done with err %+v", err)
@ -131,9 +134,7 @@ func TestRtmpPublish_FlvPlay_Basic(t *testing.T) {
// Start SRS server and wait for it to be ready.
svr := NewSRSServer(func(v *srsServer) {
v.envs = []string{
fmt.Sprintf("SRS_LISTEN=%v", v.rtmpListen),
"SRS_HTTP_SERVER_ENABLED=on",
fmt.Sprintf("SRS_HTTP_SERVER_LISTEN=%v", v.httpListen),
"SRS_VHOST_HTTP_REMUX_ENABLED=on",
}
})
@ -161,7 +162,7 @@ func TestRtmpPublish_FlvPlay_Basic(t *testing.T) {
// Start FFprobe to detect and verify stream.
duration := time.Duration(*srsFFprobeDuration) * time.Millisecond
ffprobe := NewFFprobe(func(v *ffprobeClient) {
v.dvrFile = path.Join(svr.WorkDir(), "objs", fmt.Sprintf("srs-ffprobe-%v.mp4", streamID))
v.dvrFile = path.Join(svr.WorkDir(), "objs", fmt.Sprintf("srs-ffprobe-%v.flv", streamID))
v.streamURL = fmt.Sprintf("http://localhost:%v/live/%v.flv", svr.HTTPPort(), streamID)
v.duration, v.timeout = duration, time.Duration(*srsFFprobeTimeout)*time.Millisecond
})
@ -182,5 +183,12 @@ func TestRtmpPublish_FlvPlay_Basic(t *testing.T) {
if len(m.Streams) != 2 {
r3 = errors.Errorf("invalid streams=%v, %v, %v", len(m.Streams), m.String(), str)
}
if ts := 90; m.Format.ProbeScore < ts {
r4 = errors.Errorf("low score=%v < %v, %v, %v", m.Format.ProbeScore, ts, m.String(), str)
}
if dv := m.Duration(); dv < duration {
r5 = errors.Errorf("short duration=%v < %v, %v, %v", dv, duration, m.String(), str)
}
}
}