-
Notifications
You must be signed in to change notification settings - Fork 43
/
simple_client_test.go
80 lines (64 loc) · 1.89 KB
/
simple_client_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package opamp
import (
"context"
"testing"
"github.com/SigNoz/signoz-otel-collector/signozcol"
"go.opentelemetry.io/collector/otelcol"
"go.uber.org/zap"
)
func TestNopClientWithCollector(t *testing.T) {
coll := signozcol.New(signozcol.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 := signozcol.New(signozcol.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 := signozcol.New(signozcol.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")
}
}