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
df0f4bd4
Commit
df0f4bd4
authored
Jan 09, 2017
by
Mike Danese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add table test for should run predicates
parent
c518e890
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
116 additions
and
0 deletions
+116
-0
daemoncontroller_test.go
pkg/controller/daemon/daemoncontroller_test.go
+116
-0
No files found.
pkg/controller/daemon/daemoncontroller_test.go
View file @
df0f4bd4
...
...
@@ -651,3 +651,119 @@ func TestObservedGeneration(t *testing.T) {
t
.
Errorf
(
"Wrong ObservedGeneration for daemon %s in status. Expected %d, got %d"
,
updated
.
Name
,
daemon
.
Generation
,
updated
.
Status
.
ObservedGeneration
)
}
}
func
TestNodeShouldRunDaemonPod
(
t
*
testing
.
T
)
{
cases
:=
[]
struct
{
podsOnNode
[]
*
v1
.
Pod
ds
*
extensions
.
DaemonSet
wantToRun
,
shouldSchedule
,
shouldContinueRunning
bool
err
error
}{
{
ds
:
&
extensions
.
DaemonSet
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
&
metav1
.
LabelSelector
{
MatchLabels
:
simpleDaemonSetLabel
},
Template
:
v1
.
PodTemplateSpec
{
ObjectMeta
:
v1
.
ObjectMeta
{
Labels
:
simpleDaemonSetLabel
,
},
Spec
:
resourcePodSpec
(
""
,
"50M"
,
"0.5"
),
},
},
},
wantToRun
:
true
,
shouldSchedule
:
true
,
shouldContinueRunning
:
true
,
},
{
ds
:
&
extensions
.
DaemonSet
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
&
metav1
.
LabelSelector
{
MatchLabels
:
simpleDaemonSetLabel
},
Template
:
v1
.
PodTemplateSpec
{
ObjectMeta
:
v1
.
ObjectMeta
{
Labels
:
simpleDaemonSetLabel
,
},
Spec
:
resourcePodSpec
(
""
,
"200M"
,
"0.5"
),
},
},
},
wantToRun
:
true
,
shouldSchedule
:
false
,
shouldContinueRunning
:
true
,
},
{
ds
:
&
extensions
.
DaemonSet
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
&
metav1
.
LabelSelector
{
MatchLabels
:
simpleDaemonSetLabel
},
Template
:
v1
.
PodTemplateSpec
{
ObjectMeta
:
v1
.
ObjectMeta
{
Labels
:
simpleDaemonSetLabel
,
},
Spec
:
resourcePodSpec
(
"other-node"
,
"50M"
,
"0.5"
),
},
},
},
wantToRun
:
false
,
shouldSchedule
:
false
,
shouldContinueRunning
:
false
,
},
{
podsOnNode
:
[]
*
v1
.
Pod
{
{
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{{
Ports
:
[]
v1
.
ContainerPort
{{
HostPort
:
666
,
}},
}},
},
},
},
ds
:
&
extensions
.
DaemonSet
{
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
&
metav1
.
LabelSelector
{
MatchLabels
:
simpleDaemonSetLabel
},
Template
:
v1
.
PodTemplateSpec
{
ObjectMeta
:
v1
.
ObjectMeta
{
Labels
:
simpleDaemonSetLabel
,
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{{
Ports
:
[]
v1
.
ContainerPort
{{
HostPort
:
666
,
}},
}},
},
},
},
},
wantToRun
:
false
,
shouldSchedule
:
false
,
shouldContinueRunning
:
false
,
},
}
for
i
,
c
:=
range
cases
{
node
:=
newNode
(
"test-node"
,
nil
)
node
.
Status
.
Allocatable
=
allocatableResources
(
"100M"
,
"1"
)
manager
,
_
,
_
:=
newTestController
()
manager
.
nodeStore
.
Store
.
Add
(
node
)
for
_
,
p
:=
range
c
.
podsOnNode
{
manager
.
podStore
.
Indexer
.
Add
(
p
)
p
.
Spec
.
NodeName
=
"test-node"
}
wantToRun
,
shouldSchedule
,
shouldContinueRunning
,
err
:=
manager
.
nodeShouldRunDaemonPod
(
node
,
c
.
ds
)
if
wantToRun
!=
c
.
wantToRun
{
t
.
Errorf
(
"[%v] expected wantToRun: %v, got: %v"
,
i
,
c
.
wantToRun
,
wantToRun
)
}
if
shouldSchedule
!=
c
.
shouldSchedule
{
t
.
Errorf
(
"[%v] expected shouldSchedule: %v, got: %v"
,
i
,
c
.
shouldSchedule
,
shouldSchedule
)
}
if
shouldContinueRunning
!=
c
.
shouldContinueRunning
{
t
.
Errorf
(
"[%v] expected shouldContinueRunning: %v, got: %v"
,
i
,
c
.
shouldContinueRunning
,
shouldContinueRunning
)
}
if
err
!=
c
.
err
{
t
.
Errorf
(
"[%v] expected err: %v, got: %v"
,
i
,
c
.
err
,
err
)
}
}
}
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