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
2a0d3fbc
Commit
2a0d3fbc
authored
Aug 04, 2016
by
gmarek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix JSON-based scheduler predicates tests
parent
5273ac9b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
72 deletions
+79
-72
scheduler_predicates.go
test/e2e/scheduler_predicates.go
+79
-7
pod-with-node-affinity.yaml
...ting-manifests/node-selection/pod-with-node-affinity.yaml
+0
-28
pod-with-pod-affinity.yaml
...sting-manifests/node-selection/pod-with-pod-affinity.yaml
+0
-37
No files found.
test/e2e/scheduler_predicates.go
View file @
2a0d3fbc
...
@@ -41,6 +41,79 @@ const minPodCPURequest int64 = 500
...
@@ -41,6 +41,79 @@ const minPodCPURequest int64 = 500
// variable set in BeforeEach, never modified afterwards
// variable set in BeforeEach, never modified afterwards
var
masterNodes
sets
.
String
var
masterNodes
sets
.
String
var
podWithNodeAffinity
=
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"with-labels"
,
Annotations
:
map
[
string
]
string
{
"scheduler.alpha.kubernetes.io/affinity"
:
`{
"nodeAffinity": {
"requiredDuringSchedulingIgnoredDuringExecution": {
"nodeSelectorTerms": [{
"matchExpressions": [{
"key": "kubernetes.io/e2e-az-name",
"operator": "In",
"values": ["e2e-az1", "e2e-az2"]
}]
}]
}
}
}`
,
"another-annotation-key"
:
"another-annotation-value"
,
},
},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{
{
Name
:
"with-labels"
,
Image
:
"gcr.io/google_containers/pause:2.0"
,
},
},
},
}
var
podWithPodAffinity
=
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"with-newlabels"
,
Annotations
:
map
[
string
]
string
{
"scheduler.alpha.kubernetes.io/affinity"
:
`{
"podAffinity": {
"requiredDuringSchedulingIgnoredDuringExecution": [{
"labelSelector": {
"matchExpressions": [{
"key": "security",
"operator": "In",
"values":["S1"]
}]
},
"topologyKey": "kubernetes.io/hostname"
}]
},
"podAntiAffinity": {
"requiredDuringSchedulingIgnoredDuringExecution": [{
"labelSelector": {
"matchExpressions": [{
"key": "security",
"operator": "In",
"values":["S2"]
}]
},
"topologyKey": "kubernetes.io/hostname"
}]
}
}`
,
"another-annotation-key"
:
"another-annotation-value"
,
},
},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{
{
Name
:
"with-newlabels"
,
Image
:
"gcr.io/google_containers/pause:2.0"
,
},
},
},
}
// Returns a number of currently scheduled and not scheduled Pods.
// Returns a number of currently scheduled and not scheduled Pods.
func
getPodsScheduled
(
pods
*
api
.
PodList
)
(
scheduledPods
,
notScheduledPods
[]
api
.
Pod
)
{
func
getPodsScheduled
(
pods
*
api
.
PodList
)
(
scheduledPods
,
notScheduledPods
[]
api
.
Pod
)
{
for
_
,
pod
:=
range
pods
.
Items
{
for
_
,
pod
:=
range
pods
.
Items
{
...
@@ -708,9 +781,9 @@ var _ = framework.KubeDescribe("SchedulerPredicates [Serial]", func() {
...
@@ -708,9 +781,9 @@ var _ = framework.KubeDescribe("SchedulerPredicates [Serial]", func() {
defer
framework
.
RemoveLabelOffNode
(
c
,
nodeName
,
k
)
defer
framework
.
RemoveLabelOffNode
(
c
,
nodeName
,
k
)
By
(
"Trying to launch a pod that with NodeAffinity setting as embedded JSON string in the annotation value."
)
By
(
"Trying to launch a pod that with NodeAffinity setting as embedded JSON string in the annotation value."
)
labelPodName
:=
"with-labels"
labelPodName
:=
podWithNodeAffinity
.
Name
testPodPath
:=
"test/e2e/testing-manifests/node-selection/pod-with-node-affinity.yaml"
pod
,
err
=
c
.
Pods
(
ns
)
.
Create
(
&
podWithNodeAffinity
)
framework
.
RunKubectlOrDie
(
"create"
,
"-f"
,
testPodPath
,
fmt
.
Sprintf
(
"--namespace=%v"
,
ns
)
)
framework
.
ExpectNoError
(
err
)
// check that pod got scheduled. We intentionally DO NOT check that the
// check that pod got scheduled. We intentionally DO NOT check that the
// pod is running because this will create a race condition with the
// pod is running because this will create a race condition with the
...
@@ -1223,10 +1296,9 @@ var _ = framework.KubeDescribe("SchedulerPredicates [Serial]", func() {
...
@@ -1223,10 +1296,9 @@ var _ = framework.KubeDescribe("SchedulerPredicates [Serial]", func() {
defer
framework
.
RemoveLabelOffNode
(
c
,
nodeName
,
k
)
defer
framework
.
RemoveLabelOffNode
(
c
,
nodeName
,
k
)
By
(
"Trying to launch a pod that with PodAffinity & PodAntiAffinity setting as embedded JSON string in the annotation value."
)
By
(
"Trying to launch a pod that with PodAffinity & PodAntiAffinity setting as embedded JSON string in the annotation value."
)
labelPodName
:=
"with-newlabels"
labelPodName
:=
podWithPodAffinity
.
Name
testPodPath
:=
"test/e2e/testing-manifests/node-selection/pod-with-pod-affinity.yaml"
pod
,
err
=
c
.
Pods
(
ns
)
.
Create
(
&
podWithPodAffinity
)
framework
.
RunKubectlOrDie
(
"create"
,
"-f"
,
testPodPath
,
fmt
.
Sprintf
(
"--namespace=%v"
,
ns
))
framework
.
ExpectNoError
(
err
)
// check that pod got scheduled. We intentionally DO NOT check that the
// check that pod got scheduled. We intentionally DO NOT check that the
// pod is running because this will create a race condition with the
// pod is running because this will create a race condition with the
// kubelet and the scheduler: the scheduler might have scheduled a pod
// kubelet and the scheduler: the scheduler might have scheduled a pod
...
...
test/e2e/testing-manifests/node-selection/pod-with-node-affinity.yaml
deleted
100644 → 0
View file @
5273ac9b
apiVersion
:
v1
kind
:
Pod
metadata
:
name
:
with-labels
annotations
:
scheduler.alpha.kubernetes.io/affinity
:
>
{
"nodeAffinity": {
"requiredDuringSchedulingIgnoredDuringExecution": {
"nodeSelectorTerms": [
{
"matchExpressions": [
{
"key": "kubernetes.io/e2e-az-name",
"operator": "In",
"values": ["e2e-az1", "e2e-az2"]
}
]
}
]
}
}
}
another-annotation-key
:
another-annotation-value
spec
:
containers
:
-
name
:
with-labels
image
:
gcr.io/google_containers/pause:2.0
test/e2e/testing-manifests/node-selection/pod-with-pod-affinity.yaml
deleted
100644 → 0
View file @
5273ac9b
apiVersion
:
v1
kind
:
Pod
metadata
:
name
:
with-newlabels
annotations
:
scheduler.alpha.kubernetes.io/affinity
:
>
{
"podAffinity": {
"requiredDuringSchedulingIgnoredDuringExecution": [{
"labelSelector": {
"matchExpressions": [{
"key": "security",
"operator": "In",
"values":["S1"]
}]
},
"topologyKey": "kubernetes.io/hostname"
}]
},
"podAntiAffinity": {
"requiredDuringSchedulingIgnoredDuringExecution": [{
"labelSelector": {
"matchExpressions": [{
"key": "security",
"operator": "In",
"values":["S2"]
}]
},
"topologyKey": "kubernetes.io/hostname"
}]
}
}
another-annotation-key
:
another-annotation-value
spec
:
containers
:
-
name
:
with-newlabels
image
:
gcr.io/google_containers/pause:2.0
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