@@ -45,20 +45,23 @@ var (
45
45
// From PV controller
46
46
annBindCompleted = "pv.kubernetes.io/bind-completed"
47
47
48
- tests = []struct { nodes , existingPods , minPods int }{
48
+ defaultTests = []struct { nodes , existingPods , minPods int }{
49
49
{nodes : 500 , existingPods : 500 , minPods : 1000 },
50
50
{nodes : 5000 , existingPods : 5000 , minPods : 1000 },
51
51
}
52
+ testNamespace = "sched-test"
53
+ setupNamespace = "sched-setup"
52
54
)
53
55
54
56
// BenchmarkScheduling benchmarks the scheduling rate when the cluster has
55
57
// various quantities of nodes and scheduled pods.
56
58
func BenchmarkScheduling (b * testing.B ) {
57
59
testStrategy := testutils .NewSimpleWithControllerCreatePodStrategy ("rc1" )
58
- for _ , test := range tests {
60
+ for _ , test := range defaultTests {
59
61
name := fmt .Sprintf ("%vNodes/%vPods" , test .nodes , test .existingPods )
60
62
b .Run (name , func (b * testing.B ) {
61
- benchmarkScheduling (test .nodes , test .existingPods , test .minPods , defaultNodeStrategy , testStrategy , b )
63
+ nodeStrategies := []testutils.CountToStrategy {{Count : test .nodes , Strategy : defaultNodeStrategy }}
64
+ benchmarkScheduling (test .existingPods , test .minPods , nodeStrategies , testStrategy , b )
62
65
})
63
66
}
64
67
}
@@ -67,15 +70,26 @@ func BenchmarkScheduling(b *testing.B) {
67
70
// PodAntiAffinity rules when the cluster has various quantities of nodes and
68
71
// scheduled pods.
69
72
func BenchmarkSchedulingPodAntiAffinity (b * testing.B ) {
73
+ // Since the pods has anti affinity to each other, the number of pods to schedule
74
+ // can't exceed the number of nodes (the topology used in the test)
75
+ tests := []struct { nodes , existingPods , minPods int }{
76
+ {nodes : 500 , existingPods : 100 , minPods : 400 },
77
+ {nodes : 5000 , existingPods : 1000 , minPods : 1000 },
78
+ }
70
79
testBasePod := makeBasePodWithPodAntiAffinity (
71
80
map [string ]string {"name" : "test" , "color" : "green" },
72
81
map [string ]string {"color" : "green" })
73
- // The test strategy creates pods with anti-affinity for each other.
82
+ // The test strategy creates pods with anti-affinity to each other, each pod ending up in a separate node .
74
83
testStrategy := testutils .NewCustomCreatePodStrategy (testBasePod )
75
84
for _ , test := range tests {
76
85
name := fmt .Sprintf ("%vNodes/%vPods" , test .nodes , test .existingPods )
77
86
b .Run (name , func (b * testing.B ) {
78
- benchmarkScheduling (test .nodes , test .existingPods , test .minPods , defaultNodeStrategy , testStrategy , b )
87
+ var nodeStrategies []testutils.CountToStrategy
88
+ for i := 0 ; i < test .nodes ; i ++ {
89
+ nodeStrategy := testutils .NewLabelNodePrepareStrategy (v1 .LabelHostname , fmt .Sprintf ("node-%d" , i ))
90
+ nodeStrategies = append (nodeStrategies , testutils.CountToStrategy {Count : 1 , Strategy : nodeStrategy })
91
+ }
92
+ benchmarkScheduling (test .existingPods , test .minPods , nodeStrategies , testStrategy , b )
79
93
})
80
94
}
81
95
}
@@ -88,10 +102,11 @@ func BenchmarkSchedulingSecrets(b *testing.B) {
88
102
// The test strategy creates pods with a secret.
89
103
testBasePod := makeBasePodWithSecret ()
90
104
testStrategy := testutils .NewCustomCreatePodStrategy (testBasePod )
91
- for _ , test := range tests {
105
+ for _ , test := range defaultTests {
92
106
name := fmt .Sprintf ("%vNodes/%vPods" , test .nodes , test .existingPods )
93
107
b .Run (name , func (b * testing.B ) {
94
- benchmarkScheduling (test .nodes , test .existingPods , test .minPods , defaultNodeStrategy , testStrategy , b )
108
+ nodeStrategies := []testutils.CountToStrategy {{Count : test .nodes , Strategy : defaultNodeStrategy }}
109
+ benchmarkScheduling (test .existingPods , test .minPods , nodeStrategies , testStrategy , b )
95
110
})
96
111
}
97
112
}
@@ -104,10 +119,11 @@ func BenchmarkSchedulingInTreePVs(b *testing.B) {
104
119
baseClaim := makeBasePersistentVolumeClaim ()
105
120
basePod := makeBasePod ()
106
121
testStrategy := testutils .NewCreatePodWithPersistentVolumeStrategy (baseClaim , awsVolumeFactory , basePod )
107
- for _ , test := range tests {
122
+ for _ , test := range defaultTests {
108
123
name := fmt .Sprintf ("%vNodes/%vPods" , test .nodes , test .existingPods )
109
124
b .Run (name , func (b * testing.B ) {
110
- benchmarkScheduling (test .nodes , test .existingPods , test .minPods , defaultNodeStrategy , testStrategy , b )
125
+ nodeStrategies := []testutils.CountToStrategy {{Count : test .nodes , Strategy : defaultNodeStrategy }}
126
+ benchmarkScheduling (test .existingPods , test .minPods , nodeStrategies , testStrategy , b )
111
127
})
112
128
}
113
129
}
@@ -134,12 +150,13 @@ func BenchmarkSchedulingMigratedInTreePVs(b *testing.B) {
134
150
},
135
151
}
136
152
nodeStrategy := testutils .NewNodeAllocatableStrategy (allocatable , csiAllocatable , []string {csilibplugins .AWSEBSInTreePluginName })
137
- for _ , test := range tests {
153
+ for _ , test := range defaultTests {
138
154
name := fmt .Sprintf ("%vNodes/%vPods" , test .nodes , test .existingPods )
139
155
b .Run (name , func (b * testing.B ) {
140
156
defer featuregatetesting .SetFeatureGateDuringTest (b , utilfeature .DefaultFeatureGate , features .CSIMigration , true )()
141
157
defer featuregatetesting .SetFeatureGateDuringTest (b , utilfeature .DefaultFeatureGate , features .CSIMigrationAWS , true )()
142
- benchmarkScheduling (test .nodes , test .existingPods , test .minPods , nodeStrategy , testStrategy , b )
158
+ nodeStrategies := []testutils.CountToStrategy {{Count : test .nodes , Strategy : nodeStrategy }}
159
+ benchmarkScheduling (test .existingPods , test .minPods , nodeStrategies , testStrategy , b )
143
160
})
144
161
}
145
162
}
@@ -164,10 +181,11 @@ func BenchmarkSchedulingCSIPVs(b *testing.B) {
164
181
},
165
182
}
166
183
nodeStrategy := testutils .NewNodeAllocatableStrategy (allocatable , csiAllocatable , []string {})
167
- for _ , test := range tests {
184
+ for _ , test := range defaultTests {
168
185
name := fmt .Sprintf ("%vNodes/%vPods" , test .nodes , test .existingPods )
169
186
b .Run (name , func (b * testing.B ) {
170
- benchmarkScheduling (test .nodes , test .existingPods , test .minPods , nodeStrategy , testStrategy , b )
187
+ nodeStrategies := []testutils.CountToStrategy {{Count : test .nodes , Strategy : nodeStrategy }}
188
+ benchmarkScheduling (test .existingPods , test .minPods , nodeStrategies , testStrategy , b )
171
189
})
172
190
}
173
191
}
@@ -183,10 +201,11 @@ func BenchmarkSchedulingPodAffinity(b *testing.B) {
183
201
// The test strategy creates pods with affinity for each other.
184
202
testStrategy := testutils .NewCustomCreatePodStrategy (testBasePod )
185
203
nodeStrategy := testutils .NewLabelNodePrepareStrategy (v1 .LabelZoneFailureDomain , "zone1" )
186
- for _ , test := range tests {
204
+ for _ , test := range defaultTests {
187
205
name := fmt .Sprintf ("%vNodes/%vPods" , test .nodes , test .existingPods )
188
206
b .Run (name , func (b * testing.B ) {
189
- benchmarkScheduling (test .nodes , test .existingPods , test .minPods , nodeStrategy , testStrategy , b )
207
+ nodeStrategies := []testutils.CountToStrategy {{Count : test .nodes , Strategy : nodeStrategy }}
208
+ benchmarkScheduling (test .existingPods , test .minPods , nodeStrategies , testStrategy , b )
190
209
})
191
210
}
192
211
}
@@ -201,11 +220,15 @@ func BenchmarkSchedulingPreferredPodAffinity(b *testing.B) {
201
220
)
202
221
// The test strategy creates pods with affinity for each other.
203
222
testStrategy := testutils .NewCustomCreatePodStrategy (testBasePod )
204
- nodeStrategy := testutils .NewLabelNodePrepareStrategy (v1 .LabelZoneFailureDomain , "zone1" )
205
- for _ , test := range tests {
223
+ for _ , test := range defaultTests {
206
224
name := fmt .Sprintf ("%vNodes/%vPods" , test .nodes , test .existingPods )
207
225
b .Run (name , func (b * testing.B ) {
208
- benchmarkScheduling (test .nodes , test .existingPods , test .minPods , nodeStrategy , testStrategy , b )
226
+ var nodeStrategies []testutils.CountToStrategy
227
+ for i := 0 ; i < test .nodes ; i ++ {
228
+ nodeStrategy := testutils .NewLabelNodePrepareStrategy (v1 .LabelHostname , fmt .Sprintf ("node-%d" , i ))
229
+ nodeStrategies = append (nodeStrategies , testutils.CountToStrategy {Count : 1 , Strategy : nodeStrategy })
230
+ }
231
+ benchmarkScheduling (test .existingPods , test .minPods , nodeStrategies , testStrategy , b )
209
232
})
210
233
}
211
234
}
@@ -218,13 +241,17 @@ func BenchmarkSchedulingPreferredPodAntiAffinity(b *testing.B) {
218
241
map [string ]string {"foo" : "" },
219
242
map [string ]string {"foo" : "" },
220
243
)
221
- // The test strategy creates pods with affinity for each other.
244
+ // The test strategy creates pods with anti affinity to each other.
222
245
testStrategy := testutils .NewCustomCreatePodStrategy (testBasePod )
223
- nodeStrategy := testutils .NewLabelNodePrepareStrategy (v1 .LabelZoneFailureDomain , "zone1" )
224
- for _ , test := range tests {
246
+ for _ , test := range defaultTests {
225
247
name := fmt .Sprintf ("%vNodes/%vPods" , test .nodes , test .existingPods )
226
248
b .Run (name , func (b * testing.B ) {
227
- benchmarkScheduling (test .nodes , test .existingPods , test .minPods , nodeStrategy , testStrategy , b )
249
+ var nodeStrategies []testutils.CountToStrategy
250
+ for i := 0 ; i < test .nodes ; i ++ {
251
+ nodeStrategy := testutils .NewLabelNodePrepareStrategy (v1 .LabelHostname , fmt .Sprintf ("node-%d" , i ))
252
+ nodeStrategies = append (nodeStrategies , testutils.CountToStrategy {Count : 1 , Strategy : nodeStrategy })
253
+ }
254
+ benchmarkScheduling (test .existingPods , test .minPods , nodeStrategies , testStrategy , b )
228
255
})
229
256
}
230
257
}
@@ -237,10 +264,11 @@ func BenchmarkSchedulingNodeAffinity(b *testing.B) {
237
264
// The test strategy creates pods with node-affinity for each other.
238
265
testStrategy := testutils .NewCustomCreatePodStrategy (testBasePod )
239
266
nodeStrategy := testutils .NewLabelNodePrepareStrategy (v1 .LabelZoneFailureDomain , "zone1" )
240
- for _ , test := range tests {
267
+ for _ , test := range defaultTests {
241
268
name := fmt .Sprintf ("%vNodes/%vPods" , test .nodes , test .existingPods )
242
269
b .Run (name , func (b * testing.B ) {
243
- benchmarkScheduling (test .nodes , test .existingPods , test .minPods , nodeStrategy , testStrategy , b )
270
+ nodeStrategies := []testutils.CountToStrategy {{Count : test .nodes , Strategy : nodeStrategy }}
271
+ benchmarkScheduling (test .existingPods , test .minPods , nodeStrategies , testStrategy , b )
244
272
})
245
273
}
246
274
}
@@ -263,6 +291,7 @@ func makeBasePodWithPodAntiAffinity(podLabels, affinityLabels map[string]string)
263
291
MatchLabels : affinityLabels ,
264
292
},
265
293
TopologyKey : v1 .LabelHostname ,
294
+ Namespaces : []string {testNamespace , setupNamespace },
266
295
},
267
296
},
268
297
},
@@ -289,6 +318,7 @@ func makeBasePodWithPreferredPodAntiAffinity(podLabels, affinityLabels map[strin
289
318
MatchLabels : affinityLabels ,
290
319
},
291
320
TopologyKey : v1 .LabelHostname ,
321
+ Namespaces : []string {testNamespace , setupNamespace },
292
322
},
293
323
Weight : 1 ,
294
324
},
@@ -317,6 +347,7 @@ func makeBasePodWithPreferredPodAffinity(podLabels, affinityLabels map[string]st
317
347
MatchLabels : affinityLabels ,
318
348
},
319
349
TopologyKey : v1 .LabelHostname ,
350
+ Namespaces : []string {testNamespace , setupNamespace },
320
351
},
321
352
Weight : 1 ,
322
353
},
@@ -344,6 +375,7 @@ func makeBasePodWithPodAffinity(podLabels, affinityZoneLabels map[string]string)
344
375
MatchLabels : affinityZoneLabels ,
345
376
},
346
377
TopologyKey : v1 .LabelZoneFailureDomain ,
378
+ Namespaces : []string {testNamespace , setupNamespace },
347
379
},
348
380
},
349
381
},
@@ -384,8 +416,8 @@ func makeBasePodWithNodeAffinity(key string, vals []string) *v1.Pod {
384
416
// and specific number of pods already scheduled.
385
417
// This will schedule numExistingPods pods before the benchmark starts, and at
386
418
// least minPods pods during the benchmark.
387
- func benchmarkScheduling (numNodes , numExistingPods , minPods int ,
388
- nodeStrategy testutils.PrepareNodeStrategy ,
419
+ func benchmarkScheduling (numExistingPods , minPods int ,
420
+ nodeStrategies [] testutils.CountToStrategy ,
389
421
testPodStrategy testutils.TestPodCreateStrategy ,
390
422
b * testing.B ) {
391
423
if b .N < minPods {
@@ -396,16 +428,15 @@ func benchmarkScheduling(numNodes, numExistingPods, minPods int,
396
428
397
429
nodePreparer := framework .NewIntegrationTestNodePreparer (
398
430
clientset ,
399
- []testutils.CountToStrategy {{Count : numNodes , Strategy : nodeStrategy }},
400
- "scheduler-perf-" ,
401
- )
431
+ nodeStrategies ,
432
+ "scheduler-perf-" )
402
433
if err := nodePreparer .PrepareNodes (); err != nil {
403
434
klog .Fatalf ("%v" , err )
404
435
}
405
436
defer nodePreparer .CleanupNodes ()
406
437
407
438
config := testutils .NewTestPodCreatorConfig ()
408
- config .AddStrategy ("sched-setup" , numExistingPods , testPodStrategy )
439
+ config .AddStrategy (setupNamespace , numExistingPods , testPodStrategy )
409
440
podCreator := testutils .NewTestPodCreator (clientset , config )
410
441
podCreator .CreatePods ()
411
442
@@ -439,7 +470,7 @@ func benchmarkScheduling(numNodes, numExistingPods, minPods int,
439
470
// start benchmark
440
471
b .ResetTimer ()
441
472
config = testutils .NewTestPodCreatorConfig ()
442
- config .AddStrategy ("sched-test" , b .N , testPodStrategy )
473
+ config .AddStrategy (testNamespace , b .N , testPodStrategy )
443
474
podCreator = testutils .NewTestPodCreator (clientset , config )
444
475
podCreator .CreatePods ()
445
476
0 commit comments