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
f5840695
Commit
f5840695
authored
Mar 24, 2015
by
Victor Marmol
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5894 from yujuhong/fix_order
Fix flakey TestGetSetPods
parents
a9c9d27f
ff3d36ed
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
16 deletions
+25
-16
pod_manager_test.go
pkg/kubelet/pod_manager_test.go
+25
-16
No files found.
pkg/kubelet/pod_manager_test.go
View file @
f5840695
...
@@ -21,7 +21,6 @@ import (
...
@@ -21,7 +21,6 @@ import (
"testing"
"testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
kubecontainer
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
)
)
// Stub out mirror client for testing purpose.
// Stub out mirror client for testing purpose.
...
@@ -69,26 +68,36 @@ func TestGetSetPods(t *testing.T) {
...
@@ -69,26 +68,36 @@ func TestGetSetPods(t *testing.T) {
updates
:=
append
(
expectedPods
,
mirrorPod
)
updates
:=
append
(
expectedPods
,
mirrorPod
)
podManager
,
_
:=
newFakePodManager
()
podManager
,
_
:=
newFakePodManager
()
podManager
.
SetPods
(
updates
)
podManager
.
SetPods
(
updates
)
// Tests that all regular pods are recorded corrrectly.
actualPods
:=
podManager
.
GetPods
()
actualPods
:=
podManager
.
GetPods
()
if
!
reflect
.
DeepEqual
(
expectedPods
,
actualPods
)
{
if
len
(
actualPods
)
!=
len
(
expectedPods
)
{
t
.
Errorf
(
"pods are not set correctly; expected %#v, got %#v"
,
expectedPods
,
actualPods
)
t
.
Errorf
(
"expected %d pods, got %d pods; expected pods %#v, got pods %#v"
,
len
(
expectedPods
),
len
(
actualPods
),
}
expectedPods
,
actualPods
)
actualPod
,
ok
:=
podManager
.
mirrorPodByUID
[
mirrorPod
.
UID
]
if
!
ok
{
t
.
Errorf
(
"mirror pod %q is not found in the mirror pod map by UID"
,
mirrorPod
.
UID
)
}
else
if
!
reflect
.
DeepEqual
(
&
mirrorPod
,
actualPod
)
{
t
.
Errorf
(
"mirror pod is recorded incorrectly. expect: %v, got: %v"
,
mirrorPod
,
actualPod
)
}
}
actualPod
,
ok
=
podManager
.
mirrorPodByFullName
[
kubecontainer
.
GetPodFullName
(
&
mirrorPod
)]
for
_
,
expected
:=
range
expectedPods
{
if
!
ok
{
found
:=
false
t
.
Errorf
(
"mirror pod %q is not found in the mirror pod map by full name"
,
kubecontainer
.
GetPodFullName
(
&
mirrorPod
))
for
_
,
actual
:=
range
actualPods
{
}
else
if
!
reflect
.
DeepEqual
(
&
mirrorPod
,
actualPod
)
{
if
actual
.
UID
==
expected
.
UID
{
t
.
Errorf
(
"mirror pod is recorded incorrectly. expect: %v, got: %v"
,
mirrorPod
,
actualPod
)
if
!
reflect
.
DeepEqual
(
&
expected
,
&
actual
)
{
t
.
Errorf
(
"pod was recorded incorrectly. expect: %#v, got: %#v"
,
expected
,
actual
)
}
found
=
true
break
}
}
if
!
found
{
t
.
Errorf
(
"pod %q was not found in %#v"
,
expected
.
UID
,
actualPods
)
}
}
}
// Tests UID translation works as expected.
if
uid
:=
podManager
.
TranslatePodUID
(
mirrorPod
.
UID
);
uid
!=
staticPod
.
UID
{
if
uid
:=
podManager
.
TranslatePodUID
(
mirrorPod
.
UID
);
uid
!=
staticPod
.
UID
{
t
.
Errorf
(
"unable to translate UID %q to the static POD's UID %q; %#v"
,
mirrorPod
.
UID
,
staticPod
.
UID
,
podManager
.
mirrorPodByUID
)
t
.
Errorf
(
"unable to translate UID %q to the static POD's UID %q; %#v"
,
mirrorPod
.
UID
,
staticPod
.
UID
,
podManager
.
mirrorPodByUID
)
}
}
actualPod
,
ok
=
podManager
.
GetPodByFullName
(
"bar_default"
)
// Test the basic Get methods.
actualPod
,
ok
:=
podManager
.
GetPodByFullName
(
"bar_default"
)
if
!
ok
||
!
reflect
.
DeepEqual
(
actualPod
,
&
staticPod
)
{
if
!
ok
||
!
reflect
.
DeepEqual
(
actualPod
,
&
staticPod
)
{
t
.
Errorf
(
"unable to get pod by full name; expected: %#v, got: %#v"
,
staticPod
,
actualPod
)
t
.
Errorf
(
"unable to get pod by full name; expected: %#v, got: %#v"
,
staticPod
,
actualPod
)
}
}
...
...
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