@@ -120,6 +120,7 @@ func TestPriorityQueue_Add(t *testing.T) {
120
120
logger , ctx := ktesting .NewTestContext (t )
121
121
ctx , cancel := context .WithCancel (ctx )
122
122
defer cancel ()
123
+ metrics .Register ()
123
124
q := NewTestQueueWithObjects (ctx , newDefaultQueueSort (), objs )
124
125
q .Add (logger , medPriorityPodInfo .Pod )
125
126
q .Add (logger , unschedulablePodInfo .Pod )
@@ -2926,7 +2927,6 @@ func TestPodTimestamp(t *testing.T) {
2926
2927
// TestPendingPodsMetric tests Prometheus metrics related with pending pods
2927
2928
func TestPendingPodsMetric (t * testing.T ) {
2928
2929
timestamp := time .Now ()
2929
- metrics .Register ()
2930
2930
total := 60
2931
2931
queueableNum := 50
2932
2932
queueable , failme := "queueable" , "failme"
@@ -2951,6 +2951,7 @@ func TestPendingPodsMetric(t *testing.T) {
2951
2951
pInfosWithDelay [i ].Attempts = 0
2952
2952
}
2953
2953
}
2954
+ metrics .Register ()
2954
2955
2955
2956
tests := []struct {
2956
2957
name string
@@ -3185,11 +3186,11 @@ scheduler_plugin_execution_duration_seconds_count{extension_point="PreEnqueue",p
3185
3186
3186
3187
for _ , test := range tests {
3187
3188
t .Run (test .name , func (t * testing.T ) {
3188
- resetMetrics ()
3189
- resetPodInfos ()
3190
3189
logger , ctx := ktesting .NewTestContext (t )
3191
3190
ctx , cancel := context .WithCancel (ctx )
3192
3191
defer cancel ()
3192
+ resetMetrics ()
3193
+ resetPodInfos ()
3193
3194
3194
3195
m := map [string ][]framework.PreEnqueuePlugin {"" : {& preEnqueuePlugin {allowlists : []string {queueable }}}}
3195
3196
recorder := metrics .NewMetricsAsyncRecorder (3 , 20 * time .Microsecond , ctx .Done ())
@@ -3326,8 +3327,8 @@ func TestPerPodSchedulingMetrics(t *testing.T) {
3326
3327
func TestIncomingPodsMetrics (t * testing.T ) {
3327
3328
timestamp := time .Now ()
3328
3329
unschedulablePlg := "unschedulable_plugin"
3329
- metrics .Register ()
3330
3330
var pInfos = make ([]* framework.QueuedPodInfo , 0 , 3 )
3331
+ metrics .Register ()
3331
3332
for i := 1 ; i <= 3 ; i ++ {
3332
3333
p := & framework.QueuedPodInfo {
3333
3334
PodInfo : mustNewTestPodInfo (t ,
@@ -3399,10 +3400,10 @@ func TestIncomingPodsMetrics(t *testing.T) {
3399
3400
3400
3401
for _ , test := range tests {
3401
3402
t .Run (test .name , func (t * testing.T ) {
3402
- metrics .SchedulerQueueIncomingPods .Reset ()
3403
3403
logger , ctx := ktesting .NewTestContext (t )
3404
3404
ctx , cancel := context .WithCancel (ctx )
3405
3405
defer cancel ()
3406
+ metrics .SchedulerQueueIncomingPods .Reset ()
3406
3407
queue := NewTestQueue (ctx , newDefaultQueueSort (), WithClock (testingclock .NewFakeClock (timestamp )))
3407
3408
for _ , op := range test .operations {
3408
3409
for _ , pInfo := range pInfos {
0 commit comments