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
3c555f2c
Commit
3c555f2c
authored
Feb 15, 2017
by
gmarek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apply comments
parent
de6c9bd5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
12 deletions
+37
-12
taint_controller_test.go
pkg/controller/node/taint_controller_test.go
+37
-12
No files found.
pkg/controller/node/taint_controller_test.go
View file @
3c555f2c
...
@@ -87,7 +87,7 @@ func addTaintsToNode(node *v1.Node, key, value string, indices []int) *v1.Node {
...
@@ -87,7 +87,7 @@ func addTaintsToNode(node *v1.Node, key, value string, indices []int) *v1.Node {
}
}
type
timestampedPod
struct
{
type
timestampedPod
struct
{
name
string
name
s
[]
string
timestamp
time
.
Duration
timestamp
time
.
Duration
}
}
...
@@ -503,7 +503,7 @@ func TestUpdateNode(t *testing.T) {
...
@@ -503,7 +503,7 @@ func TestUpdateNode(t *testing.T) {
additionalSleep
:
1500
*
time
.
Millisecond
,
additionalSleep
:
1500
*
time
.
Millisecond
,
},
},
{
{
description
:
"Pod with multiple tolerations are victed when first one runs out"
,
description
:
"Pod with multiple tolerations are
e
victed when first one runs out"
,
pods
:
[]
v1
.
Pod
{
pods
:
[]
v1
.
Pod
{
{
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
...
@@ -592,8 +592,8 @@ func TestUpdateNodeWithMultiplePods(t *testing.T) {
...
@@ -592,8 +592,8 @@ func TestUpdateNodeWithMultiplePods(t *testing.T) {
oldNode
:
testutil
.
NewNode
(
"node1"
),
oldNode
:
testutil
.
NewNode
(
"node1"
),
newNode
:
addTaintsToNode
(
testutil
.
NewNode
(
"node1"
),
"testTaint1"
,
"taint1"
,
[]
int
{
1
}),
newNode
:
addTaintsToNode
(
testutil
.
NewNode
(
"node1"
),
"testTaint1"
,
"taint1"
,
[]
int
{
1
}),
expectedDeleteTimes
:
durationSlice
{
expectedDeleteTimes
:
durationSlice
{
{
"pod1"
,
0
},
{
[]
string
{
"pod1"
}
,
0
},
{
"pod2"
,
time
.
Second
},
{
[]
string
{
"pod2"
}
,
time
.
Second
},
},
},
},
},
{
{
...
@@ -606,8 +606,7 @@ func TestUpdateNodeWithMultiplePods(t *testing.T) {
...
@@ -606,8 +606,7 @@ func TestUpdateNodeWithMultiplePods(t *testing.T) {
oldNode
:
testutil
.
NewNode
(
"node1"
),
oldNode
:
testutil
.
NewNode
(
"node1"
),
newNode
:
addTaintsToNode
(
testutil
.
NewNode
(
"node1"
),
"testTaint1"
,
"taint1"
,
[]
int
{
1
,
2
}),
newNode
:
addTaintsToNode
(
testutil
.
NewNode
(
"node1"
),
"testTaint1"
,
"taint1"
,
[]
int
{
1
,
2
}),
expectedDeleteTimes
:
durationSlice
{
expectedDeleteTimes
:
durationSlice
{
{
"pod1"
,
0
},
{[]
string
{
"pod1"
,
"pod2"
,
"pod3"
},
0
},
{
"pod2"
,
0
},
},
},
},
},
}
}
...
@@ -636,20 +635,46 @@ func TestUpdateNodeWithMultiplePods(t *testing.T) {
...
@@ -636,20 +635,46 @@ func TestUpdateNodeWithMultiplePods(t *testing.T) {
sleptAlready
=
item
.
expectedDeleteTimes
[
i
]
.
timestamp
+
increment
sleptAlready
=
item
.
expectedDeleteTimes
[
i
]
.
timestamp
+
increment
}
}
podDeleted
:=
false
for
delay
,
podName
:=
range
item
.
expectedDeleteTimes
[
i
]
.
names
{
deleted
:=
false
for
_
,
action
:=
range
fakeClientset
.
Actions
()
{
deleteAction
,
ok
:=
action
.
(
clienttesting
.
DeleteActionImpl
)
if
!
ok
{
glog
.
Infof
(
"Found not-delete action with verb %v. Ignoring."
,
action
.
GetVerb
())
continue
}
if
deleteAction
.
GetResource
()
.
Resource
!=
"pods"
{
continue
}
if
podName
==
deleteAction
.
GetName
()
{
deleted
=
true
}
}
if
!
deleted
{
t
.
Errorf
(
"Failed to deleted pod %v after %v"
,
podName
,
delay
)
}
}
for
_
,
action
:=
range
fakeClientset
.
Actions
()
{
for
_
,
action
:=
range
fakeClientset
.
Actions
()
{
deleteAction
,
ok
:=
action
.
(
clienttesting
.
DeleteActionImpl
)
deleteAction
,
ok
:=
action
.
(
clienttesting
.
DeleteActionImpl
)
if
!
ok
{
if
!
ok
{
glog
.
Infof
(
"Found not-delete action with verb %v. Ignoring."
,
action
.
GetVerb
())
glog
.
Infof
(
"Found not-delete action with verb %v. Ignoring."
,
action
.
GetVerb
())
continue
continue
}
}
if
deleteAction
.
GetResource
()
.
Resource
==
"pods"
&&
deleteAction
.
GetName
()
==
item
.
expectedDeleteTimes
[
i
]
.
name
{
if
deleteAction
.
GetResource
()
.
Resource
!=
"pods"
{
podDeleted
=
true
continue
}
deletedPodName
:=
deleteAction
.
GetName
()
expected
:=
false
for
_
,
podName
:=
range
item
.
expectedDeleteTimes
[
i
]
.
names
{
if
podName
==
deletedPodName
{
expected
=
true
}
}
if
!
expected
{
t
.
Errorf
(
"Pod %v was deleted even though it shouldn't have"
,
deletedPodName
)
}
}
}
}
if
!
podDeleted
{
fakeClientset
.
ClearActions
()
t
.
Errorf
(
"%v: Unexepected test result. Expected delete %v which didn't happen"
,
item
.
description
,
item
.
expectedDeleteTimes
[
i
]
.
name
)
}
}
}
close
(
stopCh
)
close
(
stopCh
)
...
...
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