mirror of
https://github.com/hanzoai/otel-collector.git
synced 2026-10-30 18:26:25 +00:00
- 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
81 lines
1.9 KiB
Go
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")
|
|
}
|
|
}
|