mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Test: Add chunksize and atc blackbox test for RTMP.
This commit is contained in:
parent
d02b942263
commit
c31a8076bb
5 changed files with 178 additions and 7 deletions
11
trunk/3rdparty/srs-bench/README.md
vendored
11
trunk/3rdparty/srs-bench/README.md
vendored
|
@ -27,7 +27,7 @@ cd srs-bench && make
|
|||
|
||||
```bash
|
||||
git clone https://github.com/ossrs/srs.git &&
|
||||
cd srs/trunk && ./configure && make &&
|
||||
cd srs/trunk && ./configure --h265=on --gb28181=on && make &&
|
||||
./objs/srs -c conf/console.conf
|
||||
```
|
||||
|
||||
|
@ -240,6 +240,15 @@ go test ./blackbox -mod=vendor -v -count=1
|
|||
make && ./objs/srs_blackbox_test -test.v
|
||||
```
|
||||
|
||||
由于黑盒测试依赖特殊的FFmpeg,可以在Docker中编译和启动:
|
||||
|
||||
```bash
|
||||
docker run --rm -it -v $(pwd):/g -w /g ossrs/srs:ubuntu20 bash
|
||||
make && ./objs/srs_blackbox_test -test.v
|
||||
```
|
||||
|
||||
> Note: 依赖SRS二进制,当然也可以在这个Docker中编译SRS,具体请参考SRS的Wiki。
|
||||
|
||||
支持的参数如下:
|
||||
|
||||
* `-srs-binary`,每个测试用例都需要启动一个SRS服务,因此需要设置SRS的位置。默认值:`../../objs/srs`
|
||||
|
|
|
@ -117,7 +117,7 @@ func TestRtmpPublish_RtmpPlay_CodecMP3_Basic(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestRtmpPublish_FlvPlay_CodecMP3_Basic(t *testing.T) {
|
||||
func TestRtmpPublish_HttpFlvPlay_CodecMP3_Basic(t *testing.T) {
|
||||
// This case is run in parallel.
|
||||
t.Parallel()
|
||||
|
||||
|
|
164
trunk/3rdparty/srs-bench/blackbox/rtmp_test.go
vendored
164
trunk/3rdparty/srs-bench/blackbox/rtmp_test.go
vendored
|
@ -110,7 +110,7 @@ func TestRtmpPublish_RtmpPlay_Basic(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestRtmpPublish_FlvPlay_Basic(t *testing.T) {
|
||||
func TestRtmpPublish_HttpFlvPlay_Basic(t *testing.T) {
|
||||
// This case is run in parallel.
|
||||
t.Parallel()
|
||||
|
||||
|
@ -192,3 +192,165 @@ func TestRtmpPublish_FlvPlay_Basic(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRtmpPublish_RtmpPlay_ChunkSize128(t *testing.T) {
|
||||
// This case is run in parallel.
|
||||
t.Parallel()
|
||||
|
||||
// Setup the max timeout for this case.
|
||||
ctx, cancel := context.WithTimeout(logger.WithContext(context.Background()), time.Duration(*srsTimeout)*time.Millisecond)
|
||||
defer cancel()
|
||||
|
||||
// Check a set of errors.
|
||||
var r0, r1, r2, r3, r4, r5 error
|
||||
defer func(ctx context.Context) {
|
||||
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)
|
||||
}
|
||||
}(ctx)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
defer wg.Wait()
|
||||
|
||||
// Start SRS server and wait for it to be ready.
|
||||
svr := NewSRSServer(func(v *srsServer) {
|
||||
v.envs = []string{
|
||||
"SRS_CHUNK_SIZE=128",
|
||||
}
|
||||
})
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
r0 = svr.Run(ctx, cancel)
|
||||
}()
|
||||
|
||||
// Start FFmpeg to publish stream.
|
||||
streamID := fmt.Sprintf("stream-%v-%v", os.Getpid(), rand.Int())
|
||||
streamURL := fmt.Sprintf("rtmp://localhost:%v/live/%v", svr.RTMPPort(), streamID)
|
||||
ffmpeg := NewFFmpeg(func(v *ffmpegClient) {
|
||||
v.args = []string{
|
||||
"-stream_loop", "-1", "-re", "-i", *srsPublishAvatar, "-c", "copy", "-f", "flv", streamURL,
|
||||
}
|
||||
})
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
<-svr.ReadyCtx().Done()
|
||||
r1 = ffmpeg.Run(ctx, cancel)
|
||||
}()
|
||||
|
||||
// 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.flv", streamID))
|
||||
v.streamURL, v.duration, v.timeout = streamURL, duration, time.Duration(*srsFFprobeTimeout)*time.Millisecond
|
||||
})
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
<-svr.ReadyCtx().Done()
|
||||
r2 = ffprobe.Run(ctx, cancel)
|
||||
}()
|
||||
|
||||
// Fast quit for probe done.
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
case <-ffprobe.ProbeDoneCtx().Done():
|
||||
defer cancel()
|
||||
|
||||
str, m := ffprobe.Result()
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRtmpPublish_RtmpPlay_EnableATC(t *testing.T) {
|
||||
// This case is run in parallel.
|
||||
t.Parallel()
|
||||
|
||||
// Setup the max timeout for this case.
|
||||
ctx, cancel := context.WithTimeout(logger.WithContext(context.Background()), time.Duration(*srsTimeout)*time.Millisecond)
|
||||
defer cancel()
|
||||
|
||||
// Check a set of errors.
|
||||
var r0, r1, r2, r3, r4, r5 error
|
||||
defer func(ctx context.Context) {
|
||||
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)
|
||||
}
|
||||
}(ctx)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
defer wg.Wait()
|
||||
|
||||
// Start SRS server and wait for it to be ready.
|
||||
svr := NewSRSServer(func(v *srsServer) {
|
||||
v.envs = []string{
|
||||
"SRS_VHOST_PLAY_ATC=on",
|
||||
}
|
||||
})
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
r0 = svr.Run(ctx, cancel)
|
||||
}()
|
||||
|
||||
// Start FFmpeg to publish stream.
|
||||
streamID := fmt.Sprintf("stream-%v-%v", os.Getpid(), rand.Int())
|
||||
streamURL := fmt.Sprintf("rtmp://localhost:%v/live/%v", svr.RTMPPort(), streamID)
|
||||
ffmpeg := NewFFmpeg(func(v *ffmpegClient) {
|
||||
v.args = []string{
|
||||
"-stream_loop", "-1", "-re", "-i", *srsPublishAvatar, "-c", "copy", "-f", "flv", streamURL,
|
||||
}
|
||||
})
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
<-svr.ReadyCtx().Done()
|
||||
r1 = ffmpeg.Run(ctx, cancel)
|
||||
}()
|
||||
|
||||
// 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.flv", streamID))
|
||||
v.streamURL, v.duration, v.timeout = streamURL, duration, time.Duration(*srsFFprobeTimeout)*time.Millisecond
|
||||
})
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
<-svr.ReadyCtx().Done()
|
||||
r2 = ffprobe.Run(ctx, cancel)
|
||||
}()
|
||||
|
||||
// Fast quit for probe done.
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
case <-ffprobe.ProbeDoneCtx().Done():
|
||||
defer cancel()
|
||||
|
||||
str, m := ffprobe.Result()
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
trunk/3rdparty/srs-bench/srs/rtc_test.go
vendored
2
trunk/3rdparty/srs-bench/srs/rtc_test.go
vendored
|
@ -1940,7 +1940,7 @@ func TestRTCServerVersion(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestRtcPublish_FlvPlay(t *testing.T) {
|
||||
func TestRtcPublish_HttpFlvPlay(t *testing.T) {
|
||||
ctx := logger.WithContext(context.Background())
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Duration(*srsTimeout)*time.Millisecond)
|
||||
|
||||
|
|
6
trunk/3rdparty/srs-bench/srs/rtmp_test.go
vendored
6
trunk/3rdparty/srs-bench/srs/rtmp_test.go
vendored
|
@ -395,7 +395,7 @@ func TestRtmpPublish_MultipleSequences_RtcPlay(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestRtmpPublish_FlvPlay(t *testing.T) {
|
||||
func TestRtmpPublish_HttpFlvPlay(t *testing.T) {
|
||||
ctx := logger.WithContext(context.Background())
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Duration(*srsTimeout)*time.Millisecond)
|
||||
|
||||
|
@ -472,7 +472,7 @@ func TestRtmpPublish_FlvPlay(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestRtmpPublish_FlvPlayNoAudio(t *testing.T) {
|
||||
func TestRtmpPublish_HttpFlvPlayNoAudio(t *testing.T) {
|
||||
ctx := logger.WithContext(context.Background())
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Duration(*srsTimeout)*time.Millisecond)
|
||||
|
||||
|
@ -555,7 +555,7 @@ func TestRtmpPublish_FlvPlayNoAudio(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestRtmpPublish_FlvPlayNoVideo(t *testing.T) {
|
||||
func TestRtmpPublish_HttpFlvPlayNoVideo(t *testing.T) {
|
||||
ctx := logger.WithContext(context.Background())
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Duration(*srsTimeout)*time.Millisecond)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue