Skip to content

Commit 0ea756f

Browse files
authored
Merge pull request kubernetes#84688 from tahsinrahman/kubeproxyconfig-test
Increase test coverage for ComponentConfigs and add tests for kubeproxyconfiguration
2 parents 646afd5 + ce5cbe8 commit 0ea756f

File tree

23 files changed

+833
-6
lines changed

23 files changed

+833
-6
lines changed

pkg/proxy/apis/config/BUILD

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package(default_visibility = ["//visibility:public"])
22

3-
load(
4-
"@io_bazel_rules_go//go:def.bzl",
5-
"go_library",
6-
)
3+
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
74

85
go_library(
96
name = "go_default_library",
@@ -40,3 +37,13 @@ filegroup(
4037
],
4138
tags = ["automanaged"],
4239
)
40+
41+
go_test(
42+
name = "go_default_test",
43+
srcs = ["register_test.go"],
44+
embed = [":go_default_library"],
45+
deps = [
46+
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
47+
"//staging/src/k8s.io/component-base/config/testing:go_default_library",
48+
],
49+
)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
Copyright 2019 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package config
18+
19+
import (
20+
"reflect"
21+
"testing"
22+
23+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24+
componentconfigtesting "k8s.io/component-base/config/testing"
25+
)
26+
27+
func TestComponentConfigSetup(t *testing.T) {
28+
pkginfo := &componentconfigtesting.ComponentConfigPackage{
29+
ComponentName: "kube-proxy",
30+
GroupName: GroupName,
31+
SchemeGroupVersion: SchemeGroupVersion,
32+
AddToScheme: AddToScheme,
33+
AllowedTags: map[reflect.Type]bool{
34+
reflect.TypeOf(metav1.TypeMeta{}): true,
35+
reflect.TypeOf(metav1.Duration{}): true,
36+
},
37+
}
38+
39+
if err := componentconfigtesting.VerifyInternalTypePackage(pkginfo); err != nil {
40+
t.Errorf("failed TestComponentConfigSetup for kube-proxy: %v", err)
41+
}
42+
}

pkg/proxy/apis/config/scheme/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ filegroup(
3131
go_test(
3232
name = "go_default_test",
3333
srcs = ["scheme_test.go"],
34+
data = glob(["testdata/**"]),
3435
embed = [":go_default_library"],
3536
deps = [
3637
"//pkg/proxy/apis/config/fuzzer:go_default_library",
3738
"//staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip:go_default_library",
39+
"//staging/src/k8s.io/component-base/config/testing:go_default_library",
3840
],
3941
)

pkg/proxy/apis/config/scheme/scheme_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,18 @@ import (
2020
"testing"
2121

2222
"k8s.io/apimachinery/pkg/api/apitesting/roundtrip"
23+
componentconfigtesting "k8s.io/component-base/config/testing"
2324
"k8s.io/kubernetes/pkg/proxy/apis/config/fuzzer"
2425
)
2526

26-
func TestRoundTripTypes(t *testing.T) {
27+
func TestRoundTripFuzzing(t *testing.T) {
2728
roundtrip.RoundTripTestForScheme(t, Scheme, fuzzer.Funcs)
2829
}
30+
31+
func TestRoundTripYAML(t *testing.T) {
32+
componentconfigtesting.RoundTripTest(t, Scheme, Codecs)
33+
}
34+
35+
func TestDefaults(t *testing.T) {
36+
componentconfigtesting.DefaultingTest(t, Scheme, Codecs)
37+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
BindAddress: ""
2+
ClientConnection:
3+
AcceptContentTypes: ""
4+
Burst: 0
5+
ContentType: ""
6+
Kubeconfig: ""
7+
QPS: 0
8+
ClusterCIDR: ""
9+
ConfigSyncPeriod: 0s
10+
Conntrack:
11+
MaxPerCore: null
12+
Min: null
13+
TCPCloseWaitTimeout: null
14+
TCPEstablishedTimeout: null
15+
EnableProfiling: false
16+
FeatureGates: null
17+
HealthzBindAddress: ""
18+
HostnameOverride: ""
19+
IPTables:
20+
MasqueradeAll: false
21+
MasqueradeBit: null
22+
MinSyncPeriod: 0s
23+
SyncPeriod: 0s
24+
IPVS:
25+
ExcludeCIDRs: null
26+
MinSyncPeriod: 0s
27+
Scheduler: ""
28+
StrictARP: false
29+
SyncPeriod: 0s
30+
MetricsBindAddress: ""
31+
Mode: ""
32+
NodePortAddresses: null
33+
OOMScoreAdj: null
34+
PortRange: ""
35+
UDPIdleTimeout: 0s
36+
Winkernel:
37+
EnableDSR: false
38+
NetworkName: ""
39+
SourceVip: ""
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
apiVersion: kubeproxy.config.k8s.io/v1alpha1
2+
bindAddress: 0.0.0.0
3+
clientConnection:
4+
acceptContentTypes: ""
5+
burst: 10
6+
contentType: application/vnd.kubernetes.protobuf
7+
kubeconfig: ""
8+
qps: 5
9+
clusterCIDR: ""
10+
configSyncPeriod: 15m0s
11+
conntrack:
12+
maxPerCore: 32768
13+
min: 131072
14+
tcpCloseWaitTimeout: 1h0m0s
15+
tcpEstablishedTimeout: 24h0m0s
16+
enableProfiling: false
17+
healthzBindAddress: 0.0.0.0:10256
18+
hostnameOverride: ""
19+
iptables:
20+
masqueradeAll: false
21+
masqueradeBit: 14
22+
minSyncPeriod: 0s
23+
syncPeriod: 30s
24+
ipvs:
25+
excludeCIDRs: null
26+
minSyncPeriod: 0s
27+
scheduler: ""
28+
strictARP: false
29+
syncPeriod: 30s
30+
kind: KubeProxyConfiguration
31+
metricsBindAddress: 127.0.0.1:10249
32+
mode: ""
33+
nodePortAddresses: null
34+
oomScoreAdj: -999
35+
portRange: ""
36+
udpIdleTimeout: 250ms
37+
winkernel:
38+
enableDSR: false
39+
networkName: ""
40+
sourceVip: ""

pkg/proxy/apis/config/scheme/testdata/KubeProxyConfiguration/before/__internal.yaml

Whitespace-only changes.

pkg/proxy/apis/config/scheme/testdata/KubeProxyConfiguration/before/v1alpha1.yaml

Whitespace-only changes.

pkg/proxy/apis/config/scheme/testdata/KubeProxyConfiguration/v1alpha1To__internal/empty.yaml

Whitespace-only changes.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
BindAddress: 0.0.0.0
2+
ClientConnection:
3+
AcceptContentTypes: ""
4+
Burst: 10
5+
ContentType: application/vnd.kubernetes.protobuf
6+
Kubeconfig: ""
7+
QPS: 5
8+
ClusterCIDR: ""
9+
ConfigSyncPeriod: 15m0s
10+
Conntrack:
11+
MaxPerCore: 32768
12+
Min: 131072
13+
TCPCloseWaitTimeout: 1h0m0s
14+
TCPEstablishedTimeout: 24h0m0s
15+
EnableProfiling: false
16+
FeatureGates: {}
17+
HealthzBindAddress: 0.0.0.0:10256
18+
HostnameOverride: ""
19+
IPTables:
20+
MasqueradeAll: false
21+
MasqueradeBit: 14
22+
MinSyncPeriod: 0s
23+
SyncPeriod: 30s
24+
IPVS:
25+
ExcludeCIDRs: null
26+
MinSyncPeriod: 0s
27+
Scheduler: ""
28+
StrictARP: false
29+
SyncPeriod: 30s
30+
MetricsBindAddress: 127.0.0.1:10249
31+
Mode: ""
32+
NodePortAddresses: null
33+
OOMScoreAdj: -999
34+
PortRange: ""
35+
UDPIdleTimeout: 250ms
36+
Winkernel:
37+
EnableDSR: false
38+
NetworkName: ""
39+
SourceVip: ""

0 commit comments

Comments
 (0)