forked from grafana/grafana-operator
/
grafanaDeployment_test.go
69 lines (62 loc) · 1.67 KB
/
grafanaDeployment_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
package model
import (
"testing"
grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1"
"github.com/stretchr/testify/assert"
)
func TestGrafanaDeployment_httpProxy(t *testing.T) {
t.Run("noProxy is setting", func(t *testing.T) {
cr := &grafanav1alpha1.Grafana{
Spec: grafanav1alpha1.GrafanaSpec{
Deployment: &grafanav1alpha1.GrafanaDeployment{
HttpProxy: &grafanav1alpha1.GrafanaHttpProxy{
Enabled: true,
URL: "http://1.2.3.4",
SecureURL: "http://1.2.3.4",
NoProxy: ".svc.cluster.local,.svc",
},
},
},
}
deployment := GrafanaDeployment(cr, "", "")
for _, container := range deployment.Spec.Template.Spec.Containers {
if container.Name != "grafana" {
continue
}
noProxyExist := false
for _, env := range container.Env {
if env.Name == "NO_PROXY" {
noProxyExist = true
assert.Equal(t, ".svc.cluster.local,.svc", env.Value)
}
}
assert.True(t, noProxyExist)
}
})
t.Run("noProxy is not setting", func(t *testing.T) {
cr := &grafanav1alpha1.Grafana{
Spec: grafanav1alpha1.GrafanaSpec{
Deployment: &grafanav1alpha1.GrafanaDeployment{
HttpProxy: &grafanav1alpha1.GrafanaHttpProxy{
Enabled: true,
URL: "http://1.2.3.4",
SecureURL: "http://1.2.3.4",
},
},
},
}
deployment := GrafanaDeployment(cr, "", "")
for _, container := range deployment.Spec.Template.Spec.Containers {
if container.Name != "grafana" {
continue
}
noProxyExist := false
for _, env := range container.Env {
if env.Name == "NO_PROXY" {
noProxyExist = true
}
}
assert.False(t, noProxyExist)
}
})
}