Merge pull request #52403 from m1093782566/ut-ipvs-config

Automatic merge from submit-queue (batch tested with PRs 52355, 52537, 52551, 52403, 50673). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>..

Clear TODO: Adding UT for loading ipvs config

**What this PR does / why we need it**:

Clear TODO: Adding UT for loading ipvs config

**Which issue this PR fixes**: 

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue 2017-09-23 15:27:00 -07:00 committed by GitHub
commit bc6d20cf33

View File

@ -292,7 +292,7 @@ ipvs:
syncPeriod: 60s syncPeriod: 60s
kind: KubeProxyConfiguration kind: KubeProxyConfiguration
metricsBindAddress: "%s" metricsBindAddress: "%s"
mode: "iptables" mode: "%s"
oomScoreAdj: 17 oomScoreAdj: 17
portRange: "2-7" portRange: "2-7"
resourceContainer: /foo resourceContainer: /foo
@ -301,20 +301,23 @@ udpTimeoutMilliseconds: 123ms
testCases := []struct { testCases := []struct {
name string name string
mode string
bindAddress string bindAddress string
clusterCIDR string clusterCIDR string
healthzBindAddress string healthzBindAddress string
metricsBindAddress string metricsBindAddress string
}{ }{
{ {
name: "IPv4 config", name: "iptables mode, IPv4 config",
mode: "iptables",
bindAddress: "9.8.7.6", bindAddress: "9.8.7.6",
clusterCIDR: "1.2.3.0/24", clusterCIDR: "1.2.3.0/24",
healthzBindAddress: "1.2.3.4:12345", healthzBindAddress: "1.2.3.4:12345",
metricsBindAddress: "2.3.4.5:23456", metricsBindAddress: "2.3.4.5:23456",
}, },
{ {
name: "IPv6 config", name: "ipvs mode, IPv6 config",
mode: "ipvs",
bindAddress: "2001:db8::1", bindAddress: "2001:db8::1",
clusterCIDR: "fd00:1::0/64", clusterCIDR: "fd00:1::0/64",
healthzBindAddress: "[fd00:1::5]:12345", healthzBindAddress: "[fd00:1::5]:12345",
@ -355,8 +358,7 @@ udpTimeoutMilliseconds: 123ms
SyncPeriod: metav1.Duration{Duration: 60 * time.Second}, SyncPeriod: metav1.Duration{Duration: 60 * time.Second},
}, },
MetricsBindAddress: tc.metricsBindAddress, MetricsBindAddress: tc.metricsBindAddress,
Mode: "iptables", Mode: componentconfig.ProxyMode(tc.mode),
// TODO: IPVS
OOMScoreAdj: utilpointer.Int32Ptr(17), OOMScoreAdj: utilpointer.Int32Ptr(17),
PortRange: "2-7", PortRange: "2-7",
ResourceContainer: "/foo", ResourceContainer: "/foo",
@ -368,7 +370,7 @@ udpTimeoutMilliseconds: 123ms
yaml := fmt.Sprintf( yaml := fmt.Sprintf(
yamlTemplate, tc.bindAddress, tc.clusterCIDR, yamlTemplate, tc.bindAddress, tc.clusterCIDR,
tc.healthzBindAddress, tc.metricsBindAddress) tc.healthzBindAddress, tc.metricsBindAddress, tc.mode)
config, err := options.loadConfig([]byte(yaml)) config, err := options.loadConfig([]byte(yaml))
assert.NoError(t, err, "unexpected error for %s: %v", tc.name, err) assert.NoError(t, err, "unexpected error for %s: %v", tc.name, err)
if !reflect.DeepEqual(expected, config) { if !reflect.DeepEqual(expected, config) {