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
49b53b86
Commit
49b53b86
authored
Nov 04, 2016
by
Derek McQuay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubeadm: unit tests for app/master/apiclient.go
parent
ada63282
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
201 additions
and
0 deletions
+201
-0
apiclient_test.go
cmd/kubeadm/app/master/apiclient_test.go
+201
-0
No files found.
cmd/kubeadm/app/master/apiclient_test.go
0 → 100644
View file @
49b53b86
/*
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
(
"fmt"
"testing"
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
kubeadmapi
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
"k8s.io/kubernetes/pkg/api"
)
func
TestCreateClientAndWaitForAPI
(
t
*
testing
.
T
)
{
cfg
:=
&
kubeadmapi
.
MasterConfiguration
{
Networking
:
kubeadm
.
Networking
{
DNSDomain
:
"localhost"
},
}
fmt
.
Println
(
cfg
)
}
func
TestStandardLabels
(
t
*
testing
.
T
)
{
var
tests
=
[]
struct
{
n
string
expected
string
}{
{
n
:
"foo"
,
expected
:
"foo"
,
},
{
n
:
"bar"
,
expected
:
"bar"
,
},
}
for
_
,
rt
:=
range
tests
{
actual
:=
standardLabels
(
rt
.
n
)
if
actual
[
"component"
]
!=
rt
.
expected
{
t
.
Errorf
(
"failed standardLabels:
\n\t
expected: %s
\n\t
actual: %s"
,
rt
.
expected
,
actual
[
"component"
],
)
}
if
actual
[
"name"
]
!=
rt
.
expected
{
t
.
Errorf
(
"failed standardLabels:
\n\t
expected: %s
\n\t
actual: %s"
,
rt
.
expected
,
actual
[
"name"
],
)
}
if
actual
[
"k8s-app"
]
!=
rt
.
expected
{
t
.
Errorf
(
"failed standardLabels:
\n\t
expected: %s
\n\t
actual: %s"
,
rt
.
expected
,
actual
[
"k8s-app"
],
)
}
}
}
func
TestNewDaemonSet
(
t
*
testing
.
T
)
{
var
tests
=
[]
struct
{
dn
string
expected
string
}{
{
dn
:
"foo"
,
expected
:
"foo"
,
},
{
dn
:
"bar"
,
expected
:
"bar"
,
},
}
for
_
,
rt
:=
range
tests
{
p
:=
api
.
PodSpec
{}
actual
:=
NewDaemonSet
(
rt
.
dn
,
p
)
if
actual
.
Spec
.
Selector
.
MatchLabels
[
"k8s-app"
]
!=
rt
.
expected
{
t
.
Errorf
(
"failed NewDaemonSet:
\n\t
expected: %s
\n\t
actual: %s"
,
rt
.
expected
,
actual
.
Spec
.
Selector
.
MatchLabels
[
"k8s-app"
],
)
}
if
actual
.
Spec
.
Selector
.
MatchLabels
[
"component"
]
!=
rt
.
expected
{
t
.
Errorf
(
"failed NewDaemonSet:
\n\t
expected: %s
\n\t
actual: %s"
,
rt
.
expected
,
actual
.
Spec
.
Selector
.
MatchLabels
[
"component"
],
)
}
if
actual
.
Spec
.
Selector
.
MatchLabels
[
"name"
]
!=
rt
.
expected
{
t
.
Errorf
(
"failed NewDaemonSet:
\n\t
expected: %s
\n\t
actual: %s"
,
rt
.
expected
,
actual
.
Spec
.
Selector
.
MatchLabels
[
"name"
],
)
}
}
}
func
TestNewService
(
t
*
testing
.
T
)
{
var
tests
=
[]
struct
{
dn
string
expected
string
}{
{
dn
:
"foo"
,
expected
:
"foo"
,
},
{
dn
:
"bar"
,
expected
:
"bar"
,
},
}
for
_
,
rt
:=
range
tests
{
p
:=
api
.
ServiceSpec
{}
actual
:=
NewService
(
rt
.
dn
,
p
)
if
actual
.
ObjectMeta
.
Labels
[
"k8s-app"
]
!=
rt
.
expected
{
t
.
Errorf
(
"failed NewService:
\n\t
expected: %s
\n\t
actual: %s"
,
rt
.
expected
,
actual
.
ObjectMeta
.
Labels
[
"k8s-app"
],
)
}
if
actual
.
ObjectMeta
.
Labels
[
"component"
]
!=
rt
.
expected
{
t
.
Errorf
(
"failed NewService:
\n\t
expected: %s
\n\t
actual: %s"
,
rt
.
expected
,
actual
.
ObjectMeta
.
Labels
[
"component"
],
)
}
if
actual
.
ObjectMeta
.
Labels
[
"name"
]
!=
rt
.
expected
{
t
.
Errorf
(
"failed NewService:
\n\t
expected: %s
\n\t
actual: %s"
,
rt
.
expected
,
actual
.
ObjectMeta
.
Labels
[
"name"
],
)
}
}
}
func
TestNewDeployment
(
t
*
testing
.
T
)
{
var
tests
=
[]
struct
{
dn
string
expected
string
}{
{
dn
:
"foo"
,
expected
:
"foo"
,
},
{
dn
:
"bar"
,
expected
:
"bar"
,
},
}
for
_
,
rt
:=
range
tests
{
p
:=
api
.
PodSpec
{}
actual
:=
NewDeployment
(
rt
.
dn
,
1
,
p
)
if
actual
.
Spec
.
Selector
.
MatchLabels
[
"k8s-app"
]
!=
rt
.
expected
{
t
.
Errorf
(
"failed NewDeployment:
\n\t
expected: %s
\n\t
actual: %s"
,
rt
.
expected
,
actual
.
Spec
.
Selector
.
MatchLabels
[
"k8s-app"
],
)
}
if
actual
.
Spec
.
Selector
.
MatchLabels
[
"component"
]
!=
rt
.
expected
{
t
.
Errorf
(
"failed NewDeployment:
\n\t
expected: %s
\n\t
actual: %s"
,
rt
.
expected
,
actual
.
Spec
.
Selector
.
MatchLabels
[
"component"
],
)
}
if
actual
.
Spec
.
Selector
.
MatchLabels
[
"name"
]
!=
rt
.
expected
{
t
.
Errorf
(
"failed NewDeployment:
\n\t
expected: %s
\n\t
actual: %s"
,
rt
.
expected
,
actual
.
Spec
.
Selector
.
MatchLabels
[
"name"
],
)
}
}
}
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