mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2026-03-14 14:35:44 +01:00
Move log test helpers to separate package.
This commit is contained in:
parent
3c6d3c0b7a
commit
ee6f026bbb
42 changed files with 236 additions and 151 deletions
|
|
@ -27,13 +27,13 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/test"
|
||||
)
|
||||
|
||||
func TestDeferredExecutor_MultiClose(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
e := NewDeferredExecutor(logger, 0)
|
||||
defer e.waitForStop()
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ func TestDeferredExecutor_MultiClose(t *testing.T) {
|
|||
func TestDeferredExecutor_QueueSize(t *testing.T) {
|
||||
t.Parallel()
|
||||
test.SynctestTest(t, func(t *testing.T) {
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
e := NewDeferredExecutor(logger, 0)
|
||||
defer e.waitForStop()
|
||||
defer e.Close()
|
||||
|
|
@ -67,7 +67,7 @@ func TestDeferredExecutor_QueueSize(t *testing.T) {
|
|||
|
||||
func TestDeferredExecutor_Order(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
e := NewDeferredExecutor(logger, 64)
|
||||
defer e.waitForStop()
|
||||
defer e.Close()
|
||||
|
|
@ -96,7 +96,7 @@ func TestDeferredExecutor_Order(t *testing.T) {
|
|||
|
||||
func TestDeferredExecutor_CloseFromFunc(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
e := NewDeferredExecutor(logger, 64)
|
||||
defer e.waitForStop()
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ func TestDeferredExecutor_CloseFromFunc(t *testing.T) {
|
|||
|
||||
func TestDeferredExecutor_DeferAfterClose(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
e := NewDeferredExecutor(logger, 64)
|
||||
defer e.waitForStop()
|
||||
|
||||
|
|
@ -124,7 +124,7 @@ func TestDeferredExecutor_DeferAfterClose(t *testing.T) {
|
|||
|
||||
func TestDeferredExecutor_WaitForStopTwice(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
e := NewDeferredExecutor(logger, 64)
|
||||
defer e.waitForStop()
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import (
|
|||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/api"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/nats"
|
||||
natstest "github.com/strukturag/nextcloud-spreed-signaling/nats/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/talk"
|
||||
|
|
@ -150,7 +151,7 @@ func testAsyncEvents(t *testing.T, events AsyncEvents) {
|
|||
func TestAsyncEvents_Loopback(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
events, err := NewAsyncEvents(ctx, nats.LoopbackUrl)
|
||||
require.NoError(t, err)
|
||||
|
|
@ -161,7 +162,7 @@ func TestAsyncEvents_NATS(t *testing.T) {
|
|||
t.Parallel()
|
||||
|
||||
server, _ := natstest.StartLocalServer(t)
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
events, err := NewAsyncEvents(ctx, server.ClientURL())
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import (
|
|||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/async/events"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/nats"
|
||||
natstest "github.com/strukturag/nextcloud-spreed-signaling/nats/test"
|
||||
)
|
||||
|
|
@ -61,7 +62,7 @@ func GetAsyncEventsForTest(t *testing.T) events.AsyncEvents {
|
|||
}
|
||||
|
||||
func getRealAsyncEventsForTest(t *testing.T) events.AsyncEvents {
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
server, _ := natstest.StartLocalServer(t)
|
||||
events, err := events.NewAsyncEvents(ctx, server.ClientURL())
|
||||
|
|
@ -76,7 +77,7 @@ type natsEvents interface {
|
|||
}
|
||||
|
||||
func getLoopbackAsyncEventsForTest(t *testing.T) events.AsyncEvents {
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
events, err := events.NewAsyncEvents(ctx, nats.LoopbackUrl)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/test"
|
||||
)
|
||||
|
||||
|
|
@ -58,7 +59,7 @@ func TestThrottler(t *testing.T) {
|
|||
assert := assert.New(t)
|
||||
th := newMemoryThrottlerForTest(t)
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
|
||||
throttle1, err := th.CheckBruteforce(ctx, "192.168.0.1", "action1")
|
||||
|
|
@ -93,7 +94,7 @@ func TestThrottlerIPv6(t *testing.T) {
|
|||
assert := assert.New(t)
|
||||
th := newMemoryThrottlerForTest(t)
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
|
||||
// Make sure full /64 subnets are throttled for IPv6.
|
||||
|
|
@ -131,7 +132,7 @@ func TestThrottler_Bruteforce(t *testing.T) {
|
|||
assert := assert.New(t)
|
||||
th := newMemoryThrottlerForTest(t)
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
|
||||
delay := 100 * time.Millisecond
|
||||
|
|
@ -160,7 +161,7 @@ func TestThrottler_Cleanup(t *testing.T) {
|
|||
th, ok := throttler.(*memoryThrottler)
|
||||
require.True(t, ok, "required memoryThrottler, got %T", throttler)
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
|
||||
throttle1, err := th.CheckBruteforce(ctx, "192.168.0.1", "action1")
|
||||
|
|
@ -215,7 +216,7 @@ func TestThrottler_ExpirePartial(t *testing.T) {
|
|||
assert := assert.New(t)
|
||||
th := newMemoryThrottlerForTest(t)
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
|
||||
throttle1, err := th.CheckBruteforce(ctx, "192.168.0.1", "action1")
|
||||
|
|
@ -248,7 +249,7 @@ func TestThrottler_ExpireAll(t *testing.T) {
|
|||
assert := assert.New(t)
|
||||
th := newMemoryThrottlerForTest(t)
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
|
||||
throttle1, err := th.CheckBruteforce(ctx, "192.168.0.1", "action1")
|
||||
|
|
@ -281,7 +282,7 @@ func TestThrottler_Negative(t *testing.T) {
|
|||
assert := assert.New(t)
|
||||
th := newMemoryThrottlerForTest(t)
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
|
||||
delay := 100 * time.Millisecond
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ import (
|
|||
"github.com/strukturag/nextcloud-spreed-signaling/api"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/geoip"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
)
|
||||
|
||||
func TestCounterWriter(t *testing.T) {
|
||||
|
|
@ -87,7 +88,7 @@ func newTestClient(h *testHandler, r *http.Request, conn *websocket.Conn, id uin
|
|||
addr = host
|
||||
}
|
||||
|
||||
logger := log.NewLoggerForTest(h.t)
|
||||
logger := logtest.NewLoggerForTest(h.t)
|
||||
ctx := log.NewLoggerContext(r.Context(), logger)
|
||||
result.SetConn(ctx, conn, addr, r.Header.Get("User-Agent"), false, result)
|
||||
return result
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ import (
|
|||
"github.com/strukturag/nextcloud-spreed-signaling/api"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/internal"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/proxy"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/sfu"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/talk"
|
||||
|
|
@ -142,7 +143,7 @@ func newProxyServerForTest(t *testing.T) (*ProxyServer, *rsa.PrivateKey, *httpte
|
|||
config := goconf.NewConfigFile()
|
||||
config.AddOption("tokens", TokenIdForTest, pubkey.Name())
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
proxy, err = NewProxyServer(ctx, r, "0.0", config)
|
||||
require.NoError(err)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import (
|
|||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zaptest"
|
||||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/test"
|
||||
)
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ func newTokensEtcdForTesting(t *testing.T) (*tokensEtcd, *embed.Etcd) {
|
|||
cfg.AddOption("etcd", "endpoints", etcd.Config().ListenClientUrls[0].String())
|
||||
cfg.AddOption("tokens", "keyformat", "/%s, /testing/%s/key")
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
tokens, err := NewProxyTokensEtcd(logger, cfg)
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
)
|
||||
|
||||
type MockLookup struct {
|
||||
|
|
@ -81,7 +81,7 @@ func NewMonitorForTest(t *testing.T, interval time.Duration, lookup *MockLookup)
|
|||
t.Helper()
|
||||
require := require.New(t)
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
var lookupFunc MonitorLookupFunc
|
||||
if lookup != nil {
|
||||
lookupFunc = lookup.lookup
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ import (
|
|||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/internal"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/test"
|
||||
)
|
||||
|
||||
|
|
@ -140,7 +141,7 @@ func NewClientForTest(t *testing.T) (*embed.Etcd, Client) {
|
|||
config.AddOption("etcd", "endpoints", etcd.Config().ListenClientUrls[0].String())
|
||||
config.AddOption("etcd", "loglevel", "error")
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
client, err := NewClient(logger, config, "")
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() {
|
||||
|
|
@ -159,7 +160,7 @@ func NewEtcdClientWithTLSForTest(t *testing.T) (*embed.Etcd, Client) {
|
|||
config.AddOption("etcd", "clientcert", certfile)
|
||||
config.AddOption("etcd", "cacert", certfile)
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
client, err := NewClient(logger, config, "")
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() {
|
||||
|
|
@ -184,7 +185,7 @@ func DeleteValue(etcd *embed.Etcd, key string) {
|
|||
|
||||
func Test_EtcdClient_Get(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
assert := assert.New(t)
|
||||
require := require.New(t)
|
||||
|
|
@ -229,7 +230,7 @@ func Test_EtcdClient_Get(t *testing.T) {
|
|||
|
||||
func Test_EtcdClientTLS_Get(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
assert := assert.New(t)
|
||||
require := require.New(t)
|
||||
|
|
@ -274,7 +275,7 @@ func Test_EtcdClientTLS_Get(t *testing.T) {
|
|||
|
||||
func Test_EtcdClient_GetPrefix(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
assert := assert.New(t)
|
||||
etcd, client := NewClientForTest(t)
|
||||
|
|
@ -386,7 +387,7 @@ func (l *EtcdClientTestListener) EtcdKeyDeleted(client Client, key string, prevV
|
|||
|
||||
func Test_EtcdClient_Watch(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
assert := assert.New(t)
|
||||
etcd, client := NewClientForTest(t)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ import (
|
|||
"go.uber.org/zap/zaptest"
|
||||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/etcd"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/test"
|
||||
)
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ func NewServerForTest(t *testing.T) *Server {
|
|||
func NewEtcdClientForTest(t *testing.T, server *Server) etcd.Client {
|
||||
t.Helper()
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
|
||||
config := goconf.NewConfigFile()
|
||||
config.AddOption("etcd", "endpoints", server.URL().String())
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
)
|
||||
|
||||
func testLookupReader(t *testing.T, reader *Lookup) {
|
||||
|
|
@ -79,7 +79,7 @@ func GetIpUrlForTest(t *testing.T) string {
|
|||
|
||||
func TestLookup(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
require := require.New(t)
|
||||
reader, err := NewLookupFromUrl(logger, GetIpUrlForTest(t))
|
||||
require.NoError(err)
|
||||
|
|
@ -92,7 +92,7 @@ func TestLookup(t *testing.T) {
|
|||
|
||||
func TestLookupCaching(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
require := require.New(t)
|
||||
reader, err := NewLookupFromUrl(logger, GetIpUrlForTest(t))
|
||||
require.NoError(err)
|
||||
|
|
@ -133,7 +133,7 @@ func TestLookupContinent(t *testing.T) {
|
|||
|
||||
func TestLookupCloseEmpty(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
reader, err := NewLookupFromUrl(logger, "ignore-url")
|
||||
require.NoError(t, err)
|
||||
reader.Close()
|
||||
|
|
@ -141,7 +141,7 @@ func TestLookupCloseEmpty(t *testing.T) {
|
|||
|
||||
func TestLookupFromFile(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
require := require.New(t)
|
||||
geoIpUrl := GetIpUrlForTest(t)
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
)
|
||||
|
||||
func mustSucceed1[T any, A1 any](t *testing.T, f func(a1 A1) (T, bool), a1 A1) T {
|
||||
|
|
@ -48,7 +49,7 @@ func TestOverridesEmpty(t *testing.T) {
|
|||
assert := assert.New(t)
|
||||
|
||||
config := goconf.NewConfigFile()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
|
||||
overrides, err := LoadOverrides(ctx, config, true)
|
||||
|
|
@ -69,7 +70,7 @@ func TestOverrides(t *testing.T) {
|
|||
config.AddOption("geoip-overrides", "10.4.5.6", "loopback")
|
||||
config.AddOption("geoip-overrides", "192.168.1.0", "")
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
|
||||
overrides, err := LoadOverrides(ctx, config, true)
|
||||
|
|
@ -101,7 +102,7 @@ func TestOverridesInvalidIgnoreErrors(t *testing.T) {
|
|||
config.AddOption("geoip-overrides", "300.1.2.3/8", "DE")
|
||||
config.AddOption("geoip-overrides", "10.2.0.0/16", "FR")
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
|
||||
overrides, err := LoadOverrides(ctx, config, true)
|
||||
|
|
@ -127,7 +128,7 @@ func TestOverridesInvalidIPReturnErrors(t *testing.T) {
|
|||
config.AddOption("geoip-overrides", "invalid-ip", "DE")
|
||||
config.AddOption("geoip-overrides", "10.2.0.0/16", "FR")
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
|
||||
overrides, err := LoadOverrides(ctx, config, false)
|
||||
|
|
@ -143,7 +144,7 @@ func TestOverridesInvalidCIDRReturnErrors(t *testing.T) {
|
|||
config.AddOption("geoip-overrides", "300.1.2.3/8", "DE")
|
||||
config.AddOption("geoip-overrides", "10.2.0.0/16", "FR")
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
|
||||
overrides, err := LoadOverrides(ctx, config, false)
|
||||
|
|
|
|||
|
|
@ -36,12 +36,13 @@ import (
|
|||
"github.com/strukturag/nextcloud-spreed-signaling/etcd"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/etcd/etcdtest"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/test"
|
||||
)
|
||||
|
||||
func NewClientsForTestWithConfig(t *testing.T, config *goconf.ConfigFile, etcdClient etcd.Client, lookup *dns.MockLookup) (*Clients, *dns.Monitor) {
|
||||
dnsMonitor := dns.NewMonitorForTest(t, time.Hour, lookup) // will be updated manually
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
client, err := NewClients(ctx, config, etcdClient, dnsMonitor, "0.0.0")
|
||||
require.NoError(t, err)
|
||||
|
|
@ -67,7 +68,7 @@ func NewClientsWithEtcdForTest(t *testing.T, embedEtcd *etcdtest.Server, lookup
|
|||
config.AddOption("grpc", "targettype", "etcd")
|
||||
config.AddOption("grpc", "targetprefix", "/grpctargets")
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
etcdClient, err := etcd.NewClient(logger, config, "")
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() {
|
||||
|
|
@ -89,7 +90,7 @@ func waitForEvent(ctx context.Context, t *testing.T, ch <-chan struct{}) {
|
|||
}
|
||||
|
||||
func Test_GrpcClients_DnsDiscovery(t *testing.T) { // nolint:paralleltest
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
test.EnsureNoGoroutinesLeak(t, func(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
|
@ -174,7 +175,7 @@ func Test_GrpcClients_DnsDiscoveryInitialFailed(t *testing.T) {
|
|||
}
|
||||
|
||||
func Test_GrpcClients_EtcdInitial(t *testing.T) { // nolint:paralleltest
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
test.EnsureNoGoroutinesLeak(t, func(t *testing.T) {
|
||||
_, addr1 := NewServerForTest(t)
|
||||
|
|
@ -197,7 +198,7 @@ func Test_GrpcClients_EtcdInitial(t *testing.T) { // nolint:paralleltest
|
|||
|
||||
func Test_GrpcClients_EtcdUpdate(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
assert := assert.New(t)
|
||||
embedEtcd := etcdtest.NewServerForTest(t)
|
||||
|
|
@ -244,7 +245,7 @@ func Test_GrpcClients_EtcdUpdate(t *testing.T) {
|
|||
|
||||
func Test_GrpcClients_EtcdIgnoreSelf(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
assert := assert.New(t)
|
||||
embedEtcd := etcdtest.NewServerForTest(t)
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ import (
|
|||
"github.com/strukturag/nextcloud-spreed-signaling/geoip"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/internal"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/sfu"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/talk"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/test"
|
||||
|
|
@ -82,7 +83,7 @@ func (s *Server) WaitForCertPoolReload(ctx context.Context, counter uint64) erro
|
|||
}
|
||||
|
||||
func NewServerForTestWithConfig(t *testing.T, config *goconf.ConfigFile) (server *Server, addr string) {
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
for port := 50000; port < 50100; port++ {
|
||||
addr = net.JoinHostPort("127.0.0.1", strconv.Itoa(port))
|
||||
|
|
@ -185,7 +186,7 @@ func TestServer_ReloadCerts(t *testing.T) {
|
|||
|
||||
func TestServer_ReloadCA(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
require := require.New(t)
|
||||
serverKey, err := rsa.GenerateKey(rand.Reader, 1024)
|
||||
require.NoError(err)
|
||||
|
|
@ -335,7 +336,7 @@ type testServerHub struct {
|
|||
|
||||
func newTestServerHub(t *testing.T) *testServerHub {
|
||||
t.Helper()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
|
||||
cfg := goconf.NewConfigFile()
|
||||
cfg.AddOption(testBackendId, "secret", "not-so-secret")
|
||||
|
|
|
|||
|
|
@ -34,11 +34,12 @@ import (
|
|||
"github.com/strukturag/nextcloud-spreed-signaling/etcd/etcdtest"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/grpc"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
)
|
||||
|
||||
func NewClientsForTestWithConfig(t *testing.T, config *goconf.ConfigFile, etcdClient etcd.Client, lookup *dns.MockLookup) (*grpc.Clients, *dns.Monitor) {
|
||||
dnsMonitor := dns.NewMonitorForTest(t, time.Hour, lookup) // will be updated manually
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
client, err := grpc.NewClients(ctx, config, etcdClient, dnsMonitor, "0.0.0")
|
||||
require.NoError(t, err)
|
||||
|
|
@ -64,7 +65,7 @@ func NewClientsWithEtcdForTest(t *testing.T, embedEtcd *etcdtest.Server, lookup
|
|||
config.AddOption("grpc", "targettype", "etcd")
|
||||
config.AddOption("grpc", "targetprefix", "/grpctargets")
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
etcdClient, err := etcd.NewClient(logger, config, "")
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() {
|
||||
|
|
|
|||
|
|
@ -32,11 +32,12 @@ import (
|
|||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/grpc"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/test"
|
||||
)
|
||||
|
||||
func NewServerForTestWithConfig(t *testing.T, config *goconf.ConfigFile) (server *grpc.Server, addr string) {
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
for port := 50000; port < 50100; port++ {
|
||||
addr = net.JoinHostPort("127.0.0.1", strconv.Itoa(port))
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@
|
|||
package log
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"log"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
|
@ -41,11 +44,29 @@ func TestGlobalLogger(t *testing.T) {
|
|||
assert.Fail("should have paniced", "got logger %+v", logger)
|
||||
}
|
||||
|
||||
type testLogWriter struct {
|
||||
mu sync.Mutex
|
||||
t testing.TB
|
||||
}
|
||||
|
||||
func (w *testLogWriter) Write(b []byte) (int, error) {
|
||||
w.t.Helper()
|
||||
if !bytes.HasSuffix(b, []byte("\n")) {
|
||||
b = append(b, '\n')
|
||||
}
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
w.t.Logf("%s", string(b))
|
||||
return len(b), nil
|
||||
}
|
||||
|
||||
func TestLoggerContext(t *testing.T) {
|
||||
t.Parallel()
|
||||
assert := assert.New(t)
|
||||
|
||||
testLogger := NewLoggerForTest(t)
|
||||
testLogger := log.New(&testLogWriter{
|
||||
t: t,
|
||||
}, t.Name()+": ", log.LstdFlags|log.Lmicroseconds|log.Lshortfile)
|
||||
testLogger.Printf("Hello %s!", "world")
|
||||
|
||||
ctx := NewLoggerContext(t.Context(), testLogger)
|
||||
|
|
|
|||
|
|
@ -19,15 +19,16 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package log
|
||||
package test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"log"
|
||||
stdlog "log"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/internal"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
)
|
||||
|
||||
type testLogWriter struct {
|
||||
|
|
@ -46,17 +47,17 @@ func (w *testLogWriter) Write(b []byte) (int, error) {
|
|||
}
|
||||
|
||||
var (
|
||||
testLoggers internal.TestStorage[Logger]
|
||||
testLoggers internal.TestStorage[log.Logger]
|
||||
)
|
||||
|
||||
func NewLoggerForTest(t testing.TB) Logger {
|
||||
func NewLoggerForTest(t testing.TB) log.Logger {
|
||||
t.Helper()
|
||||
|
||||
logger, found := testLoggers.Get(t)
|
||||
if !found {
|
||||
logger = log.New(&testLogWriter{
|
||||
logger = stdlog.New(&testLogWriter{
|
||||
t: t,
|
||||
}, t.Name()+": ", log.LstdFlags|log.Lmicroseconds|log.Lshortfile)
|
||||
}, t.Name()+": ", stdlog.LstdFlags|stdlog.Lmicroseconds|stdlog.Lshortfile)
|
||||
|
||||
testLoggers.Set(t, logger)
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package log
|
||||
package test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package log
|
||||
package test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
39
log/test/log_test.go
Normal file
39
log/test/log_test.go
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
* Standalone signaling server for the Nextcloud Spreed app.
|
||||
* Copyright (C) 2026 struktur AG
|
||||
*
|
||||
* @author Joachim Bauch <bauch@struktur.de>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestLoggerForTest(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
log1 := NewLoggerForTest(t)
|
||||
log2 := NewLoggerForTest(t)
|
||||
assert.Equal(t, log1, log2)
|
||||
|
||||
log1.Printf("Test output")
|
||||
log1.Println("Test output")
|
||||
}
|
||||
|
|
@ -29,11 +29,11 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
)
|
||||
|
||||
func CreateLoopbackClientForTest(t *testing.T) Client {
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
result, err := NewLoopbackClient(logger)
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() {
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import (
|
|||
"github.com/nats-io/nats.go"
|
||||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/test"
|
||||
)
|
||||
|
||||
|
|
@ -59,7 +60,7 @@ func StartLocalServerPort(t *testing.T, port int) (*server.Server, int) {
|
|||
func CreateLocalClientForTest(t *testing.T, options ...nats.Option) (*server.Server, int, Client) {
|
||||
t.Helper()
|
||||
server, port := StartLocalServer(t)
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
result, err := NewClient(ctx, server.ClientURL(), options...)
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/nats"
|
||||
)
|
||||
|
||||
|
|
@ -42,7 +43,7 @@ func TestLocalServer(t *testing.T) {
|
|||
server, port := StartLocalServer(t)
|
||||
assert.NotEqual(0, port)
|
||||
|
||||
ctx := log.NewLoggerContext(t.Context(), log.NewLoggerForTest(t))
|
||||
ctx := log.NewLoggerContext(t.Context(), logtest.NewLoggerForTest(t))
|
||||
|
||||
client, err := nats.NewClient(ctx, server.ClientURL())
|
||||
require.NoError(err)
|
||||
|
|
@ -56,7 +57,7 @@ func TestWaitForSubscriptionsEmpty(t *testing.T) {
|
|||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
|
||||
ctx := log.NewLoggerContext(t.Context(), log.NewLoggerForTest(t))
|
||||
ctx := log.NewLoggerContext(t.Context(), logtest.NewLoggerForTest(t))
|
||||
|
||||
client, err := nats.NewClient(ctx, nats.LoopbackUrl)
|
||||
require.NoError(err)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/test"
|
||||
)
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ func TestFileWatcher_NotExist(t *testing.T) {
|
|||
t.Parallel()
|
||||
assert := assert.New(t)
|
||||
tmpdir := t.TempDir()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
if w, err := NewFileWatcher(logger, path.Join(tmpdir, "test.txt"), func(filename string) {}, DefaultDeduplicateWatchEvents); !assert.ErrorIs(err, os.ErrNotExist) {
|
||||
if w != nil {
|
||||
assert.NoError(w.Close())
|
||||
|
|
@ -58,7 +58,7 @@ func TestFileWatcher_File(t *testing.T) { // nolint:paralleltest
|
|||
filename := path.Join(tmpdir, "test.txt")
|
||||
require.NoError(os.WriteFile(filename, []byte("Hello world!"), 0644))
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
modified := make(chan struct{})
|
||||
w, err := NewFileWatcher(logger, filename, func(filename string) {
|
||||
modified <- struct{}{}
|
||||
|
|
@ -101,7 +101,7 @@ func TestFileWatcher_CurrentDir(t *testing.T) { // nolint:paralleltest
|
|||
filename := path.Join(tmpdir, "test.txt")
|
||||
require.NoError(os.WriteFile(filename, []byte("Hello world!"), 0644))
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
modified := make(chan struct{})
|
||||
w, err := NewFileWatcher(logger, "./"+path.Base(filename), func(filename string) {
|
||||
modified <- struct{}{}
|
||||
|
|
@ -143,7 +143,7 @@ func TestFileWatcher_Rename(t *testing.T) {
|
|||
filename := path.Join(tmpdir, "test.txt")
|
||||
require.NoError(os.WriteFile(filename, []byte("Hello world!"), 0644))
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
modified := make(chan struct{})
|
||||
w, err := NewFileWatcher(logger, filename, func(filename string) {
|
||||
modified <- struct{}{}
|
||||
|
|
@ -187,7 +187,7 @@ func TestFileWatcher_Symlink(t *testing.T) {
|
|||
filename := path.Join(tmpdir, "symlink.txt")
|
||||
require.NoError(os.Symlink(sourceFilename, filename))
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
modified := make(chan struct{})
|
||||
w, err := NewFileWatcher(logger, filename, func(filename string) {
|
||||
modified <- struct{}{}
|
||||
|
|
@ -222,7 +222,7 @@ func TestFileWatcher_ChangeSymlinkTarget(t *testing.T) {
|
|||
filename := path.Join(tmpdir, "symlink.txt")
|
||||
require.NoError(os.Symlink(sourceFilename1, filename))
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
modified := make(chan struct{})
|
||||
w, err := NewFileWatcher(logger, filename, func(filename string) {
|
||||
modified <- struct{}{}
|
||||
|
|
@ -259,7 +259,7 @@ func TestFileWatcher_OtherSymlink(t *testing.T) {
|
|||
filename := path.Join(tmpdir, "symlink.txt")
|
||||
require.NoError(os.Symlink(sourceFilename1, filename))
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
modified := make(chan struct{})
|
||||
w, err := NewFileWatcher(logger, filename, func(filename string) {
|
||||
modified <- struct{}{}
|
||||
|
|
@ -290,7 +290,7 @@ func TestFileWatcher_RenameSymlinkTarget(t *testing.T) {
|
|||
filename := path.Join(tmpdir, "test.txt")
|
||||
require.NoError(os.Symlink(sourceFilename1, filename))
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
modified := make(chan struct{})
|
||||
w, err := NewFileWatcher(logger, filename, func(filename string) {
|
||||
modified <- struct{}{}
|
||||
|
|
@ -344,7 +344,7 @@ func TestFileWatcher_UpdateSymlinkFolder(t *testing.T) {
|
|||
filename := path.Join(tmpdir, "test.txt")
|
||||
require.NoError(os.Symlink("data/test.txt", filename))
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
modified := make(chan struct{})
|
||||
w, err := NewFileWatcher(logger, filename, func(filename string) {
|
||||
modified <- struct{}{}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ import (
|
|||
grpctest "github.com/strukturag/nextcloud-spreed-signaling/grpc/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/internal"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/nats"
|
||||
natstest "github.com/strukturag/nextcloud-spreed-signaling/nats/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/talk"
|
||||
|
|
@ -107,7 +108,7 @@ func CreateBackendServerForTestFromConfig(t *testing.T, config *goconf.ConfigFil
|
|||
config.AddOption("clients", "internalsecret", string(testInternalSecret))
|
||||
config.AddOption("geoip", "url", "none")
|
||||
events := eventstest.GetAsyncEventsForTest(t)
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
hub, err := NewHub(ctx, config, events, nil, nil, nil, r, "no-version")
|
||||
require.NoError(err)
|
||||
|
|
@ -169,7 +170,7 @@ func CreateBackendServerWithClusteringForTestFromConfig(t *testing.T, config1 *g
|
|||
config1.AddOption("clients", "internalsecret", string(testInternalSecret))
|
||||
config1.AddOption("geoip", "url", "none")
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
|
||||
events1, err := events.NewAsyncEvents(ctx, nats.ClientURL())
|
||||
|
|
@ -404,7 +405,7 @@ func TestBackendServer_RoomInvite(t *testing.T) {
|
|||
for _, backend := range eventstest.EventBackendsForTest {
|
||||
t.Run(backend, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
RunTestBackendServer_RoomInvite(ctx, t)
|
||||
})
|
||||
|
|
@ -474,7 +475,7 @@ func TestBackendServer_RoomDisinvite(t *testing.T) {
|
|||
for _, backend := range eventstest.EventBackendsForTest {
|
||||
t.Run(backend, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
RunTestBackendServer_RoomDisinvite(ctx, t)
|
||||
})
|
||||
|
|
@ -555,7 +556,7 @@ func RunTestBackendServer_RoomDisinvite(ctx context.Context, t *testing.T) {
|
|||
|
||||
func TestBackendServer_RoomDisinviteDifferentRooms(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
|
|
@ -638,7 +639,7 @@ func TestBackendServer_RoomUpdate(t *testing.T) {
|
|||
for _, backend := range eventstest.EventBackendsForTest {
|
||||
t.Run(backend, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
RunTestBackendServer_RoomUpdate(ctx, t)
|
||||
})
|
||||
|
|
@ -710,7 +711,7 @@ func TestBackendServer_RoomDelete(t *testing.T) {
|
|||
for _, backend := range eventstest.EventBackendsForTest {
|
||||
t.Run(backend, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
RunTestBackendServer_RoomDelete(ctx, t)
|
||||
})
|
||||
|
|
@ -779,7 +780,7 @@ func TestBackendServer_ParticipantsUpdatePermissions(t *testing.T) {
|
|||
for _, subtest := range clusteredTests {
|
||||
t.Run(subtest, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
|
|
@ -877,7 +878,7 @@ func TestBackendServer_ParticipantsUpdatePermissions(t *testing.T) {
|
|||
|
||||
func TestBackendServer_ParticipantsUpdateEmptyPermissions(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
|
|
@ -942,7 +943,7 @@ func TestBackendServer_ParticipantsUpdateEmptyPermissions(t *testing.T) {
|
|||
|
||||
func TestBackendServer_ParticipantsUpdateTimeout(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
|
|
@ -1105,7 +1106,7 @@ func TestBackendServer_InCallAll(t *testing.T) {
|
|||
for _, subtest := range clusteredTests {
|
||||
t.Run(subtest, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
|
|
@ -1277,7 +1278,7 @@ func TestBackendServer_InCallAll(t *testing.T) {
|
|||
|
||||
func TestBackendServer_RoomMessage(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
|
|
@ -1447,7 +1448,7 @@ func Test_IsNumeric(t *testing.T) {
|
|||
|
||||
func TestBackendServer_DialoutNoSipBridge(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
|
|
@ -1491,7 +1492,7 @@ func TestBackendServer_DialoutNoSipBridge(t *testing.T) {
|
|||
|
||||
func TestBackendServer_DialoutAccepted(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
|
|
@ -1578,7 +1579,7 @@ func TestBackendServer_DialoutAccepted(t *testing.T) {
|
|||
|
||||
func TestBackendServer_DialoutAcceptedCompat(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
|
|
@ -1665,7 +1666,7 @@ func TestBackendServer_DialoutAcceptedCompat(t *testing.T) {
|
|||
|
||||
func TestBackendServer_DialoutRejected(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
|
|
@ -1750,7 +1751,7 @@ func TestBackendServer_DialoutRejected(t *testing.T) {
|
|||
|
||||
func TestBackendServer_DialoutFirstFailed(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import (
|
|||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/api"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/mock"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/sfu"
|
||||
sfujanus "github.com/strukturag/nextcloud-spreed-signaling/sfu/janus"
|
||||
|
|
@ -56,7 +57,7 @@ func newMcuJanusForTesting(t *testing.T) (JanusSFU, *janustest.JanusGateway) {
|
|||
if strings.Contains(t.Name(), "Filter") {
|
||||
config.AddOption("mcu", "blockedcandidates", "192.0.0.0/24, 192.168.0.0/16")
|
||||
}
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
mcu, err := sfujanus.NewJanusSFUWithGateway(ctx, gateway, config)
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ import (
|
|||
grpctest "github.com/strukturag/nextcloud-spreed-signaling/grpc/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/internal"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/mock"
|
||||
natstest "github.com/strukturag/nextcloud-spreed-signaling/nats/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/session"
|
||||
|
|
@ -164,7 +165,7 @@ func getTestConfigWithMultipleUrls(server *httptest.Server) (*goconf.ConfigFile,
|
|||
}
|
||||
|
||||
func CreateHubForTestWithConfig(t *testing.T, getConfigFunc func(*httptest.Server) (*goconf.ConfigFile, error)) (*Hub, events.AsyncEvents, *mux.Router, *httptest.Server) {
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
r := mux.NewRouter()
|
||||
|
|
@ -215,7 +216,7 @@ func CreateHubWithMultipleUrlsForTest(t *testing.T) (*Hub, events.AsyncEvents, *
|
|||
}
|
||||
|
||||
func CreateClusteredHubsForTestWithConfig(t *testing.T, getConfigFunc func(*httptest.Server) (*goconf.ConfigFile, error)) (*Hub, *Hub, *mux.Router, *mux.Router, *httptest.Server, *httptest.Server) {
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
|
|
@ -5037,7 +5038,7 @@ func TestGeoipOverrides(t *testing.T) {
|
|||
|
||||
func TestDialoutStatus(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/talk"
|
||||
)
|
||||
|
||||
|
|
@ -62,7 +63,7 @@ func NewRoomPingForTest(ctx context.Context, t *testing.T) (*url.URL, *RoomPing)
|
|||
|
||||
func TestSingleRoomPing(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
assert := assert.New(t)
|
||||
u, ping := NewRoomPingForTest(ctx, t)
|
||||
|
|
@ -106,7 +107,7 @@ func TestSingleRoomPing(t *testing.T) {
|
|||
|
||||
func TestMultiRoomPing(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
assert := assert.New(t)
|
||||
u, ping := NewRoomPingForTest(ctx, t)
|
||||
|
|
@ -146,7 +147,7 @@ func TestMultiRoomPing(t *testing.T) {
|
|||
|
||||
func TestMultiRoomPing_Separate(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
assert := assert.New(t)
|
||||
u, ping := NewRoomPingForTest(ctx, t)
|
||||
|
|
@ -182,7 +183,7 @@ func TestMultiRoomPing_Separate(t *testing.T) {
|
|||
|
||||
func TestMultiRoomPing_DeleteRoom(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
assert := assert.New(t)
|
||||
u, ping := NewRoomPingForTest(ctx, t)
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/talk"
|
||||
)
|
||||
|
||||
|
|
@ -80,7 +81,7 @@ func TestRoom_InCall(t *testing.T) {
|
|||
|
||||
func TestRoom_Update(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
|
|
@ -175,7 +176,7 @@ loop:
|
|||
|
||||
func TestRoom_Delete(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
|
|
@ -273,7 +274,7 @@ loop:
|
|||
|
||||
func TestRoom_RoomJoinFeatures(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
|
|
@ -311,7 +312,7 @@ func TestRoom_RoomJoinFeatures(t *testing.T) {
|
|||
|
||||
func TestRoom_RoomSessionData(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
|
|
@ -355,7 +356,7 @@ func TestRoom_RoomSessionData(t *testing.T) {
|
|||
|
||||
func TestRoom_InCallAll(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import (
|
|||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/api"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
metricstest "github.com/strukturag/nextcloud-spreed-signaling/metrics/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/sfu"
|
||||
sfutest "github.com/strukturag/nextcloud-spreed-signaling/sfu/test"
|
||||
|
|
@ -70,7 +71,7 @@ func (h *TestJanusEventsServerHandler) ServeHTTP(w http.ResponseWriter, r *http.
|
|||
if host, _, err := net.SplitHostPort(addr); err == nil {
|
||||
addr = host
|
||||
}
|
||||
logger := log.NewLoggerForTest(h.t)
|
||||
logger := logtest.NewLoggerForTest(h.t)
|
||||
ctx := log.NewLoggerContext(r.Context(), logger)
|
||||
RunEventsHandler(ctx, h.mcu, conn, addr, r.Header.Get("User-Agent"))
|
||||
return
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import (
|
|||
"github.com/strukturag/nextcloud-spreed-signaling/api"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/geoip"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
metricstest "github.com/strukturag/nextcloud-spreed-signaling/metrics/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/mock"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/sfu"
|
||||
|
|
@ -59,7 +60,7 @@ func newMcuJanusForTesting(t *testing.T) (*janusSFU, *janustest.JanusGateway) {
|
|||
if strings.Contains(t.Name(), "Filter") {
|
||||
config.AddOption("mcu", "blockedcandidates", "192.0.0.0/24, 192.168.0.0/16")
|
||||
}
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
mcu, err := NewJanusSFU(ctx, "", config)
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import (
|
|||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/api"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/internal"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/mock"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/sfu"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/talk"
|
||||
|
|
@ -193,7 +193,7 @@ func (c *TestMCUClient) MaxBitrate() api.Bandwidth {
|
|||
|
||||
func (c *TestMCUClient) Close(ctx context.Context) {
|
||||
if c.closed.CompareAndSwap(false, true) {
|
||||
logger := log.NewLoggerForTest(c.t)
|
||||
logger := logtest.NewLoggerForTest(c.t)
|
||||
logger.Printf("Close MCU client %s", c.id)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/etcd/etcdtest"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
)
|
||||
|
||||
type TestProxyInformationEtcd struct {
|
||||
|
|
@ -45,7 +45,7 @@ func newProxyConfigEtcd(t *testing.T, proxy McuProxy) (*etcdtest.TestServer, Con
|
|||
embedEtcd, client := etcdtest.NewClientForTest(t)
|
||||
cfg := goconf.NewConfigFile()
|
||||
cfg.AddOption("mcu", "keyprefix", "proxies/")
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
p, err := NewConfigEtcd(logger, cfg, client, proxy)
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/dns"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
)
|
||||
|
||||
func newProxyConfigStatic(t *testing.T, proxy McuProxy, dnsDiscovery bool, lookup *dns.MockLookup, urls ...string) (Config, *dns.Monitor) {
|
||||
|
|
@ -41,7 +41,7 @@ func newProxyConfigStatic(t *testing.T, proxy McuProxy, dnsDiscovery bool, looku
|
|||
cfg.AddOption("mcu", "dnsdiscovery", "true")
|
||||
}
|
||||
dnsMonitor := dns.NewMonitorForTest(t, time.Hour, lookup) // will be updated manually
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
p, err := NewConfigStatic(logger, cfg, proxy, dnsMonitor)
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() {
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ import (
|
|||
grpctest "github.com/strukturag/nextcloud-spreed-signaling/grpc/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/internal"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
metricstest "github.com/strukturag/nextcloud-spreed-signaling/metrics/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/proxy"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/sfu"
|
||||
|
|
@ -241,7 +242,7 @@ func newMcuProxyForTestWithOptions(t *testing.T, options testserver.ProxyTestOpt
|
|||
etcdConfig.AddOption("etcd", "endpoints", options.Etcd.URL().String())
|
||||
etcdConfig.AddOption("etcd", "loglevel", "error")
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
etcdClient, err := etcd.NewClient(logger, etcdConfig, "")
|
||||
require.NoError(err)
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import (
|
|||
grpctest "github.com/strukturag/nextcloud-spreed-signaling/grpc/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/internal"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/sfu"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/sfu/proxy"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/sfu/proxy/testserver"
|
||||
|
|
@ -96,7 +97,7 @@ func NewMcuProxyForTestWithOptions(t *testing.T, options testserver.ProxyTestOpt
|
|||
etcdConfig.AddOption("etcd", "endpoints", options.Etcd.URL().String())
|
||||
etcdConfig.AddOption("etcd", "loglevel", "error")
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
etcdClient, err := etcd.NewClient(logger, etcdConfig, "")
|
||||
require.NoError(err)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import (
|
|||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/api"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/internal"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/mock"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/sfu"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/talk"
|
||||
|
|
@ -193,7 +193,7 @@ func (c *SFUClient) MaxBitrate() api.Bandwidth {
|
|||
|
||||
func (c *SFUClient) Close(ctx context.Context) {
|
||||
if c.closed.CompareAndSwap(false, true) {
|
||||
logger := log.NewLoggerForTest(c.t)
|
||||
logger := logtest.NewLoggerForTest(c.t)
|
||||
logger.Printf("Close SFU client %s", c.id)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/pool"
|
||||
)
|
||||
|
||||
|
|
@ -69,7 +70,7 @@ func returnOCS(t *testing.T, w http.ResponseWriter, body []byte) {
|
|||
|
||||
func TestPostOnRedirect(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
r := mux.NewRouter()
|
||||
|
|
@ -117,7 +118,7 @@ func TestPostOnRedirect(t *testing.T) {
|
|||
|
||||
func TestPostOnRedirectDifferentHost(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
r := mux.NewRouter()
|
||||
|
|
@ -154,7 +155,7 @@ func TestPostOnRedirectDifferentHost(t *testing.T) {
|
|||
|
||||
func TestPostOnRedirectStatusFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
|
|
@ -197,7 +198,7 @@ func TestPostOnRedirectStatusFound(t *testing.T) {
|
|||
|
||||
func TestHandleThrottled(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/etcd/etcdtest"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/test"
|
||||
)
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ func (s *mockBackendStats) DecBackends() {
|
|||
|
||||
func TestIsUrlAllowed_Compat(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
// Old-style configuration
|
||||
valid_urls := []string{
|
||||
"http://domain.invalid",
|
||||
|
|
@ -136,7 +136,7 @@ func TestIsUrlAllowed_Compat(t *testing.T) {
|
|||
|
||||
func TestIsUrlAllowed_CompatForceHttps(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
// Old-style configuration, force HTTPS
|
||||
valid_urls := []string{
|
||||
"https://domain.invalid",
|
||||
|
|
@ -157,7 +157,7 @@ func TestIsUrlAllowed_CompatForceHttps(t *testing.T) {
|
|||
|
||||
func TestIsUrlAllowed(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
valid_urls := [][]string{
|
||||
{"https://domain.invalid/foo", string(testBackendSecret) + "-foo"},
|
||||
{"https://domain.invalid/foo/", string(testBackendSecret) + "-foo"},
|
||||
|
|
@ -202,7 +202,7 @@ func TestIsUrlAllowed(t *testing.T) {
|
|||
|
||||
func TestIsUrlAllowed_EmptyAllowlist(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
valid_urls := []string{}
|
||||
invalid_urls := []string{
|
||||
"http://domain.invalid",
|
||||
|
|
@ -219,7 +219,7 @@ func TestIsUrlAllowed_EmptyAllowlist(t *testing.T) {
|
|||
|
||||
func TestIsUrlAllowed_AllowAll(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
valid_urls := []string{
|
||||
"http://domain.invalid",
|
||||
"https://domain.invalid",
|
||||
|
|
@ -265,7 +265,7 @@ func TestBackendReloadNoChange(t *testing.T) {
|
|||
t.Parallel()
|
||||
stats := &mockBackendStats{}
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
original_config := goconf.NewConfigFile()
|
||||
|
|
@ -301,7 +301,7 @@ func TestBackendReloadChangeExistingURL(t *testing.T) {
|
|||
t.Parallel()
|
||||
stats := &mockBackendStats{}
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
original_config := goconf.NewConfigFile()
|
||||
|
|
@ -342,7 +342,7 @@ func TestBackendReloadChangeSecret(t *testing.T) {
|
|||
t.Parallel()
|
||||
stats := &mockBackendStats{}
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
original_config := goconf.NewConfigFile()
|
||||
|
|
@ -379,7 +379,7 @@ func TestBackendReloadAddBackend(t *testing.T) {
|
|||
t.Parallel()
|
||||
stats := &mockBackendStats{}
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
original_config := goconf.NewConfigFile()
|
||||
|
|
@ -420,7 +420,7 @@ func TestBackendReloadRemoveHost(t *testing.T) {
|
|||
t.Parallel()
|
||||
stats := &mockBackendStats{}
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
original_config := goconf.NewConfigFile()
|
||||
|
|
@ -458,7 +458,7 @@ func TestBackendReloadRemoveBackendFromSharedHost(t *testing.T) {
|
|||
t.Parallel()
|
||||
stats := &mockBackendStats{}
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
original_config := goconf.NewConfigFile()
|
||||
|
|
@ -512,7 +512,7 @@ func TestBackendConfiguration_EtcdCompat(t *testing.T) {
|
|||
t.Parallel()
|
||||
stats := &mockBackendStats{}
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
embedEtcd, client := etcdtest.NewClientForTest(t)
|
||||
|
|
@ -629,7 +629,7 @@ func TestBackendConfiguration_EtcdCompat(t *testing.T) {
|
|||
|
||||
func TestBackendCommonSecret(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
u1, err := url.Parse("http://domain1.invalid")
|
||||
|
|
@ -672,7 +672,7 @@ func TestBackendChangeUrls(t *testing.T) {
|
|||
t.Parallel()
|
||||
stats := &mockBackendStats{}
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
u1, err := url.Parse("http://domain1.invalid/")
|
||||
|
|
@ -762,7 +762,7 @@ func TestBackendConfiguration_EtcdChangeUrls(t *testing.T) {
|
|||
t.Parallel()
|
||||
stats := &mockBackendStats{}
|
||||
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
embedEtcd, client := etcdtest.NewClientForTest(t)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import (
|
|||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/etcd"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/etcd/etcdtest"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/test"
|
||||
)
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ func (tl *testListener) EtcdClientCreated(client etcd.Client) {
|
|||
}
|
||||
|
||||
func Test_BackendStorageEtcdNoLeak(t *testing.T) { // nolint:paralleltest
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
test.EnsureNoGoroutinesLeak(t, func(t *testing.T) {
|
||||
embedEtcd, client := etcdtest.NewClientForTest(t)
|
||||
tl := &testListener{
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ import (
|
|||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/api"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/pool"
|
||||
)
|
||||
|
||||
|
|
@ -182,7 +183,7 @@ func SetCapabilitiesGetNow(t *testing.T, capabilities *Capabilities, f func() ti
|
|||
|
||||
func TestCapabilities(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
assert := assert.New(t)
|
||||
url, capabilities := NewCapabilitiesForTest(t)
|
||||
|
|
@ -226,7 +227,7 @@ func TestCapabilities(t *testing.T) {
|
|||
|
||||
func TestInvalidateCapabilities(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
assert := assert.New(t)
|
||||
var called atomic.Uint32
|
||||
|
|
@ -287,7 +288,7 @@ func TestInvalidateCapabilities(t *testing.T) {
|
|||
|
||||
func TestCapabilitiesNoCache(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
assert := assert.New(t)
|
||||
var called atomic.Uint32
|
||||
|
|
@ -332,7 +333,7 @@ func TestCapabilitiesNoCache(t *testing.T) {
|
|||
|
||||
func TestCapabilitiesShortCache(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
assert := assert.New(t)
|
||||
var called atomic.Uint32
|
||||
|
|
@ -387,7 +388,7 @@ func TestCapabilitiesShortCache(t *testing.T) {
|
|||
|
||||
func TestCapabilitiesNoCacheETag(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
assert := assert.New(t)
|
||||
var called atomic.Uint32
|
||||
|
|
@ -429,7 +430,7 @@ func TestCapabilitiesNoCacheETag(t *testing.T) {
|
|||
|
||||
func TestCapabilitiesCacheNoMustRevalidate(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
assert := assert.New(t)
|
||||
var called atomic.Uint32
|
||||
|
|
@ -470,7 +471,7 @@ func TestCapabilitiesCacheNoMustRevalidate(t *testing.T) {
|
|||
|
||||
func TestCapabilitiesNoCacheNoMustRevalidate(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
assert := assert.New(t)
|
||||
var called atomic.Uint32
|
||||
|
|
@ -511,7 +512,7 @@ func TestCapabilitiesNoCacheNoMustRevalidate(t *testing.T) {
|
|||
|
||||
func TestCapabilitiesNoCacheMustRevalidate(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
assert := assert.New(t)
|
||||
var called atomic.Uint32
|
||||
|
|
@ -550,7 +551,7 @@ func TestCapabilitiesNoCacheMustRevalidate(t *testing.T) {
|
|||
|
||||
func TestConcurrentExpired(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.NewLoggerForTest(t)
|
||||
logger := logtest.NewLoggerForTest(t)
|
||||
ctx := log.NewLoggerContext(t.Context(), logger)
|
||||
assert := assert.New(t)
|
||||
var called atomic.Uint32
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue