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
42c6d716
Commit
42c6d716
authored
Oct 06, 2015
by
gmarek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for number of scheduled, not running nodes in scheduler_predicates test
parent
107d0f6d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
22 deletions
+25
-22
scheduler_predicates.go
test/e2e/scheduler_predicates.go
+25
-22
No files found.
test/e2e/scheduler_predicates.go
View file @
42c6d716
...
...
@@ -32,13 +32,13 @@ import (
.
"github.com/onsi/gomega"
)
// Returns a number of currently
running and not running
Pods.
func
getPods
Numbers
(
pods
*
api
.
PodList
)
(
runningPods
,
notRunning
Pods
int
)
{
// Returns a number of currently
scheduled and not scheduled
Pods.
func
getPods
ScheduledNumbers
(
pods
*
api
.
PodList
)
(
scheduledPods
,
notScheduled
Pods
int
)
{
for
_
,
pod
:=
range
pods
.
Items
{
if
pod
.
S
tatus
.
Phase
==
api
.
PodRunning
{
running
Pods
+=
1
if
pod
.
S
pec
.
NodeName
!=
""
{
scheduled
Pods
+=
1
}
else
{
not
Running
Pods
+=
1
not
Scheduled
Pods
+=
1
}
}
return
...
...
@@ -49,7 +49,7 @@ func getPodsNumbers(pods *api.PodList) (runningPods, notRunningPods int) {
func
startPods
(
c
*
client
.
Client
,
replicas
int
,
ns
string
,
podNamePrefix
string
,
pod
api
.
Pod
)
{
allPods
,
err
:=
c
.
Pods
(
api
.
NamespaceAll
)
.
List
(
labels
.
Everything
(),
fields
.
Everything
())
expectNoError
(
err
)
pods
RunningBefore
,
_
:=
getPods
Numbers
(
allPods
)
pods
ScheduledBefore
,
_
:=
getPodsScheduled
Numbers
(
allPods
)
for
i
:=
0
;
i
<
replicas
;
i
++
{
podName
:=
fmt
.
Sprintf
(
"%v-%v"
,
podNamePrefix
,
i
)
...
...
@@ -66,25 +66,25 @@ func startPods(c *client.Client, replicas int, ns string, podNamePrefix string,
// completely broken vs. running slowly.
timeout
:=
10
*
time
.
Minute
startTime
:=
time
.
Now
()
currently
Running
Pods
:=
0
for
pods
RunningBefore
+
replicas
!=
currentlyRunning
Pods
{
currently
Scheduled
Pods
:=
0
for
pods
ScheduledBefore
+
replicas
!=
currentlyScheduled
Pods
{
allPods
,
err
:=
c
.
Pods
(
api
.
NamespaceAll
)
.
List
(
labels
.
Everything
(),
fields
.
Everything
())
expectNoError
(
err
)
running
Pods
:=
0
scheduled
Pods
:=
0
for
_
,
pod
:=
range
allPods
.
Items
{
if
pod
.
S
tatus
.
Phase
==
api
.
PodRunning
{
running
Pods
+=
1
if
pod
.
S
pec
.
NodeName
!=
""
{
scheduled
Pods
+=
1
}
}
currently
RunningPods
=
running
Pods
Logf
(
"%v pods running"
,
currently
Running
Pods
)
currently
ScheduledPods
=
scheduled
Pods
Logf
(
"%v pods running"
,
currently
Scheduled
Pods
)
if
startTime
.
Add
(
timeout
)
.
Before
(
time
.
Now
())
{
Logf
(
"Timed out after %v waiting for pods to start running."
,
timeout
)
break
}
time
.
Sleep
(
5
*
time
.
Second
)
}
Expect
(
currently
RunningPods
)
.
To
(
Equal
(
podsRunning
Before
+
replicas
))
Expect
(
currently
ScheduledPods
)
.
To
(
Equal
(
podsScheduled
Before
+
replicas
))
}
func
getRequestedCPU
(
pod
api
.
Pod
)
int64
{
...
...
@@ -95,10 +95,10 @@ func getRequestedCPU(pod api.Pod) int64 {
return
result
}
func
verifyResult
(
c
*
client
.
Client
,
podName
string
,
ns
string
,
oldNot
Running
int
)
{
func
verifyResult
(
c
*
client
.
Client
,
podName
string
,
ns
string
,
oldNot
Scheduled
int
)
{
allPods
,
err
:=
c
.
Pods
(
api
.
NamespaceAll
)
.
List
(
labels
.
Everything
(),
fields
.
Everything
())
expectNoError
(
err
)
_
,
not
RunningPods
:=
getPods
Numbers
(
allPods
)
_
,
not
ScheduledPods
:=
getPodsScheduled
Numbers
(
allPods
)
schedEvents
,
err
:=
c
.
Events
(
ns
)
.
List
(
labels
.
Everything
(),
...
...
@@ -121,7 +121,7 @@ func verifyResult(c *client.Client, podName string, ns string, oldNotRunning int
}
}
Expect
(
not
RunningPods
)
.
To
(
Equal
(
1
+
oldNotRunning
),
printOnce
(
fmt
.
Sprintf
(
"Pods found in the cluster: %#v"
,
allPods
)))
Expect
(
not
ScheduledPods
)
.
To
(
Equal
(
1
+
oldNotScheduled
),
printOnce
(
fmt
.
Sprintf
(
"Pods found in the cluster: %#v"
,
allPods
)))
Expect
(
schedEvents
.
Items
)
.
ToNot
(
BeEmpty
(),
printOnce
(
fmt
.
Sprintf
(
"Pods found in the cluster: %#v"
,
allPods
)))
}
...
...
@@ -147,6 +147,9 @@ var _ = Describe("SchedulerPredicates", func() {
framework
.
beforeEach
()
c
=
framework
.
Client
ns
=
framework
.
Namespace
.
Name
var
err
error
nodeList
,
err
=
c
.
Nodes
()
.
List
(
labels
.
Everything
(),
fields
.
Everything
())
expectNoError
(
err
)
})
AfterEach
(
func
()
{
...
...
@@ -174,8 +177,8 @@ var _ = Describe("SchedulerPredicates", func() {
allPods
,
err
:=
c
.
Pods
(
api
.
NamespaceAll
)
.
List
(
labels
.
Everything
(),
fields
.
Everything
())
expectNoError
(
err
)
currently
RunningPods
,
currentlyDeadPods
:=
getPods
Numbers
(
allPods
)
podsNeededForSaturation
:=
int
(
totalPodCapacity
)
-
currently
Running
Pods
currently
ScheduledPods
,
currentlyNotScheduledPods
:=
getPodsScheduled
Numbers
(
allPods
)
podsNeededForSaturation
:=
int
(
totalPodCapacity
)
-
currently
Scheduled
Pods
By
(
fmt
.
Sprintf
(
"Starting additional %v Pods to fully saturate the cluster max pods and trying to start another one"
,
podsNeededForSaturation
))
...
...
@@ -221,7 +224,7 @@ var _ = Describe("SchedulerPredicates", func() {
Logf
(
"Sleeping 10 seconds and crossing our fingers that scheduler will run in that time."
)
time
.
Sleep
(
10
*
time
.
Second
)
verifyResult
(
c
,
podName
,
ns
,
currently
Dea
dPods
)
verifyResult
(
c
,
podName
,
ns
,
currently
NotSchedule
dPods
)
cleanupPods
(
c
,
ns
)
})
...
...
@@ -323,7 +326,7 @@ var _ = Describe("SchedulerPredicates", func() {
allPods
,
err
:=
c
.
Pods
(
api
.
NamespaceAll
)
.
List
(
labels
.
Everything
(),
fields
.
Everything
())
expectNoError
(
err
)
_
,
currently
DeadPods
:=
getPods
Numbers
(
allPods
)
_
,
currently
NotScheduledPods
:=
getPodsScheduled
Numbers
(
allPods
)
_
,
err
=
c
.
Pods
(
ns
)
.
Create
(
&
api
.
Pod
{
TypeMeta
:
unversioned
.
TypeMeta
{
...
...
@@ -351,7 +354,7 @@ var _ = Describe("SchedulerPredicates", func() {
Logf
(
"Sleeping 10 seconds and crossing our fingers that scheduler will run in that time."
)
time
.
Sleep
(
10
*
time
.
Second
)
verifyResult
(
c
,
podName
,
ns
,
currently
Dea
dPods
)
verifyResult
(
c
,
podName
,
ns
,
currently
NotSchedule
dPods
)
cleanupPods
(
c
,
ns
)
})
...
...
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