mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-02 06:50:37 +08:00

### Summary feat(.): initialize all factories #### Related Issues / PR's Removed all redundant commits of https://github.com/SigNoz/signoz/pull/6843 Closes https://github.com/SigNoz/signoz/pull/6782
58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
package registry
|
|
|
|
import (
|
|
"context"
|
|
"sync"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"go.signoz.io/signoz/pkg/factory/servicetest"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func TestRegistryWith2HttpServers(t *testing.T) {
|
|
http1, err := servicetest.NewHttpService("http1")
|
|
require.NoError(t, err)
|
|
|
|
http2, err := servicetest.NewHttpService("http2")
|
|
require.NoError(t, err)
|
|
|
|
registry, err := New(zap.NewNop(), http1, http2)
|
|
require.NoError(t, err)
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
var wg sync.WaitGroup
|
|
wg.Add(1)
|
|
go func() {
|
|
defer wg.Done()
|
|
require.NoError(t, registry.Start(ctx))
|
|
require.NoError(t, registry.Wait(ctx))
|
|
require.NoError(t, registry.Stop(ctx))
|
|
}()
|
|
cancel()
|
|
|
|
wg.Wait()
|
|
}
|
|
|
|
func TestRegistryWith2HttpServersWithoutWait(t *testing.T) {
|
|
http1, err := servicetest.NewHttpService("http1")
|
|
require.NoError(t, err)
|
|
|
|
http2, err := servicetest.NewHttpService("http2")
|
|
require.NoError(t, err)
|
|
|
|
registry, err := New(zap.NewNop(), http1, http2)
|
|
require.NoError(t, err)
|
|
|
|
ctx := context.Background()
|
|
var wg sync.WaitGroup
|
|
wg.Add(1)
|
|
go func() {
|
|
defer wg.Done()
|
|
require.NoError(t, registry.Start(ctx))
|
|
require.NoError(t, registry.Stop(ctx))
|
|
}()
|
|
|
|
wg.Wait()
|
|
}
|