/
controller_test.go
78 lines (65 loc) · 2.05 KB
/
controller_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
package controller
import (
"os"
"testing"
"github.com/containous/maesh/pkg/k8s"
"github.com/containous/maesh/pkg/topology"
"github.com/containous/traefik/v2/pkg/config/dynamic"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
)
const (
meshNamespace string = "maesh"
minHTTPPort = int32(5000)
maxHTTPPort = int32(5005)
minTCPPort = int32(10000)
maxTCPPort = int32(10005)
minUDPPort = int32(15000)
maxUDPPort = int32(15005)
)
type storeMock struct{}
func (a *storeMock) SetConfig(cfg *dynamic.Configuration) {}
func (a *storeMock) SetTopology(topo *topology.Topology) {}
func (a *storeMock) SetReadiness(isReady bool) {}
func TestController_NewMeshController(t *testing.T) {
store := &storeMock{}
clientMock := k8s.NewClientMock(t, "mock.yaml")
log := logrus.New()
log.SetOutput(os.Stdout)
log.SetLevel(logrus.DebugLevel)
// Create a new controller with base HTTP mode.
controller := NewMeshController(clientMock, Config{
ACLEnabled: false,
DefaultMode: "http",
Namespace: meshNamespace,
IgnoreNamespaces: []string{},
MinHTTPPort: minHTTPPort,
MaxHTTPPort: maxHTTPPort,
MinTCPPort: minTCPPort,
MaxTCPPort: maxTCPPort,
MinUDPPort: minUDPPort,
MaxUDPPort: maxUDPPort,
}, store, log)
assert.NotNil(t, controller)
}
func TestController_NewMeshControllerWithSMI(t *testing.T) {
store := &storeMock{}
clientMock := k8s.NewClientMock(t, "mock.yaml")
log := logrus.New()
log.SetOutput(os.Stdout)
log.SetLevel(logrus.DebugLevel)
// Create a new controller with base HTTP mode, in SMI mode.
controller := NewMeshController(clientMock, Config{
ACLEnabled: true,
DefaultMode: "http",
Namespace: meshNamespace,
IgnoreNamespaces: []string{},
MinHTTPPort: minHTTPPort,
MaxHTTPPort: maxHTTPPort,
MinTCPPort: minTCPPort,
MaxTCPPort: maxTCPPort,
MinUDPPort: minUDPPort,
MaxUDPPort: maxUDPPort,
}, store, log)
assert.NotNil(t, controller)
}