forked from openservicemesh/osm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver_test.go
60 lines (51 loc) · 1.42 KB
/
server_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
package debugger
import (
"testing"
"time"
"github.com/golang/mock/gomock"
tassert "github.com/stretchr/testify/assert"
testclient "k8s.io/client-go/kubernetes/fake"
"github.com/openservicemesh/osm/pkg/catalog"
tresorFake "github.com/openservicemesh/osm/pkg/certificate/providers/tresor/fake"
"github.com/openservicemesh/osm/pkg/envoy/registry"
"github.com/openservicemesh/osm/pkg/k8s"
)
// Tests GetHandlers returns the expected debug endpoints and non-nil handlers
func TestGetHandlers(t *testing.T) {
assert := tassert.New(t)
mockCtrl := gomock.NewController(t)
cm := tresorFake.NewFake(time.Hour)
mockXdsDebugger := NewMockXDSDebugger(mockCtrl)
mockCatalogDebugger := catalog.NewMockMeshCataloger(mockCtrl)
client := testclient.NewSimpleClientset()
mockKubeController := k8s.NewMockController(mockCtrl)
proxyRegistry := registry.NewProxyRegistry()
ds := NewDebugConfig(cm,
mockXdsDebugger,
mockCatalogDebugger,
proxyRegistry,
nil,
client,
mockKubeController,
nil)
handlers := ds.GetHandlers()
debugEndpoints := []string{
"/debug/certs",
"/debug/xds",
"/debug/proxy",
"/debug/policies",
"/debug/config",
"/debug/namespaces",
// Pprof handlers
"/debug/pprof/",
"/debug/pprof/cmdline",
"/debug/pprof/profile",
"/debug/pprof/symbol",
"/debug/pprof/trace",
}
for _, endpoint := range debugEndpoints {
handler, found := handlers[endpoint]
assert.True(found)
assert.NotNil(handler)
}
}