mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-26 07:14:12 +00:00
scheduler-perf: add option to enable api-server initialization
This commit is contained in:
20
test/integration/scheduler_perf/option.go
Normal file
20
test/integration/scheduler_perf/option.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package benchmark
|
||||
|
||||
import "k8s.io/kubernetes/test/utils/ktesting"
|
||||
|
||||
type SchedulerPerfOption func(options *schedulerPerfOptions)
|
||||
|
||||
// PrepareFn is a function that is called before the benchmarks run.
|
||||
type PrepareFn func(tCtx ktesting.TContext) error
|
||||
|
||||
type schedulerPerfOptions struct {
|
||||
prepareFn PrepareFn
|
||||
}
|
||||
|
||||
// WithPrepareFn is the option to set a function that is called
|
||||
// before the benchmarks run. (e.g. applying CRDs for custom plugins)
|
||||
func WithPrepareFn(prepareFn PrepareFn) SchedulerPerfOption {
|
||||
return func(s *schedulerPerfOptions) {
|
||||
s.prepareFn = prepareFn
|
||||
}
|
||||
}
|
||||
@@ -1147,7 +1147,19 @@ func fixJSONOutput(b *testing.B) {
|
||||
// You can pass your own scheduler plugins via outOfTreePluginRegistry.
|
||||
// Also, you may want to put your plugins in PluginNames variable in this package
|
||||
// to collect metrics for them.
|
||||
func RunBenchmarkPerfScheduling(b *testing.B, configFile string, topicName string, outOfTreePluginRegistry frameworkruntime.Registry) {
|
||||
func RunBenchmarkPerfScheduling(b *testing.B, configFile string, topicName string, outOfTreePluginRegistry frameworkruntime.Registry, options ...SchedulerPerfOption) {
|
||||
opts := &schedulerPerfOptions{
|
||||
prepareFn: nil,
|
||||
}
|
||||
|
||||
for _, option := range options {
|
||||
option(opts)
|
||||
}
|
||||
|
||||
runBenchmarkPerSchedulingImpl(b, configFile, topicName, outOfTreePluginRegistry, opts)
|
||||
}
|
||||
|
||||
func runBenchmarkPerSchedulingImpl(b *testing.B, configFile string, topicName string, outOfTreePluginRegistry frameworkruntime.Registry, options *schedulerPerfOptions) {
|
||||
testCases, err := getTestCases(configFile)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
@@ -1194,6 +1206,13 @@ func RunBenchmarkPerfScheduling(b *testing.B, configFile string, topicName strin
|
||||
b.Fatalf("workload %s is not valid: %v", w.Name, err)
|
||||
}
|
||||
|
||||
if options.prepareFn != nil {
|
||||
err = options.prepareFn(tCtx)
|
||||
if err != nil {
|
||||
b.Fatalf("failed to run prepareFn: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
results, err := runWorkload(tCtx, tc, w, informerFactory)
|
||||
if err != nil {
|
||||
tCtx.Fatalf("Error running workload %s: %s", w.Name, err)
|
||||
|
||||
Reference in New Issue
Block a user