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
13de1142
Unverified
Commit
13de1142
authored
Aug 13, 2018
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for scheduler config defaults
parent
4d40dd07
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
5 deletions
+79
-5
BUILD
cmd/kube-scheduler/app/options/BUILD
+3
-0
options_test.go
cmd/kube-scheduler/app/options/options_test.go
+76
-5
No files found.
cmd/kube-scheduler/app/options/BUILD
View file @
13de1142
...
...
@@ -68,6 +68,9 @@ go_test(
"//cmd/kube-scheduler/app/config:go_default_library",
"//pkg/apis/componentconfig:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/config:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/diff:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/rand:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/apis/config:go_default_library",
],
)
cmd/kube-scheduler/app/options/options_test.go
View file @
13de1142
...
...
@@ -23,10 +23,15 @@ import (
"net/http/httptest"
"os"
"path/filepath"
"reflect"
"strings"
"testing"
"time"
apimachineryconfig
"k8s.io/apimachinery/pkg/apis/config"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/diff"
apiserverconfig
"k8s.io/apiserver/pkg/apis/config"
"k8s.io/kubernetes/pkg/apis/componentconfig"
)
...
...
@@ -127,24 +132,86 @@ users:
defer
os
.
Setenv
(
"KUBERNETES_SERVICE_HOST"
,
originalHost
)
}
defaultSource
:=
"DefaultProvider"
testcases
:=
[]
struct
{
name
string
options
*
Options
expectedUsername
string
expectedError
string
expectedConfig
componentconfig
.
KubeSchedulerConfiguration
}{
{
name
:
"config file"
,
options
:
&
Options
{
ConfigFile
:
configFile
},
name
:
"config file"
,
options
:
&
Options
{
ConfigFile
:
configFile
,
ComponentConfig
:
func
()
componentconfig
.
KubeSchedulerConfiguration
{
cfg
,
_
:=
newDefaultComponentConfig
()
return
*
cfg
}(),
},
expectedUsername
:
"config"
,
expectedConfig
:
componentconfig
.
KubeSchedulerConfiguration
{
SchedulerName
:
"default-scheduler"
,
AlgorithmSource
:
componentconfig
.
SchedulerAlgorithmSource
{
Provider
:
&
defaultSource
},
HardPodAffinitySymmetricWeight
:
1
,
HealthzBindAddress
:
"0.0.0.0:10251"
,
MetricsBindAddress
:
"0.0.0.0:10251"
,
FailureDomains
:
"kubernetes.io/hostname,failure-domain.beta.kubernetes.io/zone,failure-domain.beta.kubernetes.io/region"
,
LeaderElection
:
componentconfig
.
KubeSchedulerLeaderElectionConfiguration
{
LeaderElectionConfiguration
:
apiserverconfig
.
LeaderElectionConfiguration
{
LeaderElect
:
true
,
LeaseDuration
:
metav1
.
Duration
{
Duration
:
15
*
time
.
Second
},
RenewDeadline
:
metav1
.
Duration
{
Duration
:
10
*
time
.
Second
},
RetryPeriod
:
metav1
.
Duration
{
Duration
:
2
*
time
.
Second
},
ResourceLock
:
"endpoints"
,
},
LockObjectNamespace
:
"kube-system"
,
LockObjectName
:
"kube-scheduler"
,
},
ClientConnection
:
apimachineryconfig
.
ClientConnectionConfiguration
{
Kubeconfig
:
configKubeconfig
,
QPS
:
50
,
Burst
:
100
,
ContentType
:
"application/vnd.kubernetes.protobuf"
,
},
},
},
{
name
:
"kubeconfig flag"
,
options
:
&
Options
{
ComponentConfig
:
componentconfig
.
KubeSchedulerConfiguration
{
ClientConnection
:
apimachineryconfig
.
ClientConnectionConfiguration
{
Kubeconfig
:
flagKubeconfig
}}},
ComponentConfig
:
func
()
componentconfig
.
KubeSchedulerConfiguration
{
cfg
,
_
:=
newDefaultComponentConfig
()
cfg
.
ClientConnection
.
Kubeconfig
=
flagKubeconfig
return
*
cfg
}(),
},
expectedUsername
:
"flag"
,
expectedConfig
:
componentconfig
.
KubeSchedulerConfiguration
{
SchedulerName
:
"default-scheduler"
,
AlgorithmSource
:
componentconfig
.
SchedulerAlgorithmSource
{
Provider
:
&
defaultSource
},
HardPodAffinitySymmetricWeight
:
1
,
HealthzBindAddress
:
""
,
// defaults empty when not running from config file
MetricsBindAddress
:
""
,
// defaults empty when not running from config file
FailureDomains
:
"kubernetes.io/hostname,failure-domain.beta.kubernetes.io/zone,failure-domain.beta.kubernetes.io/region"
,
LeaderElection
:
componentconfig
.
KubeSchedulerLeaderElectionConfiguration
{
LeaderElectionConfiguration
:
apiserverconfig
.
LeaderElectionConfiguration
{
LeaderElect
:
true
,
LeaseDuration
:
metav1
.
Duration
{
Duration
:
15
*
time
.
Second
},
RenewDeadline
:
metav1
.
Duration
{
Duration
:
10
*
time
.
Second
},
RetryPeriod
:
metav1
.
Duration
{
Duration
:
2
*
time
.
Second
},
ResourceLock
:
"endpoints"
,
},
LockObjectNamespace
:
"kube-system"
,
LockObjectName
:
"kube-scheduler"
,
},
ClientConnection
:
apimachineryconfig
.
ClientConnectionConfiguration
{
Kubeconfig
:
flagKubeconfig
,
QPS
:
50
,
Burst
:
100
,
ContentType
:
"application/vnd.kubernetes.protobuf"
,
},
},
},
{
name
:
"overridden master"
,
...
...
@@ -173,6 +240,10 @@ users:
return
}
if
!
reflect
.
DeepEqual
(
config
.
ComponentConfig
,
tc
.
expectedConfig
)
{
t
.
Errorf
(
"config.diff:
\n
%s"
,
diff
.
ObjectReflectDiff
(
tc
.
expectedConfig
,
config
.
ComponentConfig
))
}
// ensure we have a client
if
config
.
Client
==
nil
{
t
.
Error
(
"unexpected nil client"
)
...
...
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