Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
c630a410
Commit
c630a410
authored
Oct 15, 2017
by
drinktee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add unit test for cloud-controller-manager
parent
f54ed0da
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
114 additions
and
0 deletions
+114
-0
BUILD
cmd/cloud-controller-manager/app/options/BUILD
+13
-0
options_test.go
cmd/cloud-controller-manager/app/options/options_test.go
+101
-0
No files found.
cmd/cloud-controller-manager/app/options/BUILD
View file @
c630a410
...
...
@@ -3,6 +3,7 @@ package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
go_library(
...
...
@@ -31,3 +32,15 @@ filegroup(
srcs = [":package-srcs"],
tags = ["automanaged"],
)
go_test(
name = "go_default_test",
srcs = ["options_test.go"],
library = ":go_default_library",
deps = [
"//pkg/apis/componentconfig:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/diff:go_default_library",
],
)
cmd/cloud-controller-manager/app/options/options_test.go
0 → 100644
View file @
c630a410
/*
Copyright 2017 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
options
import
(
"reflect"
"testing"
"time"
"github.com/spf13/pflag"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/kubernetes/pkg/apis/componentconfig"
)
func
TestAddFlags
(
t
*
testing
.
T
)
{
f
:=
pflag
.
NewFlagSet
(
"addflagstest"
,
pflag
.
ContinueOnError
)
s
:=
NewCloudControllerManagerServer
()
s
.
AddFlags
(
f
)
args
:=
[]
string
{
"--address=192.168.4.10"
,
"--allocate-node-cidrs=true"
,
"--cloud-config=/cloud-config"
,
"--cloud-provider=gce"
,
"--cluster-cidr=1.2.3.4/24"
,
"--cluster-name=k8s"
,
"--configure-cloud-routes=false"
,
"--contention-profiling=true"
,
"--controller-start-interval=2m"
,
"--min-resync-period=5m"
,
"--kube-api-burst=100"
,
"--kube-api-content-type=application/vnd.kubernetes.protobuf"
,
"--kube-api-qps=50.0"
,
"--kubeconfig=/kubeconfig"
,
"--leader-elect=false"
,
"--leader-elect-lease-duration=30s"
,
"--leader-elect-renew-deadline=15s"
,
"--leader-elect-resource-lock=configmap"
,
"--leader-elect-retry-period=5s"
,
"--master=192.168.4.20"
,
"--min-resync-period=8h"
,
"--port=10000"
,
"--profiling=false"
,
"--node-status-update-frequency=10m"
,
"--route-reconciliation-period=30s"
,
"--min-resync-period=100m"
,
"--use-service-account-credentials=false"
,
}
f
.
Parse
(
args
)
expected
:=
&
CloudControllerManagerServer
{
KubeControllerManagerConfiguration
:
componentconfig
.
KubeControllerManagerConfiguration
{
CloudProvider
:
"gce"
,
CloudConfigFile
:
"/cloud-config"
,
Port
:
10000
,
Address
:
"192.168.4.10"
,
ConcurrentServiceSyncs
:
1
,
MinResyncPeriod
:
metav1
.
Duration
{
Duration
:
100
*
time
.
Minute
},
NodeMonitorPeriod
:
metav1
.
Duration
{
Duration
:
5
*
time
.
Second
},
ClusterName
:
"k8s"
,
ConfigureCloudRoutes
:
false
,
AllocateNodeCIDRs
:
true
,
ContentType
:
"application/vnd.kubernetes.protobuf"
,
EnableContentionProfiling
:
true
,
KubeAPIQPS
:
50.0
,
KubeAPIBurst
:
100
,
LeaderElection
:
componentconfig
.
LeaderElectionConfiguration
{
ResourceLock
:
"configmap"
,
LeaderElect
:
false
,
LeaseDuration
:
metav1
.
Duration
{
Duration
:
30
*
time
.
Second
},
RenewDeadline
:
metav1
.
Duration
{
Duration
:
15
*
time
.
Second
},
RetryPeriod
:
metav1
.
Duration
{
Duration
:
5
*
time
.
Second
},
},
ControllerStartInterval
:
metav1
.
Duration
{
Duration
:
2
*
time
.
Minute
},
RouteReconciliationPeriod
:
metav1
.
Duration
{
Duration
:
30
*
time
.
Second
},
ClusterCIDR
:
"1.2.3.4/24"
,
},
Kubeconfig
:
"/kubeconfig"
,
Master
:
"192.168.4.20"
,
NodeStatusUpdateFrequency
:
metav1
.
Duration
{
Duration
:
10
*
time
.
Minute
},
}
if
!
reflect
.
DeepEqual
(
expected
,
s
)
{
t
.
Errorf
(
"Got different run options than expected.
\n
Difference detected on:
\n
%s"
,
diff
.
ObjectReflectDiff
(
expected
,
s
))
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment