mirror of
https://github.com/bluenviron/mediamtx.git
synced 2025-12-24 20:11:56 -08:00
reorganize tests
This commit is contained in:
parent
508d30dc07
commit
af901bb866
4 changed files with 84 additions and 54 deletions
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestRTMPPublish(t *testing.T) {
|
||||
func TestClientRTMPPublish(t *testing.T) {
|
||||
p, ok := testProgram("")
|
||||
require.Equal(t, true, ok)
|
||||
defer p.close()
|
||||
|
|
@ -37,7 +37,7 @@ func TestRTMPPublish(t *testing.T) {
|
|||
require.Equal(t, 0, cnt2.wait())
|
||||
}
|
||||
|
||||
func TestRTMPRead(t *testing.T) {
|
||||
func TestClientRTMPRead(t *testing.T) {
|
||||
p, ok := testProgram("")
|
||||
require.Equal(t, true, ok)
|
||||
defer p.close()
|
||||
|
|
@ -66,7 +66,7 @@ func TestRTMPRead(t *testing.T) {
|
|||
require.Equal(t, 0, cnt2.wait())
|
||||
}
|
||||
|
||||
func TestRTMPAuth(t *testing.T) {
|
||||
func TestClientRTMPAuth(t *testing.T) {
|
||||
t.Run("publish", func(t *testing.T) {
|
||||
p, ok := testProgram("rtspDisable: yes\n" +
|
||||
"paths:\n" +
|
||||
|
|
@ -134,7 +134,7 @@ func TestRTMPAuth(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestRTMPAuthFail(t *testing.T) {
|
||||
func TestClientRTMPAuthFail(t *testing.T) {
|
||||
t.Run("publish", func(t *testing.T) {
|
||||
p, ok := testProgram("rtspDisable: yes\n" +
|
||||
"paths:\n" +
|
||||
|
|
@ -17,7 +17,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestRTSPPublishRead(t *testing.T) {
|
||||
func TestClientRTSPPublishRead(t *testing.T) {
|
||||
for _, ca := range []struct {
|
||||
encrypted bool
|
||||
publisherSoft string
|
||||
|
|
@ -149,7 +149,7 @@ func TestRTSPPublishRead(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestRTSPAuth(t *testing.T) {
|
||||
func TestClientRTSPAuth(t *testing.T) {
|
||||
t.Run("publish", func(t *testing.T) {
|
||||
p, ok := testProgram("rtmpDisable: yes\n" +
|
||||
"paths:\n" +
|
||||
|
|
@ -271,7 +271,7 @@ func TestRTSPAuth(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestRTSPAuthFail(t *testing.T) {
|
||||
func TestClientRTSPAuthFail(t *testing.T) {
|
||||
for _, ca := range []struct {
|
||||
name string
|
||||
user string
|
||||
|
|
@ -389,7 +389,7 @@ func TestRTSPAuthFail(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestRTSPAuthIpFail(t *testing.T) {
|
||||
func TestClientRTSPAuthIpFail(t *testing.T) {
|
||||
p, ok := testProgram("rtmpDisable: yes\n" +
|
||||
"paths:\n" +
|
||||
" all:\n" +
|
||||
|
|
@ -411,7 +411,7 @@ func TestRTSPAuthIpFail(t *testing.T) {
|
|||
require.NotEqual(t, 0, cnt1.wait())
|
||||
}
|
||||
|
||||
func TestRTSPAutomaticProtocol(t *testing.T) {
|
||||
func TestClientRTSPAutomaticProtocol(t *testing.T) {
|
||||
for _, source := range []string{
|
||||
"ffmpeg",
|
||||
} {
|
||||
|
|
@ -448,7 +448,7 @@ func TestRTSPAutomaticProtocol(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestRTSPPublisherOverride(t *testing.T) {
|
||||
func TestClientRTSPPublisherOverride(t *testing.T) {
|
||||
p, ok := testProgram("rtmpDisable: yes\n")
|
||||
require.Equal(t, true, ok)
|
||||
defer p.close()
|
||||
|
|
@ -490,7 +490,7 @@ func TestRTSPPublisherOverride(t *testing.T) {
|
|||
require.Equal(t, 0, dest.wait())
|
||||
}
|
||||
|
||||
func TestRTSPNonCompliantFrameSize(t *testing.T) {
|
||||
func TestClientRTSPNonCompliantFrameSize(t *testing.T) {
|
||||
t.Run("publish", func(t *testing.T) {
|
||||
p, ok := testProgram("rtmpDisable: yes\n" +
|
||||
"readBufferSize: 4500\n")
|
||||
|
|
@ -580,7 +580,7 @@ func TestRTSPNonCompliantFrameSize(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestRTSPRTPInfo(t *testing.T) {
|
||||
func TestClientRTSPRTPInfo(t *testing.T) {
|
||||
p, ok := testProgram("rtmpDisable: yes\n")
|
||||
require.Equal(t, true, ok)
|
||||
defer p.close()
|
||||
|
|
@ -683,7 +683,7 @@ func TestRTSPRTPInfo(t *testing.T) {
|
|||
}()
|
||||
}
|
||||
|
||||
func TestRTSPRedirect(t *testing.T) {
|
||||
func TestClientRTSPRedirect(t *testing.T) {
|
||||
p1, ok := testProgram("rtmpDisable: yes\n" +
|
||||
"paths:\n" +
|
||||
" path1:\n" +
|
||||
|
|
@ -719,7 +719,7 @@ func TestRTSPRedirect(t *testing.T) {
|
|||
require.Equal(t, 0, cnt2.wait())
|
||||
}
|
||||
|
||||
func TestRTSPFallback(t *testing.T) {
|
||||
func TestClientRTSPFallback(t *testing.T) {
|
||||
for _, ca := range []string{
|
||||
"absolute",
|
||||
"relative",
|
||||
|
|
@ -768,7 +768,7 @@ func TestRTSPFallback(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestRTSPRunOnDemand(t *testing.T) {
|
||||
func TestClientRTSPRunOnDemand(t *testing.T) {
|
||||
doneFile := filepath.Join(os.TempDir(), "ondemand_done")
|
||||
onDemandFile, err := writeTempFile([]byte(fmt.Sprintf(`#!/bin/sh
|
||||
trap 'touch %s; [ -z "$(jobs -p)" ] || kill $(jobs -p)' INT
|
||||
62
main_sourcertmp_test.go
Normal file
62
main_sourcertmp_test.go
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestSourceRTMP(t *testing.T) {
|
||||
for _, source := range []string{
|
||||
"videoaudio",
|
||||
"video",
|
||||
} {
|
||||
t.Run(source, func(t *testing.T) {
|
||||
switch source {
|
||||
case "videoaudio", "video":
|
||||
cnt1, err := newContainer("nginx-rtmp", "rtmpserver", []string{})
|
||||
require.NoError(t, err)
|
||||
defer cnt1.close()
|
||||
|
||||
input := "emptyvideoaudio.ts"
|
||||
if source == "video" {
|
||||
input = "emptyvideo.ts"
|
||||
}
|
||||
|
||||
cnt2, err := newContainer("ffmpeg", "source", []string{
|
||||
"-re",
|
||||
"-stream_loop", "-1",
|
||||
"-i", input,
|
||||
"-c", "copy",
|
||||
"-f", "flv",
|
||||
"rtmp://" + cnt1.ip() + "/stream/test",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
defer cnt2.close()
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
p, ok := testProgram("paths:\n" +
|
||||
" proxied:\n" +
|
||||
" source: rtmp://" + cnt1.ip() + "/stream/test\n" +
|
||||
" sourceOnDemand: yes\n")
|
||||
require.Equal(t, true, ok)
|
||||
defer p.close()
|
||||
}
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
cnt3, err := newContainer("ffmpeg", "dest", []string{
|
||||
"-rtsp_transport", "udp",
|
||||
"-i", "rtsp://" + ownDockerIP + ":8554/proxied",
|
||||
"-vframes", "1",
|
||||
"-f", "image2",
|
||||
"-y", "/dev/null",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
defer cnt3.close()
|
||||
require.Equal(t, 0, cnt3.wait())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -8,17 +8,15 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestSource(t *testing.T) {
|
||||
func TestSourceRTSP(t *testing.T) {
|
||||
for _, source := range []string{
|
||||
"rtsp_udp",
|
||||
"rtsp_tcp",
|
||||
"rtsps",
|
||||
"rtmp_videoaudio",
|
||||
"rtmp_video",
|
||||
"udp",
|
||||
"tcp",
|
||||
"tls",
|
||||
} {
|
||||
t.Run(source, func(t *testing.T) {
|
||||
switch source {
|
||||
case "rtsp_udp", "rtsp_tcp":
|
||||
case "udp", "tcp":
|
||||
p1, ok := testProgram("rtmpDisable: yes\n" +
|
||||
"rtspPort: 8555\n" +
|
||||
"rtpPort: 8100\n" +
|
||||
|
|
@ -46,12 +44,12 @@ func TestSource(t *testing.T) {
|
|||
"paths:\n" +
|
||||
" proxied:\n" +
|
||||
" source: rtsp://testuser:testpass@localhost:8555/teststream\n" +
|
||||
" sourceProtocol: " + source[len("rtsp_"):] + "\n" +
|
||||
" sourceProtocol: " + source[len(""):] + "\n" +
|
||||
" sourceOnDemand: yes\n")
|
||||
require.Equal(t, true, ok)
|
||||
defer p2.close()
|
||||
|
||||
case "rtsps":
|
||||
case "tls":
|
||||
serverCertFpath, err := writeTempFile(serverCert)
|
||||
require.NoError(t, err)
|
||||
defer os.Remove(serverCertFpath)
|
||||
|
|
@ -96,36 +94,6 @@ func TestSource(t *testing.T) {
|
|||
" sourceOnDemand: yes\n")
|
||||
require.Equal(t, true, ok)
|
||||
defer p2.close()
|
||||
|
||||
case "rtmp_videoaudio", "rtmp_video":
|
||||
cnt1, err := newContainer("nginx-rtmp", "rtmpserver", []string{})
|
||||
require.NoError(t, err)
|
||||
defer cnt1.close()
|
||||
|
||||
input := "emptyvideoaudio.ts"
|
||||
if source == "rtmp_video" {
|
||||
input = "emptyvideo.ts"
|
||||
}
|
||||
|
||||
cnt2, err := newContainer("ffmpeg", "source", []string{
|
||||
"-re",
|
||||
"-stream_loop", "-1",
|
||||
"-i", input,
|
||||
"-c", "copy",
|
||||
"-f", "flv",
|
||||
"rtmp://" + cnt1.ip() + "/stream/test",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
defer cnt2.close()
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
p, ok := testProgram("paths:\n" +
|
||||
" proxied:\n" +
|
||||
" source: rtmp://" + cnt1.ip() + "/stream/test\n" +
|
||||
" sourceOnDemand: yes\n")
|
||||
require.Equal(t, true, ok)
|
||||
defer p.close()
|
||||
}
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
Loading…
Add table
Add a link
Reference in a new issue