2021-08-12 09:48:47 +00:00
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
2023-11-08 10:20:16 +00:00
|
|
|
"bufio"
|
|
|
|
"context"
|
2022-11-11 10:59:52 +00:00
|
|
|
"crypto/tls"
|
2024-02-13 22:32:15 +00:00
|
|
|
"io"
|
2022-11-02 17:25:49 +00:00
|
|
|
"net"
|
2023-05-18 17:16:07 +00:00
|
|
|
"net/http"
|
2022-11-02 17:25:49 +00:00
|
|
|
"net/url"
|
2021-08-12 09:48:47 +00:00
|
|
|
"os"
|
2023-11-08 10:20:16 +00:00
|
|
|
"sync"
|
2021-08-12 09:48:47 +00:00
|
|
|
"testing"
|
2023-05-18 18:05:35 +00:00
|
|
|
"time"
|
2021-08-12 09:48:47 +00:00
|
|
|
|
2023-08-26 16:54:28 +00:00
|
|
|
"github.com/bluenviron/gortsplib/v4"
|
|
|
|
"github.com/bluenviron/gortsplib/v4/pkg/description"
|
2023-11-08 10:20:16 +00:00
|
|
|
"github.com/bluenviron/mediacommon/pkg/formats/mpegts"
|
2023-12-03 15:42:12 +00:00
|
|
|
srt "github.com/datarhei/gosrt"
|
2023-11-08 10:20:16 +00:00
|
|
|
"github.com/pion/rtp"
|
2024-09-09 10:59:23 +00:00
|
|
|
pwebrtc "github.com/pion/webrtc/v3"
|
2021-08-12 09:48:47 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2022-11-02 17:25:49 +00:00
|
|
|
|
2023-10-26 19:46:18 +00:00
|
|
|
"github.com/bluenviron/mediamtx/internal/protocols/rtmp"
|
2023-11-08 10:20:16 +00:00
|
|
|
"github.com/bluenviron/mediamtx/internal/protocols/webrtc"
|
2024-09-09 10:59:23 +00:00
|
|
|
"github.com/bluenviron/mediamtx/internal/protocols/whip"
|
2024-02-13 17:49:27 +00:00
|
|
|
"github.com/bluenviron/mediamtx/internal/test"
|
2021-08-12 09:48:47 +00:00
|
|
|
)
|
|
|
|
|
2024-02-13 22:32:15 +00:00
|
|
|
func httpPullFile(t *testing.T, hc *http.Client, u string) []byte {
|
|
|
|
res, err := hc.Get(u)
|
|
|
|
require.NoError(t, err)
|
|
|
|
defer res.Body.Close()
|
|
|
|
|
|
|
|
if res.StatusCode != http.StatusOK {
|
|
|
|
t.Errorf("bad status code: %v", res.StatusCode)
|
|
|
|
}
|
|
|
|
|
|
|
|
byts, err := io.ReadAll(res.Body)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
return byts
|
|
|
|
}
|
|
|
|
|
2021-08-12 09:48:47 +00:00
|
|
|
func TestMetrics(t *testing.T) {
|
2024-02-17 19:42:41 +00:00
|
|
|
serverCertFpath, err := test.CreateTempFile(test.TLSCertPub)
|
2021-08-12 09:48:47 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
defer os.Remove(serverCertFpath)
|
|
|
|
|
2024-02-17 19:42:41 +00:00
|
|
|
serverKeyFpath, err := test.CreateTempFile(test.TLSCertKey)
|
2021-08-12 09:48:47 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
defer os.Remove(serverKeyFpath)
|
|
|
|
|
2023-12-03 15:42:12 +00:00
|
|
|
p, ok := newInstance("api: yes\n" +
|
|
|
|
"hlsAlwaysRemux: yes\n" +
|
2023-04-13 16:15:13 +00:00
|
|
|
"metrics: yes\n" +
|
2022-12-15 23:50:47 +00:00
|
|
|
"webrtcServerCert: " + serverCertFpath + "\n" +
|
|
|
|
"webrtcServerKey: " + serverKeyFpath + "\n" +
|
2021-08-12 09:48:47 +00:00
|
|
|
"encryption: optional\n" +
|
|
|
|
"serverCert: " + serverCertFpath + "\n" +
|
2021-11-06 11:51:38 +00:00
|
|
|
"serverKey: " + serverKeyFpath + "\n" +
|
2023-12-03 15:59:35 +00:00
|
|
|
"rtmpEncryption: optional\n" +
|
|
|
|
"rtmpServerCert: " + serverCertFpath + "\n" +
|
|
|
|
"rtmpServerKey: " + serverKeyFpath + "\n" +
|
2021-11-06 11:51:38 +00:00
|
|
|
"paths:\n" +
|
2023-10-09 16:13:44 +00:00
|
|
|
" all_others:\n")
|
2021-08-12 09:48:47 +00:00
|
|
|
require.Equal(t, true, ok)
|
2022-11-02 17:25:49 +00:00
|
|
|
defer p.Close()
|
2021-08-12 09:48:47 +00:00
|
|
|
|
2024-03-10 10:51:15 +00:00
|
|
|
tr := &http.Transport{}
|
|
|
|
defer tr.CloseIdleConnections()
|
|
|
|
hc := &http.Client{Transport: tr}
|
2023-05-18 17:16:07 +00:00
|
|
|
|
2023-12-03 15:42:12 +00:00
|
|
|
t.Run("initial", func(t *testing.T) {
|
|
|
|
bo := httpPullFile(t, hc, "http://localhost:9998/metrics")
|
2023-04-11 18:47:29 +00:00
|
|
|
|
2023-12-03 15:42:12 +00:00
|
|
|
require.Equal(t, `paths 0
|
2023-04-11 18:47:29 +00:00
|
|
|
hls_muxers 0
|
|
|
|
hls_muxers_bytes_sent 0
|
|
|
|
rtsp_conns 0
|
|
|
|
rtsp_conns_bytes_received 0
|
|
|
|
rtsp_conns_bytes_sent 0
|
|
|
|
rtsp_sessions 0
|
|
|
|
rtsp_sessions_bytes_received 0
|
|
|
|
rtsp_sessions_bytes_sent 0
|
|
|
|
rtsps_conns 0
|
|
|
|
rtsps_conns_bytes_received 0
|
|
|
|
rtsps_conns_bytes_sent 0
|
|
|
|
rtsps_sessions 0
|
|
|
|
rtsps_sessions_bytes_received 0
|
|
|
|
rtsps_sessions_bytes_sent 0
|
|
|
|
rtmp_conns 0
|
|
|
|
rtmp_conns_bytes_received 0
|
|
|
|
rtmp_conns_bytes_sent 0
|
2023-12-03 15:59:35 +00:00
|
|
|
rtmps_conns 0
|
|
|
|
rtmps_conns_bytes_received 0
|
|
|
|
rtmps_conns_bytes_sent 0
|
2023-11-08 10:20:16 +00:00
|
|
|
srt_conns 0
|
|
|
|
srt_conns_bytes_received 0
|
|
|
|
srt_conns_bytes_sent 0
|
2023-05-16 13:59:37 +00:00
|
|
|
webrtc_sessions 0
|
|
|
|
webrtc_sessions_bytes_received 0
|
|
|
|
webrtc_sessions_bytes_sent 0
|
2023-04-11 18:47:29 +00:00
|
|
|
`, string(bo))
|
2023-12-03 15:42:12 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("with data", func(t *testing.T) {
|
|
|
|
terminate := make(chan struct{})
|
|
|
|
var wg sync.WaitGroup
|
2023-12-03 15:59:35 +00:00
|
|
|
wg.Add(6)
|
2023-12-03 15:42:12 +00:00
|
|
|
|
|
|
|
go func() {
|
|
|
|
defer wg.Done()
|
|
|
|
source := gortsplib.Client{}
|
|
|
|
err := source.StartRecording("rtsp://localhost:8554/rtsp_path",
|
2024-02-20 18:35:35 +00:00
|
|
|
&description.Session{Medias: []*description.Media{test.UniqueMediaH264()}})
|
2023-12-03 15:42:12 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
defer source.Close()
|
|
|
|
<-terminate
|
|
|
|
}()
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
defer wg.Done()
|
|
|
|
source2 := gortsplib.Client{TLSConfig: &tls.Config{InsecureSkipVerify: true}}
|
|
|
|
err := source2.StartRecording("rtsps://localhost:8322/rtsps_path",
|
2024-02-20 18:35:35 +00:00
|
|
|
&description.Session{Medias: []*description.Media{test.UniqueMediaH264()}})
|
2023-12-03 15:42:12 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
defer source2.Close()
|
|
|
|
<-terminate
|
|
|
|
}()
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
defer wg.Done()
|
|
|
|
u, err := url.Parse("rtmp://localhost:1935/rtmp_path")
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
nconn, err := net.Dial("tcp", u.Host)
|
|
|
|
require.NoError(t, err)
|
|
|
|
defer nconn.Close()
|
|
|
|
|
|
|
|
conn, err := rtmp.NewClientConn(nconn, u, true)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2024-02-13 22:32:15 +00:00
|
|
|
_, err = rtmp.NewWriter(conn, test.FormatH264, nil)
|
2023-12-03 15:42:12 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
<-terminate
|
|
|
|
}()
|
|
|
|
|
2023-12-03 15:59:35 +00:00
|
|
|
go func() {
|
|
|
|
defer wg.Done()
|
|
|
|
u, err := url.Parse("rtmp://localhost:1936/rtmps_path")
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
nconn, err := tls.Dial("tcp", u.Host, &tls.Config{InsecureSkipVerify: true})
|
|
|
|
require.NoError(t, err)
|
|
|
|
defer nconn.Close() //nolint:errcheck
|
|
|
|
|
|
|
|
conn, err := rtmp.NewClientConn(nconn, u, true)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2024-02-13 22:32:15 +00:00
|
|
|
_, err = rtmp.NewWriter(conn, test.FormatH264, nil)
|
2023-12-03 15:59:35 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
<-terminate
|
|
|
|
}()
|
|
|
|
|
2023-12-03 15:42:12 +00:00
|
|
|
go func() {
|
|
|
|
defer wg.Done()
|
|
|
|
|
|
|
|
su, err := url.Parse("http://localhost:8889/webrtc_path/whip")
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2024-03-10 10:51:15 +00:00
|
|
|
tr := &http.Transport{}
|
|
|
|
defer tr.CloseIdleConnections()
|
2024-04-28 16:20:08 +00:00
|
|
|
hc2 := &http.Client{Transport: tr}
|
2024-03-10 10:51:15 +00:00
|
|
|
|
2024-09-09 10:59:23 +00:00
|
|
|
s := &whip.Client{
|
2024-04-28 16:20:08 +00:00
|
|
|
HTTPClient: hc2,
|
2023-12-03 15:42:12 +00:00
|
|
|
URL: su,
|
2024-04-18 21:55:48 +00:00
|
|
|
Log: test.NilLogger,
|
2023-12-03 15:42:12 +00:00
|
|
|
}
|
|
|
|
|
2024-09-09 10:59:23 +00:00
|
|
|
track := &webrtc.OutgoingTrack{
|
|
|
|
Caps: pwebrtc.RTPCodecCapability{
|
|
|
|
MimeType: pwebrtc.MimeTypeH264,
|
|
|
|
ClockRate: 90000,
|
|
|
|
SDPFmtpLine: "level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
err = s.Publish(context.Background(), []*webrtc.OutgoingTrack{track})
|
2023-12-03 15:42:12 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
defer checkClose(t, s.Close)
|
|
|
|
|
2024-09-09 10:59:23 +00:00
|
|
|
err = track.WriteRTP(&rtp.Packet{
|
2023-12-03 15:42:12 +00:00
|
|
|
Header: rtp.Header{
|
|
|
|
Version: 2,
|
|
|
|
Marker: true,
|
|
|
|
PayloadType: 96,
|
|
|
|
SequenceNumber: 123,
|
|
|
|
Timestamp: 45343,
|
|
|
|
SSRC: 563423,
|
|
|
|
},
|
|
|
|
Payload: []byte{1},
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
<-terminate
|
|
|
|
}()
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
defer wg.Done()
|
|
|
|
|
|
|
|
srtConf := srt.DefaultConfig()
|
|
|
|
address, err := srtConf.UnmarshalURL("srt://localhost:8890?streamid=publish:srt_path")
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
err = srtConf.Validate()
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
publisher, err := srt.Dial("srt", address, srtConf)
|
|
|
|
require.NoError(t, err)
|
|
|
|
defer publisher.Close()
|
|
|
|
|
|
|
|
track := &mpegts.Track{
|
|
|
|
Codec: &mpegts.CodecH264{},
|
|
|
|
}
|
|
|
|
|
|
|
|
bw := bufio.NewWriter(publisher)
|
|
|
|
w := mpegts.NewWriter(bw, []*mpegts.Track{track})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2024-06-11 20:43:27 +00:00
|
|
|
err = w.WriteH264(track, 0, 0, true, [][]byte{
|
2024-02-13 22:32:15 +00:00
|
|
|
test.FormatH264.SPS,
|
|
|
|
test.FormatH264.PPS,
|
|
|
|
{0x05, 1}, // IDR
|
2023-12-03 15:42:12 +00:00
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
err = bw.Flush()
|
|
|
|
require.NoError(t, err)
|
|
|
|
<-terminate
|
|
|
|
}()
|
|
|
|
|
|
|
|
time.Sleep(500 * time.Millisecond)
|
|
|
|
|
|
|
|
bo := httpPullFile(t, hc, "http://localhost:9998/metrics")
|
|
|
|
|
|
|
|
require.Regexp(t,
|
|
|
|
`^paths\{name=".*?",state="ready"\} 1`+"\n"+
|
|
|
|
`paths_bytes_received\{name=".*?",state="ready"\} [0-9]+`+"\n"+
|
2023-12-08 18:17:17 +00:00
|
|
|
`paths_bytes_sent\{name=".*?",state="ready"\} [0-9]+`+"\n"+
|
2023-12-03 15:42:12 +00:00
|
|
|
`paths\{name=".*?",state="ready"\} 1`+"\n"+
|
|
|
|
`paths_bytes_received\{name=".*?",state="ready"\} [0-9]+`+"\n"+
|
2023-12-08 18:17:17 +00:00
|
|
|
`paths_bytes_sent\{name=".*?",state="ready"\} [0-9]+`+"\n"+
|
2023-12-03 15:42:12 +00:00
|
|
|
`paths\{name=".*?",state="ready"\} 1`+"\n"+
|
|
|
|
`paths_bytes_received\{name=".*?",state="ready"\} [0-9]+`+"\n"+
|
2023-12-08 18:17:17 +00:00
|
|
|
`paths_bytes_sent\{name=".*?",state="ready"\} [0-9]+`+"\n"+
|
2023-12-03 15:42:12 +00:00
|
|
|
`paths\{name=".*?",state="ready"\} 1`+"\n"+
|
|
|
|
`paths_bytes_received\{name=".*?",state="ready"\} [0-9]+`+"\n"+
|
2023-12-08 18:17:17 +00:00
|
|
|
`paths_bytes_sent\{name=".*?",state="ready"\} [0-9]+`+"\n"+
|
2023-12-03 15:42:12 +00:00
|
|
|
`paths\{name=".*?",state="ready"\} 1`+"\n"+
|
|
|
|
`paths_bytes_received\{name=".*?",state="ready"\} [0-9]+`+"\n"+
|
2023-12-08 18:17:17 +00:00
|
|
|
`paths_bytes_sent\{name=".*?",state="ready"\} [0-9]+`+"\n"+
|
2023-12-03 15:59:35 +00:00
|
|
|
`paths\{name=".*?",state="ready"\} 1`+"\n"+
|
|
|
|
`paths_bytes_received\{name=".*?",state="ready"\} [0-9]+`+"\n"+
|
2023-12-08 18:17:17 +00:00
|
|
|
`paths_bytes_sent\{name=".*?",state="ready"\} [0-9]+`+"\n"+
|
2023-12-03 15:42:12 +00:00
|
|
|
`hls_muxers\{name=".*?"\} 1`+"\n"+
|
2023-12-08 18:17:17 +00:00
|
|
|
`hls_muxers_bytes_sent\{name=".*?"\} 0`+"\n"+
|
2023-12-03 15:42:12 +00:00
|
|
|
`hls_muxers\{name=".*?"\} 1`+"\n"+
|
2023-12-08 18:17:17 +00:00
|
|
|
`hls_muxers_bytes_sent\{name=".*?"\} 0`+"\n"+
|
2023-12-03 15:42:12 +00:00
|
|
|
`hls_muxers\{name=".*?"\} 1`+"\n"+
|
|
|
|
`hls_muxers_bytes_sent\{name=".*?"\} 0`+"\n"+
|
|
|
|
`hls_muxers\{name=".*?"\} 1`+"\n"+
|
|
|
|
`hls_muxers_bytes_sent\{name=".*?"\} 0`+"\n"+
|
|
|
|
`hls_muxers\{name=".*?"\} 1`+"\n"+
|
|
|
|
`hls_muxers_bytes_sent\{name=".*?"\} 0`+"\n"+
|
2023-12-03 15:59:35 +00:00
|
|
|
`hls_muxers\{name=".*?"\} 1`+"\n"+
|
|
|
|
`hls_muxers_bytes_sent\{name=".*?"\} 0`+"\n"+
|
2023-12-03 15:42:12 +00:00
|
|
|
`rtsp_conns\{id=".*?"\} 1`+"\n"+
|
|
|
|
`rtsp_conns_bytes_received\{id=".*?"\} [0-9]+`+"\n"+
|
|
|
|
`rtsp_conns_bytes_sent\{id=".*?"\} [0-9]+`+"\n"+
|
|
|
|
`rtsp_sessions\{id=".*?",state="publish"\} 1`+"\n"+
|
|
|
|
`rtsp_sessions_bytes_received\{id=".*?",state="publish"\} 0`+"\n"+
|
|
|
|
`rtsp_sessions_bytes_sent\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`rtsps_conns\{id=".*?"\} 1`+"\n"+
|
|
|
|
`rtsps_conns_bytes_received\{id=".*?"\} [0-9]+`+"\n"+
|
|
|
|
`rtsps_conns_bytes_sent\{id=".*?"\} [0-9]+`+"\n"+
|
|
|
|
`rtsps_sessions\{id=".*?",state="publish"\} 1`+"\n"+
|
|
|
|
`rtsps_sessions_bytes_received\{id=".*?",state="publish"\} 0`+"\n"+
|
|
|
|
`rtsps_sessions_bytes_sent\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`rtmp_conns\{id=".*?",state="publish"\} 1`+"\n"+
|
|
|
|
`rtmp_conns_bytes_received\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`rtmp_conns_bytes_sent\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
2023-12-03 15:59:35 +00:00
|
|
|
`rtmps_conns\{id=".*?",state="publish"\} 1`+"\n"+
|
|
|
|
`rtmps_conns_bytes_received\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`rtmps_conns_bytes_sent\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
2023-12-03 15:42:12 +00:00
|
|
|
`srt_conns\{id=".*?",state="publish"\} 1`+"\n"+
|
2024-02-16 13:22:30 +00:00
|
|
|
`srt_conns_packets_sent\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_packets_received\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_packets_sent_unique\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_packets_received_unique\{id=".*?",state="publish"\} 1`+"\n"+
|
|
|
|
`srt_conns_packets_send_loss\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_packets_received_loss\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_packets_retrans\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_packets_received_retrans\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_packets_sent_ack\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_packets_received_ack\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_packets_sent_nak\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_packets_received_nak\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_packets_sent_km\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_packets_received_km\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_us_snd_duration\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_packets_send_drop\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_packets_received_drop\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_packets_received_undecrypt\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
2023-12-03 15:42:12 +00:00
|
|
|
`srt_conns_bytes_sent\{id=".*?",state="publish"\} 0`+"\n"+
|
2024-02-16 13:22:30 +00:00
|
|
|
`srt_conns_bytes_received\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_bytes_sent_unique\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_bytes_received_unique\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_bytes_received_loss\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_bytes_retrans\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_bytes_received_retrans\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_bytes_send_drop\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_bytes_received_drop\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_bytes_received_undecrypt\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_us_packets_send_period\{id=".*?",state="publish"\} \d+\.\d+`+"\n"+
|
|
|
|
`srt_conns_packets_flow_window\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_packets_flight_size\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_ms_rtt\{id=".*?",state="publish"\} \d+\.\d+`+"\n"+
|
|
|
|
`srt_conns_mbps_send_rate\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_mbps_receive_rate\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_mbps_link_capacity\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_bytes_avail_send_buf\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_bytes_avail_receive_buf\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_mbps_max_bw\{id=".*?",state="publish"\} -1`+"\n"+
|
|
|
|
`srt_conns_bytes_mss\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_packets_send_buf\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_bytes_send_buf\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_ms_send_buf\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_ms_send_tsb_pd_delay\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_packets_receive_buf\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_bytes_receive_buf\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_ms_receive_buf\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_ms_receive_tsb_pd_delay\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_packets_reorder_tolerance\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_packets_received_avg_belated_time\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_packets_send_loss_rate\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`srt_conns_packets_received_loss_rate\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
2023-12-03 15:42:12 +00:00
|
|
|
`webrtc_sessions\{id=".*?",state="publish"\} 1`+"\n"+
|
|
|
|
`webrtc_sessions_bytes_received\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
`webrtc_sessions_bytes_sent\{id=".*?",state="publish"\} [0-9]+`+"\n"+
|
|
|
|
"$",
|
|
|
|
string(bo))
|
|
|
|
|
|
|
|
close(terminate)
|
|
|
|
wg.Wait()
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("servers deleted", func(t *testing.T) {
|
|
|
|
httpRequest(t, hc, http.MethodPatch, "http://localhost:9997/v3/config/global/patch", map[string]interface{}{
|
|
|
|
"rtsp": false,
|
|
|
|
"rtmp": false,
|
|
|
|
"srt": false,
|
|
|
|
"hls": false,
|
|
|
|
"webrtc": false,
|
|
|
|
}, nil)
|
|
|
|
|
|
|
|
time.Sleep(500 * time.Millisecond)
|
|
|
|
|
|
|
|
bo := httpPullFile(t, hc, "http://localhost:9998/metrics")
|
|
|
|
|
|
|
|
require.Equal(t, "paths 0\n", string(bo))
|
|
|
|
})
|
2021-08-12 09:48:47 +00:00
|
|
|
}
|