1
0
mirror of https://github.com/rancher/rke.git synced 2025-07-22 02:51:54 +00:00
rke/services/kubeproxy_test.go

35 lines
1.2 KiB
Go
Raw Normal View History

2017-12-07 00:40:44 +00:00
package services
import (
"fmt"
"testing"
"github.com/rancher/types/apis/management.cattle.io/v3"
)
const (
TestKubeproxyImage = "rancher/k8s:latest"
2018-01-25 21:29:21 +00:00
TestKubeproxyVolumeBind = "/etc/kubernetes:/etc/kubernetes:z"
2017-12-07 00:40:44 +00:00
TestKubeproxyExtraArgs = "--foo=bar"
)
func TestKubeproxyConfig(t *testing.T) {
kubeproxyService := v3.KubeproxyService{}
kubeproxyService.Image = TestKubeproxyImage
kubeproxyService.ExtraArgs = map[string]string{"foo": "bar"}
imageCfg, hostCfg := buildKubeproxyConfig(nil, kubeproxyService)
// Test image and host config
assertEqual(t, TestKubeproxyImage, imageCfg.Image,
fmt.Sprintf("Failed to verify [%s] as KubeProxy Image", TestKubeproxyImage))
assertEqual(t, isStringInSlice(TestKubeproxyVolumeBind, hostCfg.Binds), true,
fmt.Sprintf("Failed to find [%s] in KubeProxy Volume Binds", TestKubeproxyVolumeBind))
assertEqual(t, isStringInSlice(TestKubeproxyExtraArgs, imageCfg.Entrypoint), true,
fmt.Sprintf("Failed to find [%s] in KubeProxy extra args", TestKubeproxyExtraArgs))
assertEqual(t, true, hostCfg.Privileged,
"Failed to verify that KubeProxy is privileged")
assertEqual(t, true, hostCfg.NetworkMode.IsHost(),
2017-12-09 11:53:38 +00:00
"Failed to verify that KubeProxy has host Network mode")
2017-12-07 00:40:44 +00:00
}