1
0
mirror of https://github.com/rancher/rke.git synced 2025-07-20 02:00:32 +00:00
rke/services/proxy_test.go
2017-12-09 19:53:38 +08:00

50 lines
1.3 KiB
Go

package services
import (
"fmt"
"testing"
"github.com/rancher/rke/hosts"
"github.com/rancher/types/apis/management.cattle.io/v3"
)
const (
TestNginxProxyImage = "test/test:latest"
TestNginxProxyConnectionString = "1.1.1.1,2.2.2.2"
)
func TestNginxProxyConfig(t *testing.T) {
cpHosts := []*hosts.Host{
&hosts.Host{
RKEConfigNode: v3.RKEConfigNode{
Address: "1.1.1.1",
InternalAddress: "1.1.1.1",
Role: []string{"controlplane"},
HostnameOverride: "cp1",
},
DClient: nil,
},
&hosts.Host{
RKEConfigNode: v3.RKEConfigNode{
Address: "2.2.2.2",
InternalAddress: "2.2.2.2",
Role: []string{"controlplane"},
HostnameOverride: "cp1",
},
DClient: nil,
},
}
nginxProxyImage := TestNginxProxyImage
nginxProxyEnv := buildProxyEnv(cpHosts)
assertEqual(t, TestNginxProxyConnectionString, nginxProxyEnv,
fmt.Sprintf("Failed to verify nginx connection string [%s]", TestNginxProxyConnectionString))
imageCfg, hostCfg := buildNginxProxyConfig(nil, nginxProxyEnv, nginxProxyImage)
// Test image and host config
assertEqual(t, TestNginxProxyImage, imageCfg.Image,
fmt.Sprintf("Failed to verify [%s] as Nginx Proxy Image", TestNginxProxyImage))
assertEqual(t, true, hostCfg.NetworkMode.IsHost(),
"Failed to verify that Nginx Proxy has host Network mode")
}