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
98880edb
Commit
98880edb
authored
Aug 10, 2018
by
tanshanshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ns for pod in integration test
parent
a1b3133b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
13 deletions
+13
-13
preemption_test.go
test/integration/scheduler/preemption_test.go
+11
-11
util.go
test/integration/scheduler/util.go
+2
-2
No files found.
test/integration/scheduler/preemption_test.go
View file @
98880edb
...
@@ -52,7 +52,7 @@ func waitForNominatedNodeNameWithTimeout(cs clientset.Interface, pod *v1.Pod, ti
...
@@ -52,7 +52,7 @@ func waitForNominatedNodeNameWithTimeout(cs clientset.Interface, pod *v1.Pod, ti
}
}
return
false
,
err
return
false
,
err
});
err
!=
nil
{
});
err
!=
nil
{
return
fmt
.
Errorf
(
"Pod %v
annotation did not get set: %v"
,
pod
.
Name
,
err
)
return
fmt
.
Errorf
(
"Pod %v
/%v annotation did not get set: %v"
,
pod
.
Namespace
,
pod
.
Name
,
err
)
}
}
return
nil
return
nil
}
}
...
@@ -268,7 +268,7 @@ func TestPreemption(t *testing.T) {
...
@@ -268,7 +268,7 @@ func TestPreemption(t *testing.T) {
for
i
,
p
:=
range
pods
{
for
i
,
p
:=
range
pods
{
if
_
,
found
:=
test
.
preemptedPodIndexes
[
i
];
found
{
if
_
,
found
:=
test
.
preemptedPodIndexes
[
i
];
found
{
if
err
=
wait
.
Poll
(
time
.
Second
,
wait
.
ForeverTestTimeout
,
podIsGettingEvicted
(
cs
,
p
.
Namespace
,
p
.
Name
));
err
!=
nil
{
if
err
=
wait
.
Poll
(
time
.
Second
,
wait
.
ForeverTestTimeout
,
podIsGettingEvicted
(
cs
,
p
.
Namespace
,
p
.
Name
));
err
!=
nil
{
t
.
Errorf
(
"Test [%v]: Pod %v
is not getting evicted."
,
test
.
description
,
p
.
Name
)
t
.
Errorf
(
"Test [%v]: Pod %v
/%v is not getting evicted."
,
test
.
description
,
p
.
Namespace
,
p
.
Name
)
}
}
}
else
{
}
else
{
if
p
.
DeletionTimestamp
!=
nil
{
if
p
.
DeletionTimestamp
!=
nil
{
...
@@ -450,7 +450,7 @@ func TestPreemptionStarvation(t *testing.T) {
...
@@ -450,7 +450,7 @@ func TestPreemptionStarvation(t *testing.T) {
// make sure that runningPods are all scheduled.
// make sure that runningPods are all scheduled.
for
_
,
p
:=
range
runningPods
{
for
_
,
p
:=
range
runningPods
{
if
err
:=
waitForPodToSchedule
(
cs
,
p
);
err
!=
nil
{
if
err
:=
waitForPodToSchedule
(
cs
,
p
);
err
!=
nil
{
t
.
Fatalf
(
"Pod %v
didn't get scheduled: %v"
,
p
.
Name
,
err
)
t
.
Fatalf
(
"Pod %v
/%v didn't get scheduled: %v"
,
p
.
Namespace
,
p
.
Name
,
err
)
}
}
}
}
// Create pending pods.
// Create pending pods.
...
@@ -464,7 +464,7 @@ func TestPreemptionStarvation(t *testing.T) {
...
@@ -464,7 +464,7 @@ func TestPreemptionStarvation(t *testing.T) {
for
_
,
p
:=
range
pendingPods
{
for
_
,
p
:=
range
pendingPods
{
if
err
:=
wait
.
Poll
(
100
*
time
.
Millisecond
,
wait
.
ForeverTestTimeout
,
if
err
:=
wait
.
Poll
(
100
*
time
.
Millisecond
,
wait
.
ForeverTestTimeout
,
podUnschedulable
(
cs
,
p
.
Namespace
,
p
.
Name
));
err
!=
nil
{
podUnschedulable
(
cs
,
p
.
Namespace
,
p
.
Name
));
err
!=
nil
{
t
.
Errorf
(
"Pod %v
didn't get marked unschedulable: %v"
,
p
.
Name
,
err
)
t
.
Errorf
(
"Pod %v
/%v didn't get marked unschedulable: %v"
,
p
.
Namespace
,
p
.
Name
,
err
)
}
}
}
}
// Create the preemptor.
// Create the preemptor.
...
@@ -474,7 +474,7 @@ func TestPreemptionStarvation(t *testing.T) {
...
@@ -474,7 +474,7 @@ func TestPreemptionStarvation(t *testing.T) {
}
}
// Check that the preemptor pod gets the annotation for nominated node name.
// Check that the preemptor pod gets the annotation for nominated node name.
if
err
:=
waitForNominatedNodeName
(
cs
,
preemptor
);
err
!=
nil
{
if
err
:=
waitForNominatedNodeName
(
cs
,
preemptor
);
err
!=
nil
{
t
.
Errorf
(
"Test [%v]: NominatedNodeName annotation was not set for pod %v
: %v"
,
test
.
description
,
preemptor
.
Name
,
err
)
t
.
Errorf
(
"Test [%v]: NominatedNodeName annotation was not set for pod %v
/%v: %v"
,
test
.
description
,
preemptor
.
Namespace
,
preemptor
.
Name
,
err
)
}
}
// Make sure that preemptor is scheduled after preemptions.
// Make sure that preemptor is scheduled after preemptions.
if
err
:=
waitForPodToScheduleWithTimeout
(
cs
,
preemptor
,
60
*
time
.
Second
);
err
!=
nil
{
if
err
:=
waitForPodToScheduleWithTimeout
(
cs
,
preemptor
,
60
*
time
.
Second
);
err
!=
nil
{
...
@@ -532,7 +532,7 @@ func TestNominatedNodeCleanUp(t *testing.T) {
...
@@ -532,7 +532,7 @@ func TestNominatedNodeCleanUp(t *testing.T) {
// make sure that the pods are all scheduled.
// make sure that the pods are all scheduled.
for
_
,
p
:=
range
lowPriPods
{
for
_
,
p
:=
range
lowPriPods
{
if
err
:=
waitForPodToSchedule
(
cs
,
p
);
err
!=
nil
{
if
err
:=
waitForPodToSchedule
(
cs
,
p
);
err
!=
nil
{
t
.
Fatalf
(
"Pod %v
didn't get scheduled: %v"
,
p
.
Name
,
err
)
t
.
Fatalf
(
"Pod %v
/%v didn't get scheduled: %v"
,
p
.
Namespace
,
p
.
Name
,
err
)
}
}
}
}
// Step 2. Create a medium priority pod.
// Step 2. Create a medium priority pod.
...
@@ -551,7 +551,7 @@ func TestNominatedNodeCleanUp(t *testing.T) {
...
@@ -551,7 +551,7 @@ func TestNominatedNodeCleanUp(t *testing.T) {
}
}
// Step 3. Check that nominated node name of the medium priority pod is set.
// Step 3. Check that nominated node name of the medium priority pod is set.
if
err
:=
waitForNominatedNodeName
(
cs
,
medPriPod
);
err
!=
nil
{
if
err
:=
waitForNominatedNodeName
(
cs
,
medPriPod
);
err
!=
nil
{
t
.
Errorf
(
"NominatedNodeName annotation was not set for pod %v
: %v"
,
medPriPod
.
Name
,
err
)
t
.
Errorf
(
"NominatedNodeName annotation was not set for pod %v
/%v: %v"
,
medPriPod
.
Namespace
,
medPriPod
.
Name
,
err
)
}
}
// Step 4. Create a high priority pod.
// Step 4. Create a high priority pod.
podConf
=
initPausePod
(
cs
,
&
pausePodConfig
{
podConf
=
initPausePod
(
cs
,
&
pausePodConfig
{
...
@@ -569,7 +569,7 @@ func TestNominatedNodeCleanUp(t *testing.T) {
...
@@ -569,7 +569,7 @@ func TestNominatedNodeCleanUp(t *testing.T) {
}
}
// Step 5. Check that nominated node name of the high priority pod is set.
// Step 5. Check that nominated node name of the high priority pod is set.
if
err
:=
waitForNominatedNodeName
(
cs
,
highPriPod
);
err
!=
nil
{
if
err
:=
waitForNominatedNodeName
(
cs
,
highPriPod
);
err
!=
nil
{
t
.
Errorf
(
"NominatedNodeName annotation was not set for pod %v
: %v"
,
medPriPod
.
Name
,
err
)
t
.
Errorf
(
"NominatedNodeName annotation was not set for pod %v
/%v: %v"
,
medPriPod
.
Namespace
,
medPriPod
.
Name
,
err
)
}
}
// And the nominated node name of the medium priority pod is cleared.
// And the nominated node name of the medium priority pod is cleared.
if
err
:=
wait
.
Poll
(
100
*
time
.
Millisecond
,
wait
.
ForeverTestTimeout
,
func
()
(
bool
,
error
)
{
if
err
:=
wait
.
Poll
(
100
*
time
.
Millisecond
,
wait
.
ForeverTestTimeout
,
func
()
(
bool
,
error
)
{
...
@@ -856,18 +856,18 @@ func TestPDBInPreemption(t *testing.T) {
...
@@ -856,18 +856,18 @@ func TestPDBInPreemption(t *testing.T) {
for
i
,
p
:=
range
pods
{
for
i
,
p
:=
range
pods
{
if
_
,
found
:=
test
.
preemptedPodIndexes
[
i
];
found
{
if
_
,
found
:=
test
.
preemptedPodIndexes
[
i
];
found
{
if
err
=
wait
.
Poll
(
time
.
Second
,
wait
.
ForeverTestTimeout
,
podIsGettingEvicted
(
cs
,
p
.
Namespace
,
p
.
Name
));
err
!=
nil
{
if
err
=
wait
.
Poll
(
time
.
Second
,
wait
.
ForeverTestTimeout
,
podIsGettingEvicted
(
cs
,
p
.
Namespace
,
p
.
Name
));
err
!=
nil
{
t
.
Errorf
(
"Test [%v]: Pod %v
is not getting evicted."
,
test
.
description
,
p
.
Name
)
t
.
Errorf
(
"Test [%v]: Pod %v
/%v is not getting evicted."
,
test
.
description
,
p
.
Namespace
,
p
.
Name
)
}
}
}
else
{
}
else
{
if
p
.
DeletionTimestamp
!=
nil
{
if
p
.
DeletionTimestamp
!=
nil
{
t
.
Errorf
(
"Test [%v]: Didn't expect pod %v
to get preempted."
,
test
.
description
,
p
.
Name
)
t
.
Errorf
(
"Test [%v]: Didn't expect pod %v
/%v to get preempted."
,
test
.
description
,
p
.
Namespace
,
p
.
Name
)
}
}
}
}
}
}
// Also check that the preemptor pod gets the annotation for nominated node name.
// Also check that the preemptor pod gets the annotation for nominated node name.
if
len
(
test
.
preemptedPodIndexes
)
>
0
{
if
len
(
test
.
preemptedPodIndexes
)
>
0
{
if
err
:=
waitForNominatedNodeName
(
cs
,
preemptor
);
err
!=
nil
{
if
err
:=
waitForNominatedNodeName
(
cs
,
preemptor
);
err
!=
nil
{
t
.
Errorf
(
"Test [%v]: NominatedNodeName annotation was not set for pod %v
: %v"
,
test
.
description
,
preemptor
.
Name
,
err
)
t
.
Errorf
(
"Test [%v]: NominatedNodeName annotation was not set for pod %v
/%v: %v"
,
test
.
description
,
preemptor
.
Namespace
,
preemptor
.
Name
,
err
)
}
}
}
}
...
...
test/integration/scheduler/util.go
View file @
98880edb
...
@@ -483,10 +483,10 @@ func runPausePod(cs clientset.Interface, pod *v1.Pod) (*v1.Pod, error) {
...
@@ -483,10 +483,10 @@ func runPausePod(cs clientset.Interface, pod *v1.Pod) (*v1.Pod, error) {
return
nil
,
fmt
.
Errorf
(
"Error creating pause pod: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"Error creating pause pod: %v"
,
err
)
}
}
if
err
=
waitForPodToSchedule
(
cs
,
pod
);
err
!=
nil
{
if
err
=
waitForPodToSchedule
(
cs
,
pod
);
err
!=
nil
{
return
pod
,
fmt
.
Errorf
(
"Pod %v
didn't schedule successfully. Error: %v"
,
pod
.
Name
,
err
)
return
pod
,
fmt
.
Errorf
(
"Pod %v
/%v didn't schedule successfully. Error: %v"
,
pod
.
Namespace
,
pod
.
Name
,
err
)
}
}
if
pod
,
err
=
cs
.
CoreV1
()
.
Pods
(
pod
.
Namespace
)
.
Get
(
pod
.
Name
,
metav1
.
GetOptions
{});
err
!=
nil
{
if
pod
,
err
=
cs
.
CoreV1
()
.
Pods
(
pod
.
Namespace
)
.
Get
(
pod
.
Name
,
metav1
.
GetOptions
{});
err
!=
nil
{
return
pod
,
fmt
.
Errorf
(
"Error getting pod %v
info: %v"
,
pod
.
Name
,
err
)
return
pod
,
fmt
.
Errorf
(
"Error getting pod %v
/%v info: %v"
,
pod
.
Namespace
,
pod
.
Name
,
err
)
}
}
return
pod
,
nil
return
pod
,
nil
}
}
...
...
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