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