@@ -25,7 +25,6 @@ import (
25
25
k8stypes "k8s.io/apimachinery/pkg/types"
26
26
27
27
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/backend"
28
- backendmetrics "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/backend/metrics" // Import config for thresholds
29
28
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/plugins"
30
29
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/types"
31
30
)
@@ -45,7 +44,7 @@ func TestSchedulePlugins(t *testing.T) {
45
44
tests := []struct {
46
45
name string
47
46
profile * SchedulerProfile
48
- input []backendmetrics. PodMetrics
47
+ input []types. Pod
49
48
wantTargetPod k8stypes.NamespacedName
50
49
targetPodScore float64
51
50
// Number of expected pods to score (after filter)
@@ -59,10 +58,10 @@ func TestSchedulePlugins(t *testing.T) {
59
58
WithScorers (NewWeightedScorer (tp1 , 1 ), NewWeightedScorer (tp2 , 1 )).
60
59
WithPicker (pickerPlugin ).
61
60
WithPostCyclePlugins (tp1 , tp2 ),
62
- input : []backendmetrics. PodMetrics {
63
- & backendmetrics. FakePodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod1" }}},
64
- & backendmetrics. FakePodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod2" }}},
65
- & backendmetrics. FakePodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod3" }}},
61
+ input : []types. Pod {
62
+ & types. PodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod1" }}},
63
+ & types. PodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod2" }}},
64
+ & types. PodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod3" }}},
66
65
},
67
66
wantTargetPod : k8stypes.NamespacedName {Name : "pod1" },
68
67
targetPodScore : 1.1 ,
@@ -76,10 +75,10 @@ func TestSchedulePlugins(t *testing.T) {
76
75
WithScorers (NewWeightedScorer (tp1 , 60 ), NewWeightedScorer (tp2 , 40 )).
77
76
WithPicker (pickerPlugin ).
78
77
WithPostCyclePlugins (tp1 , tp2 ),
79
- input : []backendmetrics. PodMetrics {
80
- & backendmetrics. FakePodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod1" }}},
81
- & backendmetrics. FakePodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod2" }}},
82
- & backendmetrics. FakePodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod3" }}},
78
+ input : []types. Pod {
79
+ & types. PodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod1" }}},
80
+ & types. PodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod2" }}},
81
+ & types. PodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod3" }}},
83
82
},
84
83
wantTargetPod : k8stypes.NamespacedName {Name : "pod1" },
85
84
targetPodScore : 50 ,
@@ -93,10 +92,10 @@ func TestSchedulePlugins(t *testing.T) {
93
92
WithScorers (NewWeightedScorer (tp1 , 1 ), NewWeightedScorer (tp2 , 1 )).
94
93
WithPicker (pickerPlugin ).
95
94
WithPostCyclePlugins (tp1 , tp2 ),
96
- input : []backendmetrics. PodMetrics {
97
- & backendmetrics. FakePodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod1" }}},
98
- & backendmetrics. FakePodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod2" }}},
99
- & backendmetrics. FakePodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod3" }}},
95
+ input : []types. Pod {
96
+ & types. PodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod1" }}},
97
+ & types. PodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod2" }}},
98
+ & types. PodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod3" }}},
100
99
},
101
100
numPodsToScore : 0 ,
102
101
err : true , // no available pods to server after filter all
@@ -123,7 +122,7 @@ func TestSchedulePlugins(t *testing.T) {
123
122
RequestId : uuid .NewString (),
124
123
}
125
124
// Run profile cycle
126
- got , err := test .profile .Run (context .Background (), request , types .NewCycleState (), types . ToSchedulerPodMetrics ( test .input ) )
125
+ got , err := test .profile .Run (context .Background (), request , types .NewCycleState (), test .input )
127
126
128
127
// Validate error state
129
128
if test .err != (err != nil ) {
@@ -136,7 +135,7 @@ func TestSchedulePlugins(t *testing.T) {
136
135
137
136
// Validate output
138
137
wantPod := & types.PodMetrics {
139
- Pod : & backend.Pod {NamespacedName : test .wantTargetPod , Labels : make ( map [ string ] string ) },
138
+ Pod : & backend.Pod {NamespacedName : test .wantTargetPod },
140
139
}
141
140
wantRes := & types.ProfileRunResult {
142
141
TargetPod : wantPod ,
0 commit comments