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
ada63282
Commit
ada63282
authored
Nov 04, 2016
by
Derek McQuay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubeadm: unit tests for app/master/addons.go
parent
a54515d2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
115 additions
and
0 deletions
+115
-0
addons_test.go
cmd/kubeadm/app/master/addons_test.go
+115
-0
No files found.
cmd/kubeadm/app/master/addons_test.go
0 → 100644
View file @
ada63282
/*
Copyright 2016 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
master
import
(
"testing"
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
kubeadmapi
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
)
func
TestCreateKubeProxyPodSpec
(
t
*
testing
.
T
)
{
var
tests
=
[]
struct
{
cfg
*
kubeadmapi
.
MasterConfiguration
expected
bool
}{
{
cfg
:
&
kubeadmapi
.
MasterConfiguration
{},
expected
:
true
,
},
}
for
_
,
rt
:=
range
tests
{
actual
:=
createKubeProxyPodSpec
(
rt
.
cfg
)
if
(
actual
.
Containers
[
0
]
.
Name
!=
""
)
!=
rt
.
expected
{
t
.
Errorf
(
"failed createKubeProxyPodSpec:
\n\t
expected: %t
\n\t
actual: %t"
,
rt
.
expected
,
(
actual
.
Containers
[
0
]
.
Name
!=
""
),
)
}
}
}
func
TestCreateKubeDNSPodSpec
(
t
*
testing
.
T
)
{
var
tests
=
[]
struct
{
cfg
*
kubeadmapi
.
MasterConfiguration
expected
string
}{
{
cfg
:
&
kubeadmapi
.
MasterConfiguration
{
Networking
:
kubeadm
.
Networking
{
DNSDomain
:
"localhost"
},
},
expected
:
"--domain=localhost"
,
},
{
cfg
:
&
kubeadmapi
.
MasterConfiguration
{
Networking
:
kubeadm
.
Networking
{
DNSDomain
:
"foo"
},
},
expected
:
"--domain=foo"
,
},
}
for
_
,
rt
:=
range
tests
{
actual
:=
createKubeDNSPodSpec
(
rt
.
cfg
)
if
actual
.
Containers
[
0
]
.
Args
[
0
]
!=
rt
.
expected
{
t
.
Errorf
(
"failed createKubeDNSPodSpec:
\n\t
expected: %s
\n\t
actual: %s"
,
rt
.
expected
,
actual
.
Containers
[
0
]
.
Args
[
0
],
)
}
}
}
func
TestCreateKubeDNSServiceSpec
(
t
*
testing
.
T
)
{
var
tests
=
[]
struct
{
cfg
*
kubeadmapi
.
MasterConfiguration
expected
bool
}{
{
cfg
:
&
kubeadmapi
.
MasterConfiguration
{
Networking
:
kubeadm
.
Networking
{
ServiceSubnet
:
"foo"
},
},
expected
:
false
,
},
{
cfg
:
&
kubeadmapi
.
MasterConfiguration
{
Networking
:
kubeadm
.
Networking
{
ServiceSubnet
:
"10.0.0.1/1"
},
},
expected
:
false
,
},
{
cfg
:
&
kubeadmapi
.
MasterConfiguration
{
Networking
:
kubeadm
.
Networking
{
ServiceSubnet
:
"10.0.0.1/24"
},
},
expected
:
true
,
},
}
for
_
,
rt
:=
range
tests
{
_
,
actual
:=
createKubeDNSServiceSpec
(
rt
.
cfg
)
if
(
actual
==
nil
)
!=
rt
.
expected
{
t
.
Errorf
(
"failed createKubeDNSServiceSpec:
\n\t
expected: %t
\n\t
actual: %t"
,
rt
.
expected
,
(
actual
==
nil
),
)
}
}
}
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