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
5257dfcd
Commit
5257dfcd
authored
May 07, 2018
by
Da K. Ma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup Pods in TestNominatedNodeCleanUp.
Signed-off-by:
Da K. Ma
<
klaus1982.cn@gmail.com
>
parent
bac31d69
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
preemption_test.go
test/integration/scheduler/preemption_test.go
+4
-0
util.go
test/integration/scheduler/util.go
+26
-0
No files found.
test/integration/scheduler/preemption_test.go
View file @
5257dfcd
...
@@ -506,7 +506,11 @@ func TestNominatedNodeCleanUp(t *testing.T) {
...
@@ -506,7 +506,11 @@ func TestNominatedNodeCleanUp(t *testing.T) {
// Initialize scheduler.
// Initialize scheduler.
context
:=
initTest
(
t
,
"preemption"
)
context
:=
initTest
(
t
,
"preemption"
)
defer
cleanupTest
(
t
,
context
)
defer
cleanupTest
(
t
,
context
)
cs
:=
context
.
clientSet
cs
:=
context
.
clientSet
defer
cleanupPodsInNamespace
(
cs
,
t
,
context
.
ns
.
Name
)
// Create a node with some resources and a label.
// Create a node with some resources and a label.
nodeRes
:=
&
v1
.
ResourceList
{
nodeRes
:=
&
v1
.
ResourceList
{
v1
.
ResourcePods
:
*
resource
.
NewQuantity
(
32
,
resource
.
DecimalSI
),
v1
.
ResourcePods
:
*
resource
.
NewQuantity
(
32
,
resource
.
DecimalSI
),
...
...
test/integration/scheduler/util.go
View file @
5257dfcd
...
@@ -534,3 +534,29 @@ func cleanupPods(cs clientset.Interface, t *testing.T, pods []*v1.Pod) {
...
@@ -534,3 +534,29 @@ func cleanupPods(cs clientset.Interface, t *testing.T, pods []*v1.Pod) {
}
}
}
}
}
}
// noPodsInNamespace returns true if no pods in the given namespace.
func
noPodsInNamespace
(
c
clientset
.
Interface
,
podNamespace
string
)
wait
.
ConditionFunc
{
return
func
()
(
bool
,
error
)
{
pods
,
err
:=
c
.
CoreV1
()
.
Pods
(
podNamespace
)
.
List
(
metav1
.
ListOptions
{})
if
err
!=
nil
{
return
false
,
err
}
return
len
(
pods
.
Items
)
==
0
,
nil
}
}
// cleanupPodsInNamespace deletes the pods in the given namespace and waits for them to
// be actually deleted.
func
cleanupPodsInNamespace
(
cs
clientset
.
Interface
,
t
*
testing
.
T
,
ns
string
)
{
if
err
:=
cs
.
CoreV1
()
.
Pods
(
ns
)
.
DeleteCollection
(
nil
,
metav1
.
ListOptions
{});
err
!=
nil
{
t
.
Errorf
(
"error while listing pod in namespace %v: %v"
,
ns
,
err
)
return
}
if
err
:=
wait
.
Poll
(
time
.
Second
,
wait
.
ForeverTestTimeout
,
noPodsInNamespace
(
cs
,
ns
));
err
!=
nil
{
t
.
Errorf
(
"error while waiting for pods in namespace %v: %v"
,
ns
,
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