Files
otel-collector/opamp/simple_client_test.go
zeekay 087e487107 feat: rebrand signoz-otel-collector → Hanzo OTEL Collector
- Go module: github.com/SigNoz/signoz-otel-collector → github.com/hanzoai/otel-collector
- All signoz-prefixed packages → o11y-prefixed
- Docker: signoz/* → ghcr.io/hanzoai/otel-collector
- ClickHouse exporter → Hanzo Datastore
- Env vars: SIGNOZ_* → HANZO_*
- Directory renames for all processor/receiver/exporter packages
2026-03-12 00:21:24 -07:00

81 lines
1.9 KiB
Go

package opamp
import (
"context"
"testing"
"github.com/hanzoai/otel-collector/o11ycol"
"go.opentelemetry.io/collector/otelcol"
"go.uber.org/zap"
)
func TestNopClientWithCollector(t *testing.T) {
coll := o11ycol.New(o11ycol.WrappedCollectorSettings{
ConfigPaths: []string{"testdata/simple/config.yaml"},
Version: "0.0.1",
Desc: "test",
LoggingOpts: []zap.Option{zap.AddStacktrace(zap.ErrorLevel)},
})
client := NewSimpleClient(coll, zap.NewNop())
err := client.Start(context.Background())
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if coll.GetState() != otelcol.StateRunning {
t.Errorf("expected collector to be run")
}
err = client.Stop(context.Background())
if err != nil {
t.Errorf("unexpected error: %v", err)
}
}
func TestNopClientWithCollectorError(t *testing.T) {
coll := o11ycol.New(o11ycol.WrappedCollectorSettings{
ConfigPaths: []string{"testdata/invalid.yaml"},
Version: "0.0.1",
Desc: "test",
LoggingOpts: []zap.Option{zap.AddStacktrace(zap.ErrorLevel)},
})
client := NewSimpleClient(coll, zap.NewNop())
err := client.Start(context.Background())
if err == nil {
t.Errorf("expected error")
}
if coll.GetState() != otelcol.StateClosed {
t.Errorf("expected collector to be in closed state")
}
err = client.Stop(context.Background())
if err == nil {
t.Errorf("expected error")
}
}
func TestNopClientWithCollectorErrorRead(t *testing.T) {
coll := o11ycol.New(o11ycol.WrappedCollectorSettings{
ConfigPaths: []string{"testdata/invalid.yaml"},
Version: "0.0.1",
Desc: "test",
LoggingOpts: []zap.Option{zap.AddStacktrace(zap.ErrorLevel)},
})
client := NewSimpleClient(coll, zap.NewNop())
err := client.Start(context.Background())
if err == nil {
t.Errorf("expected error")
}
if coll.GetState() != otelcol.StateClosed {
t.Errorf("expected collector to be in closed state")
}
}