chore: add more tests (#3299)
This commit is contained in:
@@ -85,10 +85,7 @@ func createExporter(c Config) (sdktrace.SpanExporter, error) {
|
||||
if len(c.OtlpHeaders) > 0 {
|
||||
opts = append(opts, otlptracegrpc.WithHeaders(c.OtlpHeaders))
|
||||
}
|
||||
return otlptracegrpc.New(
|
||||
context.Background(),
|
||||
opts...,
|
||||
)
|
||||
return otlptracegrpc.New(context.Background(), opts...)
|
||||
case kindOtlpHttp:
|
||||
// Not support flexible configuration now.
|
||||
opts := []otlptracehttp.Option{
|
||||
@@ -101,10 +98,7 @@ func createExporter(c Config) (sdktrace.SpanExporter, error) {
|
||||
if len(c.OtlpHttpPath) > 0 {
|
||||
opts = append(opts, otlptracehttp.WithURLPath(c.OtlpHttpPath))
|
||||
}
|
||||
return otlptracehttp.New(
|
||||
context.Background(),
|
||||
opts...,
|
||||
)
|
||||
return otlptracehttp.New(context.Background(), opts...)
|
||||
case kindFile:
|
||||
f, err := os.OpenFile(c.Endpoint, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666)
|
||||
if err != nil {
|
||||
|
||||
@@ -11,13 +11,14 @@ func TestStartAgent(t *testing.T) {
|
||||
logx.Disable()
|
||||
|
||||
const (
|
||||
endpoint1 = "localhost:1234"
|
||||
endpoint2 = "remotehost:1234"
|
||||
endpoint3 = "localhost:1235"
|
||||
endpoint4 = "localhost:1236"
|
||||
endpoint5 = "udp://localhost:6831"
|
||||
endpoint6 = "localhost:1237"
|
||||
endpoint7 = "/tmp/trace.log"
|
||||
endpoint1 = "localhost:1234"
|
||||
endpoint2 = "remotehost:1234"
|
||||
endpoint3 = "localhost:1235"
|
||||
endpoint4 = "localhost:1236"
|
||||
endpoint5 = "udp://localhost:6831"
|
||||
endpoint6 = "localhost:1237"
|
||||
endpoint71 = "/tmp/trace.log"
|
||||
endpoint72 = "/not-exist-fs/trace.log"
|
||||
)
|
||||
c1 := Config{
|
||||
Name: "foo",
|
||||
@@ -66,7 +67,12 @@ func TestStartAgent(t *testing.T) {
|
||||
}
|
||||
c9 := Config{
|
||||
Name: "file",
|
||||
Endpoint: endpoint7,
|
||||
Endpoint: endpoint71,
|
||||
Batcher: kindFile,
|
||||
}
|
||||
c10 := Config{
|
||||
Name: "file",
|
||||
Endpoint: endpoint72,
|
||||
Batcher: kindFile,
|
||||
}
|
||||
|
||||
@@ -80,6 +86,7 @@ func TestStartAgent(t *testing.T) {
|
||||
StartAgent(c7)
|
||||
StartAgent(c8)
|
||||
StartAgent(c9)
|
||||
StartAgent(c10)
|
||||
defer StopAgent()
|
||||
|
||||
lock.Lock()
|
||||
@@ -97,6 +104,8 @@ func TestStartAgent(t *testing.T) {
|
||||
assert.True(t, ok)
|
||||
_, ok = agents[endpoint6]
|
||||
assert.False(t, ok)
|
||||
_, ok = agents[endpoint7]
|
||||
_, ok = agents[endpoint71]
|
||||
assert.True(t, ok)
|
||||
_, ok = agents[endpoint72]
|
||||
assert.False(t, ok)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user