mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-16 06:32:32 +00:00
Add tests for kubeproxyconfig
This commit is contained in:
@@ -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",
|
||||
],
|
||||
)
|
||||
|
42
pkg/proxy/apis/config/register_test.go
Normal file
42
pkg/proxy/apis/config/register_test.go
Normal 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)
|
||||
}
|
||||
}
|
@@ -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",
|
||||
],
|
||||
)
|
||||
|
@@ -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)
|
||||
}
|
||||
|
39
pkg/proxy/apis/config/scheme/testdata/KubeProxyConfiguration/after/__internal.yaml
vendored
Executable file
39
pkg/proxy/apis/config/scheme/testdata/KubeProxyConfiguration/after/__internal.yaml
vendored
Executable 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: ""
|
40
pkg/proxy/apis/config/scheme/testdata/KubeProxyConfiguration/after/v1alpha1.yaml
vendored
Executable file
40
pkg/proxy/apis/config/scheme/testdata/KubeProxyConfiguration/after/v1alpha1.yaml
vendored
Executable 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: ""
|
0
pkg/proxy/apis/config/scheme/testdata/KubeProxyConfiguration/before/__internal.yaml
vendored
Normal file
0
pkg/proxy/apis/config/scheme/testdata/KubeProxyConfiguration/before/__internal.yaml
vendored
Normal file
0
pkg/proxy/apis/config/scheme/testdata/KubeProxyConfiguration/before/v1alpha1.yaml
vendored
Normal file
0
pkg/proxy/apis/config/scheme/testdata/KubeProxyConfiguration/before/v1alpha1.yaml
vendored
Normal file
0
pkg/proxy/apis/config/scheme/testdata/KubeProxyConfiguration/v1alpha1To__internal/empty.yaml
vendored
Normal file
0
pkg/proxy/apis/config/scheme/testdata/KubeProxyConfiguration/v1alpha1To__internal/empty.yaml
vendored
Normal file
39
pkg/proxy/apis/config/scheme/testdata/KubeProxyConfiguration/v1alpha1To__internal/empty.yaml.after_roundtrip
vendored
Executable file
39
pkg/proxy/apis/config/scheme/testdata/KubeProxyConfiguration/v1alpha1To__internal/empty.yaml.after_roundtrip
vendored
Executable 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: ""
|
0
pkg/proxy/apis/config/scheme/testdata/KubeProxyConfiguration/v1alpha1Tov1alpha1/empty.yaml
vendored
Normal file
0
pkg/proxy/apis/config/scheme/testdata/KubeProxyConfiguration/v1alpha1Tov1alpha1/empty.yaml
vendored
Normal file
40
pkg/proxy/apis/config/scheme/testdata/KubeProxyConfiguration/v1alpha1Tov1alpha1/empty.yaml.after_roundtrip
vendored
Executable file
40
pkg/proxy/apis/config/scheme/testdata/KubeProxyConfiguration/v1alpha1Tov1alpha1/empty.yaml.after_roundtrip
vendored
Executable 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: ""
|
@@ -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"],
|
||||
)
|
||||
|
@@ -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
1
vendor/modules.txt
vendored
@@ -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
|
||||
|
Reference in New Issue
Block a user