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
64aa958e
Commit
64aa958e
authored
Jun 01, 2015
by
Yu-Ju Hong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make PodList span multiple lines for readability
parent
55f7b9b9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
102 additions
and
13 deletions
+102
-13
kubelet_test.go
pkg/kubelet/kubelet_test.go
+102
-13
No files found.
pkg/kubelet/kubelet_test.go
View file @
64aa958e
...
@@ -552,7 +552,13 @@ func TestSyncPodsDeletesWhenSourcesAreReady(t *testing.T) {
...
@@ -552,7 +552,13 @@ func TestSyncPodsDeletesWhenSourcesAreReady(t *testing.T) {
kubelet
.
sourcesReady
=
func
()
bool
{
return
ready
}
kubelet
.
sourcesReady
=
func
()
bool
{
return
ready
}
fakeRuntime
.
PodList
=
[]
*
kubecontainer
.
Pod
{
fakeRuntime
.
PodList
=
[]
*
kubecontainer
.
Pod
{
{
ID
:
"12345678"
,
Name
:
"foo"
,
Namespace
:
"new"
,
Containers
:
[]
*
kubecontainer
.
Container
{{
Name
:
"bar"
}}},
{
ID
:
"12345678"
,
Name
:
"foo"
,
Namespace
:
"new"
,
Containers
:
[]
*
kubecontainer
.
Container
{
{
Name
:
"bar"
},
},
},
}
}
if
err
:=
kubelet
.
SyncPods
([]
*
api
.
Pod
{},
emptyPodUIDs
,
map
[
string
]
*
api
.
Pod
{},
time
.
Now
());
err
!=
nil
{
if
err
:=
kubelet
.
SyncPods
([]
*
api
.
Pod
{},
emptyPodUIDs
,
map
[
string
]
*
api
.
Pod
{},
time
.
Now
());
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
...
@@ -733,7 +739,17 @@ func TestGetContainerInfo(t *testing.T) {
...
@@ -733,7 +739,17 @@ func TestGetContainerInfo(t *testing.T) {
mockCadvisor
:=
testKubelet
.
fakeCadvisor
mockCadvisor
:=
testKubelet
.
fakeCadvisor
mockCadvisor
.
On
(
"DockerContainer"
,
containerID
,
cadvisorReq
)
.
Return
(
containerInfo
,
nil
)
mockCadvisor
.
On
(
"DockerContainer"
,
containerID
,
cadvisorReq
)
.
Return
(
containerInfo
,
nil
)
fakeRuntime
.
PodList
=
[]
*
kubecontainer
.
Pod
{
fakeRuntime
.
PodList
=
[]
*
kubecontainer
.
Pod
{
{
ID
:
"12345678"
,
Name
:
"qux"
,
Namespace
:
"ns"
,
Containers
:
[]
*
kubecontainer
.
Container
{{
Name
:
"foo"
,
ID
:
types
.
UID
(
containerID
)}}},
{
ID
:
"12345678"
,
Name
:
"qux"
,
Namespace
:
"ns"
,
Containers
:
[]
*
kubecontainer
.
Container
{
{
Name
:
"foo"
,
ID
:
types
.
UID
(
containerID
),
},
},
},
}
}
stats
,
err
:=
kubelet
.
GetContainerInfo
(
"qux_ns"
,
""
,
"foo"
,
cadvisorReq
)
stats
,
err
:=
kubelet
.
GetContainerInfo
(
"qux_ns"
,
""
,
"foo"
,
cadvisorReq
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -806,7 +822,16 @@ func TestGetContainerInfoWhenCadvisorFailed(t *testing.T) {
...
@@ -806,7 +822,16 @@ func TestGetContainerInfoWhenCadvisorFailed(t *testing.T) {
cadvisorReq
:=
&
cadvisorApi
.
ContainerInfoRequest
{}
cadvisorReq
:=
&
cadvisorApi
.
ContainerInfoRequest
{}
mockCadvisor
.
On
(
"DockerContainer"
,
containerID
,
cadvisorReq
)
.
Return
(
containerInfo
,
cadvisorApiFailure
)
mockCadvisor
.
On
(
"DockerContainer"
,
containerID
,
cadvisorReq
)
.
Return
(
containerInfo
,
cadvisorApiFailure
)
fakeRuntime
.
PodList
=
[]
*
kubecontainer
.
Pod
{
fakeRuntime
.
PodList
=
[]
*
kubecontainer
.
Pod
{
{
ID
:
"uuid"
,
Name
:
"qux"
,
Namespace
:
"ns"
,
Containers
:
[]
*
kubecontainer
.
Container
{{
Name
:
"foo"
,
ID
:
types
.
UID
(
containerID
)}}},
{
ID
:
"uuid"
,
Name
:
"qux"
,
Namespace
:
"ns"
,
Containers
:
[]
*
kubecontainer
.
Container
{
{
Name
:
"foo"
,
ID
:
types
.
UID
(
containerID
),
},
},
},
}
}
stats
,
err
:=
kubelet
.
GetContainerInfo
(
"qux_ns"
,
"uuid"
,
"foo"
,
cadvisorReq
)
stats
,
err
:=
kubelet
.
GetContainerInfo
(
"qux_ns"
,
"uuid"
,
"foo"
,
cadvisorReq
)
if
stats
!=
nil
{
if
stats
!=
nil
{
...
@@ -881,7 +906,15 @@ func TestGetContainerInfoWithNoMatchingContainers(t *testing.T) {
...
@@ -881,7 +906,15 @@ func TestGetContainerInfoWithNoMatchingContainers(t *testing.T) {
kubelet
:=
testKubelet
.
kubelet
kubelet
:=
testKubelet
.
kubelet
mockCadvisor
:=
testKubelet
.
fakeCadvisor
mockCadvisor
:=
testKubelet
.
fakeCadvisor
fakeRuntime
.
PodList
=
[]
*
kubecontainer
.
Pod
{
fakeRuntime
.
PodList
=
[]
*
kubecontainer
.
Pod
{
{
ID
:
"12345678"
,
Name
:
"qux"
,
Namespace
:
"ns"
,
Containers
:
[]
*
kubecontainer
.
Container
{{
Name
:
"bar"
,
ID
:
types
.
UID
(
"fakeID"
)}}},
{
ID
:
"12345678"
,
Name
:
"qux"
,
Namespace
:
"ns"
,
Containers
:
[]
*
kubecontainer
.
Container
{
{
Name
:
"bar"
,
ID
:
types
.
UID
(
"fakeID"
),
},
}},
}
}
stats
,
err
:=
kubelet
.
GetContainerInfo
(
"qux_ns"
,
""
,
"foo"
,
nil
)
stats
,
err
:=
kubelet
.
GetContainerInfo
(
"qux_ns"
,
""
,
"foo"
,
nil
)
...
@@ -967,7 +1000,16 @@ func TestRunInContainer(t *testing.T) {
...
@@ -967,7 +1000,16 @@ func TestRunInContainer(t *testing.T) {
containerID
:=
"abc1234"
containerID
:=
"abc1234"
fakeRuntime
.
PodList
=
[]
*
kubecontainer
.
Pod
{
fakeRuntime
.
PodList
=
[]
*
kubecontainer
.
Pod
{
{
ID
:
"12345678"
,
Name
:
"podFoo"
,
Namespace
:
"nsFoo"
,
Containers
:
[]
*
kubecontainer
.
Container
{{
Name
:
"containerFoo"
,
ID
:
types
.
UID
(
containerID
)}}},
{
ID
:
"12345678"
,
Name
:
"podFoo"
,
Namespace
:
"nsFoo"
,
Containers
:
[]
*
kubecontainer
.
Container
{
{
Name
:
"containerFoo"
,
ID
:
types
.
UID
(
containerID
),
},
},
},
}
}
cmd
:=
[]
string
{
"ls"
}
cmd
:=
[]
string
{
"ls"
}
_
,
err
:=
kubelet
.
RunInContainer
(
"podFoo_nsFoo"
,
""
,
"containerFoo"
,
cmd
)
_
,
err
:=
kubelet
.
RunInContainer
(
"podFoo_nsFoo"
,
""
,
"containerFoo"
,
cmd
)
...
@@ -1942,7 +1984,15 @@ func TestExecInContainerNoSuchContainer(t *testing.T) {
...
@@ -1942,7 +1984,15 @@ func TestExecInContainerNoSuchContainer(t *testing.T) {
podNamespace
:=
"nsFoo"
podNamespace
:=
"nsFoo"
containerID
:=
"containerFoo"
containerID
:=
"containerFoo"
fakeRuntime
.
PodList
=
[]
*
kubecontainer
.
Pod
{
fakeRuntime
.
PodList
=
[]
*
kubecontainer
.
Pod
{
{
ID
:
"12345678"
,
Name
:
podName
,
Namespace
:
podNamespace
,
Containers
:
[]
*
kubecontainer
.
Container
{{
Name
:
"bar"
,
ID
:
"barID"
}}},
{
ID
:
"12345678"
,
Name
:
podName
,
Namespace
:
podNamespace
,
Containers
:
[]
*
kubecontainer
.
Container
{
{
Name
:
"bar"
,
ID
:
"barID"
},
},
},
}
}
err
:=
kubelet
.
ExecInContainer
(
err
:=
kubelet
.
ExecInContainer
(
...
@@ -1997,8 +2047,16 @@ func TestExecInContainer(t *testing.T) {
...
@@ -1997,8 +2047,16 @@ func TestExecInContainer(t *testing.T) {
stderr
:=
&
fakeReadWriteCloser
{}
stderr
:=
&
fakeReadWriteCloser
{}
tty
:=
true
tty
:=
true
fakeRuntime
.
PodList
=
[]
*
kubecontainer
.
Pod
{
fakeRuntime
.
PodList
=
[]
*
kubecontainer
.
Pod
{
{
ID
:
"12345678"
,
Name
:
podName
,
Namespace
:
podNamespace
,
Containers
:
[]
*
kubecontainer
.
Container
{
{
{
Name
:
containerID
,
ID
:
types
.
UID
(
containerID
)}}},
ID
:
"12345678"
,
Name
:
podName
,
Namespace
:
podNamespace
,
Containers
:
[]
*
kubecontainer
.
Container
{
{
Name
:
containerID
,
ID
:
types
.
UID
(
containerID
),
},
},
},
}
}
err
:=
kubelet
.
ExecInContainer
(
err
:=
kubelet
.
ExecInContainer
(
...
@@ -2076,7 +2134,15 @@ func TestPortForwardNoSuchContainer(t *testing.T) {
...
@@ -2076,7 +2134,15 @@ func TestPortForwardNoSuchContainer(t *testing.T) {
var
port
uint16
=
5000
var
port
uint16
=
5000
fakeRuntime
.
PodList
=
[]
*
kubecontainer
.
Pod
{
fakeRuntime
.
PodList
=
[]
*
kubecontainer
.
Pod
{
{
ID
:
"12345678"
,
Name
:
podName
,
Namespace
:
podNamespace
,
Containers
:
[]
*
kubecontainer
.
Container
{{
Name
:
"bar"
,
ID
:
"barID"
}}},
{
ID
:
"12345678"
,
Name
:
podName
,
Namespace
:
podNamespace
,
Containers
:
[]
*
kubecontainer
.
Container
{
{
Name
:
"bar"
,
ID
:
"barID"
},
},
},
}
}
err
:=
kubelet
.
PortForward
(
err
:=
kubelet
.
PortForward
(
...
@@ -2898,8 +2964,17 @@ func TestGetContainerInfoForMirrorPods(t *testing.T) {
...
@@ -2898,8 +2964,17 @@ func TestGetContainerInfoForMirrorPods(t *testing.T) {
kubelet
:=
testKubelet
.
kubelet
kubelet
:=
testKubelet
.
kubelet
fakeRuntime
.
PodList
=
[]
*
kubecontainer
.
Pod
{
fakeRuntime
.
PodList
=
[]
*
kubecontainer
.
Pod
{
{
ID
:
"1234"
,
Name
:
"qux"
,
Namespace
:
"ns"
,
Containers
:
[]
*
kubecontainer
.
Container
{
{
{
Name
:
"foo"
,
ID
:
types
.
UID
(
containerID
)}}},
ID
:
"1234"
,
Name
:
"qux"
,
Namespace
:
"ns"
,
Containers
:
[]
*
kubecontainer
.
Container
{
{
Name
:
"foo"
,
ID
:
types
.
UID
(
containerID
),
},
},
},
}
}
kubelet
.
podManager
.
SetPods
(
pods
)
kubelet
.
podManager
.
SetPods
(
pods
)
...
@@ -3265,7 +3340,14 @@ func TestSyncPodsSetStatusToFailedForPodsThatRunTooLong(t *testing.T) {
...
@@ -3265,7 +3340,14 @@ func TestSyncPodsSetStatusToFailedForPodsThatRunTooLong(t *testing.T) {
}
}
fakeRuntime
.
PodList
=
[]
*
kubecontainer
.
Pod
{
fakeRuntime
.
PodList
=
[]
*
kubecontainer
.
Pod
{
{
ID
:
"12345678"
,
Name
:
"bar"
,
Namespace
:
"new"
,
Containers
:
[]
*
kubecontainer
.
Container
{{
Name
:
"foo"
}}},
{
ID
:
"12345678"
,
Name
:
"bar"
,
Namespace
:
"new"
,
Containers
:
[]
*
kubecontainer
.
Container
{
{
Name
:
"foo"
},
},
},
}
}
// Let the pod worker sets the status to fail after this sync.
// Let the pod worker sets the status to fail after this sync.
...
@@ -3313,7 +3395,14 @@ func TestSyncPodsDoesNotSetPodsThatDidNotRunTooLongToFailed(t *testing.T) {
...
@@ -3313,7 +3395,14 @@ func TestSyncPodsDoesNotSetPodsThatDidNotRunTooLongToFailed(t *testing.T) {
}
}
fakeRuntime
.
PodList
=
[]
*
kubecontainer
.
Pod
{
fakeRuntime
.
PodList
=
[]
*
kubecontainer
.
Pod
{
{
ID
:
"12345678"
,
Name
:
"bar"
,
Namespace
:
"new"
,
Containers
:
[]
*
kubecontainer
.
Container
{{
Name
:
"foo"
}}},
{
ID
:
"12345678"
,
Name
:
"bar"
,
Namespace
:
"new"
,
Containers
:
[]
*
kubecontainer
.
Container
{
{
Name
:
"foo"
},
},
},
}
}
kubelet
.
podManager
.
SetPods
(
pods
)
kubelet
.
podManager
.
SetPods
(
pods
)
...
...
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