...
1
16
17 package benchmark
18
19 import (
20 "testing"
21
22 utilfeature "k8s.io/apiserver/pkg/util/feature"
23 featuregatetesting "k8s.io/component-base/featuregate/testing"
24 "k8s.io/kubernetes/test/integration/framework"
25 "k8s.io/kubernetes/test/utils/ktesting"
26 )
27
28 func TestScheduling(t *testing.T) {
29 testCases, err := getTestCases(configFile)
30 if err != nil {
31 t.Fatal(err)
32 }
33 if err = validateTestCases(testCases); err != nil {
34 t.Fatal(err)
35 }
36
37
38 framework.GoleakCheck(t)
39
40
41
42 framework.StartEtcd(t, nil)
43
44
45
46 var configs []schedulerConfig
47 for _, tc := range testCases {
48 tcEnabled := false
49 for _, w := range tc.Workloads {
50 if enabled(*testSchedulingLabelFilter, append(tc.Labels, w.Labels...)...) {
51 tcEnabled = true
52 break
53 }
54 }
55 if !tcEnabled {
56 continue
57 }
58 exists := false
59 for _, config := range configs {
60 if config.equals(tc) {
61 exists = true
62 break
63 }
64 }
65 if !exists {
66 configs = append(configs, schedulerConfig{schedulerConfigPath: tc.SchedulerConfigPath, featureGates: tc.FeatureGates})
67 }
68 }
69 for _, config := range configs {
70
71 func() {
72 tCtx := ktesting.Init(t)
73
74
75
76
77 for feature, flag := range config.featureGates {
78 defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, feature, flag)()
79 }
80 informerFactory, tCtx := setupClusterForWorkload(tCtx, config.schedulerConfigPath, config.featureGates, nil)
81
82 for _, tc := range testCases {
83 if !config.equals(tc) {
84
85 continue
86 }
87
88 t.Run(tc.Name, func(t *testing.T) {
89 for _, w := range tc.Workloads {
90 t.Run(w.Name, func(t *testing.T) {
91 if !enabled(*testSchedulingLabelFilter, append(tc.Labels, w.Labels...)...) {
92 t.Skipf("disabled by label filter %q", *testSchedulingLabelFilter)
93 }
94 tCtx := ktesting.WithTB(tCtx, t)
95 runWorkload(tCtx, tc, w, informerFactory)
96 })
97 }
98 })
99 }
100 }()
101 }
102 }
103
View as plain text