Add tests for kubeproxyconfig

This commit is contained in:
Md Tahsin Rahman
2019-11-03 21:09:08 +06:00
parent c762fbfa2b
commit ce5cbe8b13
15 changed files with 268 additions and 6 deletions

View File

@@ -1,9 +1,6 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
@@ -40,3 +37,13 @@ filegroup(
],
tags = ["automanaged"],
)
go_test(
name = "go_default_test",
srcs = ["register_test.go"],
embed = [":go_default_library"],
deps = [
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/component-base/config/testing:go_default_library",
],
)

View File

@@ -0,0 +1,42 @@
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package config
import (
"reflect"
"testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
componentconfigtesting "k8s.io/component-base/config/testing"
)
func TestComponentConfigSetup(t *testing.T) {
pkginfo := &componentconfigtesting.ComponentConfigPackage{
ComponentName: "kube-proxy",
GroupName: GroupName,
SchemeGroupVersion: SchemeGroupVersion,
AddToScheme: AddToScheme,
AllowedTags: map[reflect.Type]bool{
reflect.TypeOf(metav1.TypeMeta{}): true,
reflect.TypeOf(metav1.Duration{}): true,
},
}
if err := componentconfigtesting.VerifyInternalTypePackage(pkginfo); err != nil {
t.Errorf("failed TestComponentConfigSetup for kube-proxy: %v", err)
}
}

View File

@@ -31,9 +31,11 @@ filegroup(
go_test(
name = "go_default_test",
srcs = ["scheme_test.go"],
data = glob(["testdata/**"]),
embed = [":go_default_library"],
deps = [
"//pkg/proxy/apis/config/fuzzer:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip:go_default_library",
"//staging/src/k8s.io/component-base/config/testing:go_default_library",
],
)

View File

@@ -20,9 +20,18 @@ import (
"testing"
"k8s.io/apimachinery/pkg/api/apitesting/roundtrip"
componentconfigtesting "k8s.io/component-base/config/testing"
"k8s.io/kubernetes/pkg/proxy/apis/config/fuzzer"
)
func TestRoundTripTypes(t *testing.T) {
func TestRoundTripFuzzing(t *testing.T) {
roundtrip.RoundTripTestForScheme(t, Scheme, fuzzer.Funcs)
}
func TestRoundTripYAML(t *testing.T) {
componentconfigtesting.RoundTripTest(t, Scheme, Codecs)
}
func TestDefaults(t *testing.T) {
componentconfigtesting.DefaultingTest(t, Scheme, Codecs)
}

View File

@@ -0,0 +1,39 @@
BindAddress: ""
ClientConnection:
AcceptContentTypes: ""
Burst: 0
ContentType: ""
Kubeconfig: ""
QPS: 0
ClusterCIDR: ""
ConfigSyncPeriod: 0s
Conntrack:
MaxPerCore: null
Min: null
TCPCloseWaitTimeout: null
TCPEstablishedTimeout: null
EnableProfiling: false
FeatureGates: null
HealthzBindAddress: ""
HostnameOverride: ""
IPTables:
MasqueradeAll: false
MasqueradeBit: null
MinSyncPeriod: 0s
SyncPeriod: 0s
IPVS:
ExcludeCIDRs: null
MinSyncPeriod: 0s
Scheduler: ""
StrictARP: false
SyncPeriod: 0s
MetricsBindAddress: ""
Mode: ""
NodePortAddresses: null
OOMScoreAdj: null
PortRange: ""
UDPIdleTimeout: 0s
Winkernel:
EnableDSR: false
NetworkName: ""
SourceVip: ""

View File

@@ -0,0 +1,40 @@
apiVersion: kubeproxy.config.k8s.io/v1alpha1
bindAddress: 0.0.0.0
clientConnection:
acceptContentTypes: ""
burst: 10
contentType: application/vnd.kubernetes.protobuf
kubeconfig: ""
qps: 5
clusterCIDR: ""
configSyncPeriod: 15m0s
conntrack:
maxPerCore: 32768
min: 131072
tcpCloseWaitTimeout: 1h0m0s
tcpEstablishedTimeout: 24h0m0s
enableProfiling: false
healthzBindAddress: 0.0.0.0:10256
hostnameOverride: ""
iptables:
masqueradeAll: false
masqueradeBit: 14
minSyncPeriod: 0s
syncPeriod: 30s
ipvs:
excludeCIDRs: null
minSyncPeriod: 0s
scheduler: ""
strictARP: false
syncPeriod: 30s
kind: KubeProxyConfiguration
metricsBindAddress: 127.0.0.1:10249
mode: ""
nodePortAddresses: null
oomScoreAdj: -999
portRange: ""
udpIdleTimeout: 250ms
winkernel:
enableDSR: false
networkName: ""
sourceVip: ""

View File

@@ -0,0 +1,39 @@
BindAddress: 0.0.0.0
ClientConnection:
AcceptContentTypes: ""
Burst: 10
ContentType: application/vnd.kubernetes.protobuf
Kubeconfig: ""
QPS: 5
ClusterCIDR: ""
ConfigSyncPeriod: 15m0s
Conntrack:
MaxPerCore: 32768
Min: 131072
TCPCloseWaitTimeout: 1h0m0s
TCPEstablishedTimeout: 24h0m0s
EnableProfiling: false
FeatureGates: {}
HealthzBindAddress: 0.0.0.0:10256
HostnameOverride: ""
IPTables:
MasqueradeAll: false
MasqueradeBit: 14
MinSyncPeriod: 0s
SyncPeriod: 30s
IPVS:
ExcludeCIDRs: null
MinSyncPeriod: 0s
Scheduler: ""
StrictARP: false
SyncPeriod: 30s
MetricsBindAddress: 127.0.0.1:10249
Mode: ""
NodePortAddresses: null
OOMScoreAdj: -999
PortRange: ""
UDPIdleTimeout: 250ms
Winkernel:
EnableDSR: false
NetworkName: ""
SourceVip: ""

View File

@@ -0,0 +1,40 @@
apiVersion: kubeproxy.config.k8s.io/v1alpha1
bindAddress: 0.0.0.0
clientConnection:
acceptContentTypes: ""
burst: 10
contentType: application/vnd.kubernetes.protobuf
kubeconfig: ""
qps: 5
clusterCIDR: ""
configSyncPeriod: 15m0s
conntrack:
maxPerCore: 32768
min: 131072
tcpCloseWaitTimeout: 1h0m0s
tcpEstablishedTimeout: 24h0m0s
enableProfiling: false
healthzBindAddress: 0.0.0.0:10256
hostnameOverride: ""
iptables:
masqueradeAll: false
masqueradeBit: 14
minSyncPeriod: 0s
syncPeriod: 30s
ipvs:
excludeCIDRs: null
minSyncPeriod: 0s
scheduler: ""
strictARP: false
syncPeriod: 30s
kind: KubeProxyConfiguration
metricsBindAddress: 127.0.0.1:10249
mode: ""
nodePortAddresses: null
oomScoreAdj: -999
portRange: ""
udpIdleTimeout: 250ms
winkernel:
enableDSR: false
networkName: ""
sourceVip: ""

View File

@@ -1,4 +1,4 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
@@ -32,3 +32,10 @@ filegroup(
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
go_test(
name = "go_default_test",
srcs = ["register_test.go"],
embed = [":go_default_library"],
deps = ["//staging/src/k8s.io/component-base/config/testing:go_default_library"],
)

View File

@@ -0,0 +1,36 @@
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1
import (
"testing"
componentconfigtesting "k8s.io/component-base/config/testing"
)
func TestComponentConfigSetup(t *testing.T) {
pkginfo := &componentconfigtesting.ComponentConfigPackage{
ComponentName: "kube-proxy",
GroupName: GroupName,
SchemeGroupVersion: SchemeGroupVersion,
AddToScheme: AddToScheme,
}
if err := componentconfigtesting.VerifyExternalTypePackage(pkginfo); err != nil {
t.Errorf("failed TestComponentConfigSetup: %v", err)
}
}

1
vendor/modules.txt vendored
View File

@@ -1658,6 +1658,7 @@ k8s.io/component-base/cli/flag
k8s.io/component-base/cli/globalflag
k8s.io/component-base/codec
k8s.io/component-base/config
k8s.io/component-base/config/testing
k8s.io/component-base/config/v1alpha1
k8s.io/component-base/config/validation
k8s.io/component-base/featuregate