-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdiscovery_test.go
49 lines (40 loc) · 1.05 KB
/
discovery_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
package huaweiapm_test
import (
"fmt"
"github.com/stretchr/testify/assert"
"github.com/go-chassis/huawei-apm"
"os"
"testing"
)
func TestNewResourceID(t *testing.T) {
s := huaweiapm.NewResourceID(nil, "123")
t.Log(s)
s = huaweiapm.NewRawResourceID(nil, "123")
assert.Equal(t, fmt.Sprintf("1230%d", os.Getpid()), s)
s = huaweiapm.NewRawResourceID([]string{"8080"}, "123")
assert.Equal(t, fmt.Sprintf("1238080"), s)
}
func TestGetAppID(t *testing.T) {
s := huaweiapm.NewAppID("region", "group")
t.Log(s)
s = huaweiapm.NewRawAppID("region", "group")
assert.Equal(t, "region|default|group", s)
}
func TestNewTDiscoveryInfo(t *testing.T) {
os.Setenv("PAAS_POD_ID", "1")
opts := huaweiapm.Options{
MonitoringGroup: "engine-app",
ServiceName: "cart",
ServiceType: "go-chassis"}
err := huaweiapm.Start(opts)
assert.Error(t, err)
t.Log(err)
opts = huaweiapm.Options{
MonitoringGroup: "engine-app",
ServiceName: "cart",
ServiceType: "go-chassis",
}
d, err := huaweiapm.BuildTDiscoveryInfo(opts)
assert.NoError(t, err)
t.Log(d)
}