@@ -23,8 +23,7 @@ import (
23
23
"github.com/google/go-cmp/cmp"
24
24
"github.com/google/uuid"
25
25
k8stypes "k8s.io/apimachinery/pkg/types"
26
- "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/backend"
27
- backendmetrics "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/backend/metrics" // Import config for thresholds
26
+ "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/backend" // Import config for thresholds
28
27
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/types"
29
28
)
30
29
@@ -51,7 +50,7 @@ func TestSchedulePlugins(t *testing.T) {
51
50
tests := []struct {
52
51
name string
53
52
profile * SchedulerProfile
54
- input []backendmetrics. PodMetrics
53
+ input []types. Pod
55
54
wantTargetPod k8stypes.NamespacedName
56
55
targetPodScore float64
57
56
// Number of expected pods to score (after filter)
@@ -65,10 +64,10 @@ func TestSchedulePlugins(t *testing.T) {
65
64
WithScorers (NewWeightedScorer (tp1 , 1 ), NewWeightedScorer (tp2 , 1 )).
66
65
WithPicker (pickerPlugin ).
67
66
WithPostCyclePlugins (tp1 , tp2 ),
68
- input : []backendmetrics. PodMetrics {
69
- & backendmetrics. FakePodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod1" }}},
70
- & backendmetrics. FakePodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod2" }}},
71
- & backendmetrics. FakePodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod3" }}},
67
+ input : []types. Pod {
68
+ & types. PodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod1" }}},
69
+ & types. PodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod2" }}},
70
+ & types. PodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod3" }}},
72
71
},
73
72
wantTargetPod : k8stypes.NamespacedName {Name : "pod1" },
74
73
targetPodScore : 1.1 ,
@@ -82,10 +81,10 @@ func TestSchedulePlugins(t *testing.T) {
82
81
WithScorers (NewWeightedScorer (tp1 , 60 ), NewWeightedScorer (tp2 , 40 )).
83
82
WithPicker (pickerPlugin ).
84
83
WithPostCyclePlugins (tp1 , tp2 ),
85
- input : []backendmetrics. PodMetrics {
86
- & backendmetrics. FakePodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod1" }}},
87
- & backendmetrics. FakePodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod2" }}},
88
- & backendmetrics. FakePodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod3" }}},
84
+ input : []types. Pod {
85
+ & types. PodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod1" }}},
86
+ & types. PodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod2" }}},
87
+ & types. PodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod3" }}},
89
88
},
90
89
wantTargetPod : k8stypes.NamespacedName {Name : "pod1" },
91
90
targetPodScore : 50 ,
@@ -99,10 +98,10 @@ func TestSchedulePlugins(t *testing.T) {
99
98
WithScorers (NewWeightedScorer (tp1 , 1 ), NewWeightedScorer (tp2 , 1 )).
100
99
WithPicker (pickerPlugin ).
101
100
WithPostCyclePlugins (tp1 , tp2 ),
102
- input : []backendmetrics. PodMetrics {
103
- & backendmetrics. FakePodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod1" }}},
104
- & backendmetrics. FakePodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod2" }}},
105
- & backendmetrics. FakePodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod3" }}},
101
+ input : []types. Pod {
102
+ & types. PodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod1" }}},
103
+ & types. PodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod2" }}},
104
+ & types. PodMetrics {Pod : & backend.Pod {NamespacedName : k8stypes.NamespacedName {Name : "pod3" }}},
106
105
},
107
106
numPodsToScore : 0 ,
108
107
err : true , // no available pods to server after filter all
@@ -129,7 +128,7 @@ func TestSchedulePlugins(t *testing.T) {
129
128
RequestId : uuid .NewString (),
130
129
}
131
130
// Run profile cycle
132
- got , err := test .profile .Run (context .Background (), request , types .NewCycleState (), types . ToSchedulerPodMetrics ( test .input ) )
131
+ got , err := test .profile .Run (context .Background (), request , types .NewCycleState (), test .input )
133
132
134
133
// Validate error state
135
134
if test .err != (err != nil ) {
@@ -142,7 +141,7 @@ func TestSchedulePlugins(t *testing.T) {
142
141
143
142
// Validate output
144
143
wantPod := & types.PodMetrics {
145
- Pod : & backend.Pod {NamespacedName : test .wantTargetPod , Labels : make ( map [ string ] string ) },
144
+ Pod : & backend.Pod {NamespacedName : test .wantTargetPod },
146
145
}
147
146
wantRes := & types.ProfileRunResult {
148
147
TargetPod : wantPod ,
0 commit comments