mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
cmd/kube-proxy: refactor options test
Signed-off-by: Daman Arora <aroradaman@gmail.com>
This commit is contained in:
parent
458b56811a
commit
0d14f18f8f
@ -179,6 +179,7 @@ nodePortAddresses:
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
expBindAddr := tc.bindAddress
|
||||
if tc.bindAddress[0] == '"' {
|
||||
// Surrounding double quotes will get stripped by the yaml parser.
|
||||
@ -229,8 +230,8 @@ nodePortAddresses:
|
||||
NodePortAddresses: []string{"10.20.30.40/16", "fd00:1::0/64"},
|
||||
DetectLocalMode: kubeproxyconfig.LocalModeClusterCIDR,
|
||||
DetectLocal: kubeproxyconfig.DetectLocalConfiguration{
|
||||
BridgeInterface: string("cbr0"),
|
||||
InterfaceNamePrefix: string("veth"),
|
||||
BridgeInterface: "cbr0",
|
||||
InterfaceNamePrefix: "veth",
|
||||
},
|
||||
Logging: logsapi.LoggingConfiguration{
|
||||
Format: "text",
|
||||
@ -252,8 +253,9 @@ nodePortAddresses:
|
||||
require.NoError(t, err, "unexpected error for %s: %v", tc.name, err)
|
||||
|
||||
if diff := cmp.Diff(config, expected); diff != "" {
|
||||
t.Fatalf("unexpected config for %s, diff = %s", tc.name, diff)
|
||||
t.Fatalf("unexpected config, diff = %s", diff)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -557,21 +559,13 @@ func TestAddressFromDeprecatedFlags(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
for i := range testCases {
|
||||
gotHealthz := addressFromDeprecatedFlags(testCases[i].healthzBindAddress, testCases[i].healthzPort)
|
||||
gotMetrics := addressFromDeprecatedFlags(testCases[i].metricsBindAddress, testCases[i].metricsPort)
|
||||
|
||||
errFn := func(name, except, got string) {
|
||||
t.Errorf("case %s: expected %v, got %v", name, except, got)
|
||||
}
|
||||
|
||||
if gotHealthz != testCases[i].expHealthz {
|
||||
errFn(testCases[i].name, testCases[i].expHealthz, gotHealthz)
|
||||
}
|
||||
|
||||
if gotMetrics != testCases[i].expMetrics {
|
||||
errFn(testCases[i].name, testCases[i].expMetrics, gotMetrics)
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
gotHealthz := addressFromDeprecatedFlags(tc.healthzBindAddress, tc.healthzPort)
|
||||
gotMetrics := addressFromDeprecatedFlags(tc.metricsBindAddress, tc.metricsPort)
|
||||
|
||||
require.Equal(t, tc.expHealthz, gotHealthz)
|
||||
require.Equal(t, tc.expMetrics, gotMetrics)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user