From 7c0220dc72c53ccf07a241ecb8e5c38a0eb1e7fa Mon Sep 17 00:00:00 2001 From: Tiago Peczenyj Date: Thu, 29 May 2025 08:27:17 +0200 Subject: [PATCH 1/2] try fix integration tests --- go.mod | 11 ++++--- go.sum | 20 ++++++------ internal/ingestion/rtp/integration_test.go | 28 +++++++++-------- internal/ingestion/srt/integration_test.go | 36 ++++++++++++---------- 4 files changed, 52 insertions(+), 43 deletions(-) diff --git a/go.mod b/go.mod index aecdb45..ffdddcd 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/alicebob/miniredis/v2 v2.34.0 github.com/charmbracelet/bubbletea v1.3.5 github.com/charmbracelet/lipgloss v1.1.0 + github.com/datarhei/gosrt v0.9.0 github.com/google/uuid v1.6.0 github.com/gorilla/mux v1.8.1 github.com/haivision/srtgo v0.0.0-20230627061225-a70d53fcd618 @@ -28,6 +29,7 @@ require ( github.com/BurntSushi/toml v1.5.0 // indirect github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect + github.com/benburkert/openpgp v0.0.0-20160410205803-c2471f86866c // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect @@ -66,20 +68,19 @@ require ( github.com/spf13/afero v1.12.0 // indirect github.com/spf13/cast v1.7.1 // indirect github.com/spf13/pflag v1.0.6 // indirect - github.com/stretchr/objx v0.5.2 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect github.com/yuin/gopher-lua v1.1.1 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/mock v0.5.0 // indirect go.uber.org/multierr v1.9.0 // indirect - golang.org/x/crypto v0.33.0 // indirect + golang.org/x/crypto v0.38.0 // indirect golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/mod v0.18.0 // indirect golang.org/x/net v0.33.0 // indirect - golang.org/x/sync v0.13.0 // indirect - golang.org/x/sys v0.32.0 // indirect - golang.org/x/text v0.22.0 // indirect + golang.org/x/sync v0.14.0 // indirect + golang.org/x/sys v0.33.0 // indirect + golang.org/x/text v0.25.0 // indirect golang.org/x/tools v0.22.0 // indirect google.golang.org/protobuf v1.36.5 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect diff --git a/go.sum b/go.sum index c2a2f82..7919c8a 100644 --- a/go.sum +++ b/go.sum @@ -6,6 +6,8 @@ github.com/alicebob/miniredis/v2 v2.34.0 h1:mBFWMaJSNL9RwdGRyEDoAAv8OQc5UlEhLDQg github.com/alicebob/miniredis/v2 v2.34.0/go.mod h1:kWShP4b58T1CW0Y5dViCd5ztzrDqRWqM3nksiyXk5s8= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= +github.com/benburkert/openpgp v0.0.0-20160410205803-c2471f86866c h1:8XZeJrs4+ZYhJeJ2aZxADI2tGADS15AzIF8MQ8XAhT4= +github.com/benburkert/openpgp v0.0.0-20160410205803-c2471f86866c/go.mod h1:x1vxHcL/9AVzuk5HOloOEPrtJY0MaalYr78afXZ+pWI= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= @@ -139,8 +141,6 @@ github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.20.1 h1:ZMi+z/lvLyPSCoNtFCpqjy0S4kPbirhpTMwl8BkW9X4= github.com/spf13/viper v1.20.1/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= -github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -158,25 +158,25 @@ go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU= go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM= go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= -golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= -golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= +golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8= +golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw= golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0= golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= -golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= +golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20200926100807-9d91bd62050c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= -golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= -golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= +golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= golang.org/x/time v0.11.0 h1:/bpjEDfN9tkoN/ryeYHnv5hcMlc8ncjMcM4XBk5NWV0= golang.org/x/time v0.11.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg= golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= diff --git a/internal/ingestion/rtp/integration_test.go b/internal/ingestion/rtp/integration_test.go index c18e017..641acce 100644 --- a/internal/ingestion/rtp/integration_test.go +++ b/internal/ingestion/rtp/integration_test.go @@ -20,6 +20,7 @@ import ( "github.com/zsiec/mirror/internal/ingestion/registry" rtpListener "github.com/zsiec/mirror/internal/ingestion/rtp" "github.com/zsiec/mirror/internal/ingestion/testdata" + "github.com/zsiec/mirror/internal/logger" "github.com/zsiec/mirror/tests" ) @@ -30,15 +31,15 @@ func TestRTPIntegration_StreamIngestion(t *testing.T) { // Setup ctx := context.Background() - logger := logrus.New() - logger.SetLevel(logrus.DebugLevel) + logrusLogger := logrus.New() + logrusLogger.SetLevel(logrus.DebugLevel) // Create test Redis registry redisClient := tests.SetupTestRedis(t) - reg := registry.NewRedisRegistry(redisClient, logger) + reg := registry.NewRedisRegistry(redisClient, logrusLogger) // Create buffer pool - bufferPool := buffer.NewBufferPool(1024*1024, 10, logger) // 1MB buffers + bufferPool := buffer.NewBufferPool(1024*1024, 10, logrusLogger) // 1MB buffers // Create RTP listener config cfg := &config.RTPConfig{ @@ -55,7 +56,9 @@ func TestRTPIntegration_StreamIngestion(t *testing.T) { Supported: []string{"h264", "hevc"}, Preferred: "hevc", } - listener := rtpListener.NewListener(cfg, codecsCfg, reg, bufferPool, logger) + + log := logger.NewLogrusAdapter(logrus.NewEntry(logrusLogger)) + listener := rtpListener.NewListener(cfg, codecsCfg, reg, log) err := listener.Start() require.NoError(t, err) defer listener.Stop() @@ -228,7 +231,8 @@ func TestRTPIntegration_StreamIngestion(t *testing.T) { Supported: []string{"h264", "hevc"}, Preferred: "hevc", } - testListener := rtpListener.NewListener(testCfg, codecsCfg, reg, bufferPool, logger) + + testListener := rtpListener.NewListener(testCfg, codecsCfg, reg, log) testListener.SetTestTimeouts(500*time.Millisecond, 1*time.Second) // Cleanup every 500ms, timeout after 1s err := testListener.Start() @@ -330,14 +334,11 @@ func TestRTPIntegration_Performance(t *testing.T) { } // Setup - logger := logrus.New() + logrusLogger := logrus.New() // Create test Redis registry redisClient := tests.SetupTestRedis(t) - reg := registry.NewRedisRegistry(redisClient, logger) - - // Create buffer pool - bufferPool := buffer.NewBufferPool(1024*1024, 10, logger) + reg := registry.NewRedisRegistry(redisClient, logrusLogger) // Create RTP listener cfg := &config.RTPConfig{ @@ -353,7 +354,10 @@ func TestRTPIntegration_Performance(t *testing.T) { Supported: []string{"h264", "hevc"}, Preferred: "hevc", } - listener := rtpListener.NewListener(cfg, codecsCfg, reg, bufferPool, logger) + + log := logger.NewLogrusAdapter(logrus.NewEntry(logrusLogger)) + + listener := rtpListener.NewListener(cfg, codecsCfg, reg, log) err := listener.Start() require.NoError(t, err) defer listener.Stop() diff --git a/internal/ingestion/srt/integration_test.go b/internal/ingestion/srt/integration_test.go index cb09134..9b4ed18 100644 --- a/internal/ingestion/srt/integration_test.go +++ b/internal/ingestion/srt/integration_test.go @@ -20,6 +20,7 @@ import ( "github.com/zsiec/mirror/internal/ingestion/registry" "github.com/zsiec/mirror/internal/ingestion/srt" "github.com/zsiec/mirror/internal/ingestion/testdata" + "github.com/zsiec/mirror/internal/logger" "github.com/zsiec/mirror/tests" ) @@ -30,15 +31,15 @@ func TestSRTIntegration_StreamIngestion(t *testing.T) { // Setup ctx := context.Background() - logger := logrus.New() - logger.SetLevel(logrus.DebugLevel) + logrusLogger := logrus.New() + logrusLogger.SetLevel(logrus.DebugLevel) // Create test Redis registry redisClient := tests.SetupTestRedis(t) - reg := registry.NewRedisRegistry(redisClient, logger) + reg := registry.NewRedisRegistry(redisClient, logrusLogger) // Create buffer pool - bufferPool := buffer.NewBufferPool(1024*1024, 10, logger) // 1MB buffers + bufferPool := buffer.NewBufferPool(1024*1024, 10, logrusLogger) // 1MB buffers // Create SRT listener config cfg := &config.SRTConfig{ @@ -58,9 +59,12 @@ func TestSRTIntegration_StreamIngestion(t *testing.T) { Supported: []string{"h264", "hevc"}, Preferred: "hevc", } - listener := srt.NewListener(cfg, codecsCfg, reg, bufferPool, logger) - // Set faster stats update for testing (500ms instead of 5s) - listener.SetTestStatsInterval(500 * time.Millisecond) + + adapter := srt.NewHaivisionAdapter() + + log := logger.NewLogrusAdapter(logrus.NewEntry(logrusLogger)) + listener := srt.NewListenerWithAdapter(cfg, codecsCfg, reg, adapter, log) + err := listener.Start() require.NoError(t, err) defer listener.Stop() @@ -278,14 +282,11 @@ func TestSRTIntegration_Metrics(t *testing.T) { // Setup ctx := context.Background() - logger := logrus.New() + logrusLogger := logrus.New() // Create test Redis registry redisClient := tests.SetupTestRedis(t) - reg := registry.NewRedisRegistry(redisClient, logger) - - // Create buffer pool - bufferPool := buffer.NewBufferPool(1024*1024, 10, logger) + reg := registry.NewRedisRegistry(redisClient, logrusLogger) // Create SRT listener cfg := &config.SRTConfig{ @@ -304,9 +305,11 @@ func TestSRTIntegration_Metrics(t *testing.T) { Supported: []string{"h264", "hevc"}, Preferred: "hevc", } - listener := srt.NewListener(cfg, codecsCfg, reg, bufferPool, logger) - // Set faster stats update for testing (500ms instead of 5s) - listener.SetTestStatsInterval(500 * time.Millisecond) + adapter := srt.NewHaivisionAdapter() + + log := logger.NewLogrusAdapter(logrus.NewEntry(logrusLogger)) + listener := srt.NewListenerWithAdapter(cfg, codecsCfg, reg, adapter, log) + err := listener.Start() require.NoError(t, err) defer listener.Stop() @@ -354,6 +357,7 @@ func TestSRTIntegration_Metrics(t *testing.T) { assert.Greater(t, stream.PacketsReceived, int64(0)) // Check listener metrics - assert.Equal(t, 1, listener.GetActiveSessions()) + assert.Equal(t, 1, listener.GetActiveConnections()) + }) } From ac6daf4b92b5b4a03bc5d8da3f02fd590671d146 Mon Sep 17 00:00:00 2001 From: Tiago Peczenyj Date: Thu, 29 May 2025 09:10:35 +0200 Subject: [PATCH 2/2] apply go fix ./... --- internal/ingestion/rtp/integration_test.go | 1 - internal/ingestion/srt/integration_test.go | 1 - 2 files changed, 2 deletions(-) diff --git a/internal/ingestion/rtp/integration_test.go b/internal/ingestion/rtp/integration_test.go index 641acce..cb24044 100644 --- a/internal/ingestion/rtp/integration_test.go +++ b/internal/ingestion/rtp/integration_test.go @@ -1,5 +1,4 @@ //go:build integration -// +build integration package rtp_test diff --git a/internal/ingestion/srt/integration_test.go b/internal/ingestion/srt/integration_test.go index 9b4ed18..39d3bcb 100644 --- a/internal/ingestion/srt/integration_test.go +++ b/internal/ingestion/srt/integration_test.go @@ -1,5 +1,4 @@ //go:build integration -// +build integration package srt_test