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
5259d09c
Unverified
Commit
5259d09c
authored
Oct 17, 2018
by
Wei Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add more scheduler benchmark testcases
- add benchmark test for PodAffinity - add benchmark test for NodeAffinity - add 1000-nodes test for PodAntiAffinity/PodAffinity/NodeAffinity
parent
f6b54f79
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
118 additions
and
10 deletions
+118
-10
scheduler_bench_test.go
test/integration/scheduler_perf/scheduler_bench_test.go
+118
-10
No files found.
test/integration/scheduler_perf/scheduler_bench_test.go
View file @
5259d09c
...
@@ -31,6 +31,10 @@ import (
...
@@ -31,6 +31,10 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
)
)
var
(
defaultNodeStrategy
=
&
testutils
.
TrivialNodePrepareStrategy
{}
)
// BenchmarkScheduling benchmarks the scheduling rate when the cluster has
// BenchmarkScheduling benchmarks the scheduling rate when the cluster has
// various quantities of nodes and scheduled pods.
// various quantities of nodes and scheduled pods.
func
BenchmarkScheduling
(
b
*
testing
.
B
)
{
func
BenchmarkScheduling
(
b
*
testing
.
B
)
{
...
@@ -45,41 +49,90 @@ func BenchmarkScheduling(b *testing.B) {
...
@@ -45,41 +49,90 @@ func BenchmarkScheduling(b *testing.B) {
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
name
:=
fmt
.
Sprintf
(
"%vNodes/%vPods"
,
test
.
nodes
,
test
.
existingPods
)
name
:=
fmt
.
Sprintf
(
"%vNodes/%vPods"
,
test
.
nodes
,
test
.
existingPods
)
b
.
Run
(
name
,
func
(
b
*
testing
.
B
)
{
b
.
Run
(
name
,
func
(
b
*
testing
.
B
)
{
benchmarkScheduling
(
test
.
nodes
,
test
.
existingPods
,
test
.
minPods
,
setupStrategy
,
testStrategy
,
b
)
benchmarkScheduling
(
test
.
nodes
,
test
.
existingPods
,
test
.
minPods
,
defaultNodeStrategy
,
setupStrategy
,
testStrategy
,
b
)
})
})
}
}
}
}
// BenchmarkSchedulingAntiAffinity benchmarks the scheduling rate of pods with
// BenchmarkScheduling
Pod
AntiAffinity benchmarks the scheduling rate of pods with
// PodAntiAffinity rules when the cluster has various quantities of nodes and
// PodAntiAffinity rules when the cluster has various quantities of nodes and
// scheduled pods.
// scheduled pods.
func
BenchmarkSchedulingAntiAffinity
(
b
*
testing
.
B
)
{
func
BenchmarkScheduling
Pod
AntiAffinity
(
b
*
testing
.
B
)
{
tests
:=
[]
struct
{
nodes
,
existingPods
,
minPods
int
}{
tests
:=
[]
struct
{
nodes
,
existingPods
,
minPods
int
}{
{
nodes
:
500
,
existingPods
:
250
,
minPods
:
250
},
{
nodes
:
500
,
existingPods
:
250
,
minPods
:
250
},
{
nodes
:
500
,
existingPods
:
5000
,
minPods
:
250
},
{
nodes
:
500
,
existingPods
:
5000
,
minPods
:
250
},
{
nodes
:
1000
,
existingPods
:
1000
,
minPods
:
500
},
}
}
// The setup strategy creates pods with no affinity rules.
// The setup strategy creates pods with no affinity rules.
setupStrategy
:=
testutils
.
NewSimpleWithControllerCreatePodStrategy
(
"setup"
)
setupStrategy
:=
testutils
.
NewSimpleWithControllerCreatePodStrategy
(
"setup"
)
// The test strategy creates pods with anti-affinity for each other.
testBasePod
:=
makeBasePodWithPodAntiAffinity
(
testBasePod
:=
makeBasePodWithAntiAffinity
(
map
[
string
]
string
{
"name"
:
"test"
,
"color"
:
"green"
},
map
[
string
]
string
{
"name"
:
"test"
,
"color"
:
"green"
},
map
[
string
]
string
{
"color"
:
"green"
})
map
[
string
]
string
{
"color"
:
"green"
})
// The test strategy creates pods with anti-affinity for each other.
testStrategy
:=
testutils
.
NewCustomCreatePodStrategy
(
testBasePod
)
for
_
,
test
:=
range
tests
{
name
:=
fmt
.
Sprintf
(
"%vNodes/%vPods"
,
test
.
nodes
,
test
.
existingPods
)
b
.
Run
(
name
,
func
(
b
*
testing
.
B
)
{
benchmarkScheduling
(
test
.
nodes
,
test
.
existingPods
,
test
.
minPods
,
defaultNodeStrategy
,
setupStrategy
,
testStrategy
,
b
)
})
}
}
// BenchmarkSchedulingPodAffinity benchmarks the scheduling rate of pods with
// PodAffinity rules when the cluster has various quantities of nodes and
// scheduled pods.
func
BenchmarkSchedulingPodAffinity
(
b
*
testing
.
B
)
{
tests
:=
[]
struct
{
nodes
,
existingPods
,
minPods
int
}{
{
nodes
:
500
,
existingPods
:
250
,
minPods
:
250
},
{
nodes
:
500
,
existingPods
:
5000
,
minPods
:
250
},
{
nodes
:
1000
,
existingPods
:
1000
,
minPods
:
500
},
}
// The setup strategy creates pods with no affinity rules.
setupStrategy
:=
testutils
.
NewSimpleWithControllerCreatePodStrategy
(
"setup"
)
testBasePod
:=
makeBasePodWithPodAffinity
(
map
[
string
]
string
{
"foo"
:
""
},
map
[
string
]
string
{
"foo"
:
""
},
)
// The test strategy creates pods with affinity for each other.
testStrategy
:=
testutils
.
NewCustomCreatePodStrategy
(
testBasePod
)
testStrategy
:=
testutils
.
NewCustomCreatePodStrategy
(
testBasePod
)
nodeStrategy
:=
testutils
.
NewLabelNodePrepareStrategy
(
apis
.
LabelZoneFailureDomain
,
"zone1"
)
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
name
:=
fmt
.
Sprintf
(
"%vNodes/%vPods"
,
test
.
nodes
,
test
.
existingPods
)
name
:=
fmt
.
Sprintf
(
"%vNodes/%vPods"
,
test
.
nodes
,
test
.
existingPods
)
b
.
Run
(
name
,
func
(
b
*
testing
.
B
)
{
b
.
Run
(
name
,
func
(
b
*
testing
.
B
)
{
benchmarkScheduling
(
test
.
nodes
,
test
.
existingPods
,
test
.
minPods
,
setupStrategy
,
testStrategy
,
b
)
benchmarkScheduling
(
test
.
nodes
,
test
.
existingPods
,
test
.
minPods
,
nodeStrategy
,
setupStrategy
,
testStrategy
,
b
)
})
})
}
}
}
// BenchmarkSchedulingNodeAffinity benchmarks the scheduling rate of pods with
// NodeAffinity rules when the cluster has various quantities of nodes and
// scheduled pods.
func
BenchmarkSchedulingNodeAffinity
(
b
*
testing
.
B
)
{
tests
:=
[]
struct
{
nodes
,
existingPods
,
minPods
int
}{
{
nodes
:
500
,
existingPods
:
250
,
minPods
:
250
},
{
nodes
:
500
,
existingPods
:
5000
,
minPods
:
250
},
{
nodes
:
1000
,
existingPods
:
1000
,
minPods
:
500
},
}
// The setup strategy creates pods with no affinity rules.
setupStrategy
:=
testutils
.
NewSimpleWithControllerCreatePodStrategy
(
"setup"
)
testBasePod
:=
makeBasePodWithNodeAffinity
(
apis
.
LabelZoneFailureDomain
,
[]
string
{
"zone1"
,
"zone2"
})
// The test strategy creates pods with node-affinity for each other.
testStrategy
:=
testutils
.
NewCustomCreatePodStrategy
(
testBasePod
)
nodeStrategy
:=
testutils
.
NewLabelNodePrepareStrategy
(
apis
.
LabelZoneFailureDomain
,
"zone1"
)
for
_
,
test
:=
range
tests
{
name
:=
fmt
.
Sprintf
(
"%vNodes/%vPods"
,
test
.
nodes
,
test
.
existingPods
)
b
.
Run
(
name
,
func
(
b
*
testing
.
B
)
{
benchmarkScheduling
(
test
.
nodes
,
test
.
existingPods
,
test
.
minPods
,
nodeStrategy
,
setupStrategy
,
testStrategy
,
b
)
})
}
}
}
// makeBasePodWithAntiAffinity creates a Pod object to be used as a template.
// makeBasePodWith
Pod
AntiAffinity creates a Pod object to be used as a template.
// The Pod has a PodAntiAffinity requirement against pods with the given labels.
// The Pod has a PodAntiAffinity requirement against pods with the given labels.
func
makeBasePodWithAntiAffinity
(
podLabels
,
affinityLabels
map
[
string
]
string
)
*
v1
.
Pod
{
func
makeBasePodWith
Pod
AntiAffinity
(
podLabels
,
affinityLabels
map
[
string
]
string
)
*
v1
.
Pod
{
basePod
:=
&
v1
.
Pod
{
basePod
:=
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
GenerateName
:
"affinity-pod-"
,
GenerateName
:
"a
nit-a
ffinity-pod-"
,
Labels
:
podLabels
,
Labels
:
podLabels
,
},
},
Spec
:
testutils
.
MakePodSpec
(),
Spec
:
testutils
.
MakePodSpec
(),
...
@@ -99,11 +152,66 @@ func makeBasePodWithAntiAffinity(podLabels, affinityLabels map[string]string) *v
...
@@ -99,11 +152,66 @@ func makeBasePodWithAntiAffinity(podLabels, affinityLabels map[string]string) *v
return
basePod
return
basePod
}
}
// makeBasePodWithPodAffinity creates a Pod object to be used as a template.
// The Pod has a PodAffinity requirement against pods with the given labels.
func
makeBasePodWithPodAffinity
(
podLabels
,
affinityZoneLabels
map
[
string
]
string
)
*
v1
.
Pod
{
basePod
:=
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
GenerateName
:
"affinity-pod-"
,
Labels
:
podLabels
,
},
Spec
:
testutils
.
MakePodSpec
(),
}
basePod
.
Spec
.
Affinity
=
&
v1
.
Affinity
{
PodAffinity
:
&
v1
.
PodAffinity
{
RequiredDuringSchedulingIgnoredDuringExecution
:
[]
v1
.
PodAffinityTerm
{
{
LabelSelector
:
&
metav1
.
LabelSelector
{
MatchLabels
:
affinityZoneLabels
,
},
TopologyKey
:
apis
.
LabelZoneFailureDomain
,
},
},
},
}
return
basePod
}
// makeBasePodWithNodeAffinity creates a Pod object to be used as a template.
// The Pod has a NodeAffinity requirement against nodes with the given expressions.
func
makeBasePodWithNodeAffinity
(
key
string
,
vals
[]
string
)
*
v1
.
Pod
{
basePod
:=
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
GenerateName
:
"node-affinity-"
,
},
Spec
:
testutils
.
MakePodSpec
(),
}
basePod
.
Spec
.
Affinity
=
&
v1
.
Affinity
{
NodeAffinity
:
&
v1
.
NodeAffinity
{
RequiredDuringSchedulingIgnoredDuringExecution
:
&
v1
.
NodeSelector
{
NodeSelectorTerms
:
[]
v1
.
NodeSelectorTerm
{
{
MatchExpressions
:
[]
v1
.
NodeSelectorRequirement
{
{
Key
:
key
,
Operator
:
v1
.
NodeSelectorOpIn
,
Values
:
vals
,
},
},
},
},
},
},
}
return
basePod
}
// benchmarkScheduling benchmarks scheduling rate with specific number of nodes
// benchmarkScheduling benchmarks scheduling rate with specific number of nodes
// and specific number of pods already scheduled.
// and specific number of pods already scheduled.
// This will schedule numExistingPods pods before the benchmark starts, and at
// This will schedule numExistingPods pods before the benchmark starts, and at
// least minPods pods during the benchmark.
// least minPods pods during the benchmark.
func
benchmarkScheduling
(
numNodes
,
numExistingPods
,
minPods
int
,
func
benchmarkScheduling
(
numNodes
,
numExistingPods
,
minPods
int
,
nodeStrategy
testutils
.
PrepareNodeStrategy
,
setupPodStrategy
,
testPodStrategy
testutils
.
TestPodCreateStrategy
,
setupPodStrategy
,
testPodStrategy
testutils
.
TestPodCreateStrategy
,
b
*
testing
.
B
)
{
b
*
testing
.
B
)
{
if
b
.
N
<
minPods
{
if
b
.
N
<
minPods
{
...
@@ -115,7 +223,7 @@ func benchmarkScheduling(numNodes, numExistingPods, minPods int,
...
@@ -115,7 +223,7 @@ func benchmarkScheduling(numNodes, numExistingPods, minPods int,
nodePreparer
:=
framework
.
NewIntegrationTestNodePreparer
(
nodePreparer
:=
framework
.
NewIntegrationTestNodePreparer
(
c
,
c
,
[]
testutils
.
CountToStrategy
{{
Count
:
numNodes
,
Strategy
:
&
testutils
.
TrivialNodePrepareStrategy
{}
}},
[]
testutils
.
CountToStrategy
{{
Count
:
numNodes
,
Strategy
:
nodeStrategy
}},
"scheduler-perf-"
,
"scheduler-perf-"
,
)
)
if
err
:=
nodePreparer
.
PrepareNodes
();
err
!=
nil
{
if
err
:=
nodePreparer
.
PrepareNodes
();
err
!=
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