@@ -36,6 +36,7 @@ import (
36
36
"sigs.k8s.io/scheduler-plugins/pkg/coscheduling/core"
37
37
fakepgclientset "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned/fake"
38
38
pgformers "sigs.k8s.io/scheduler-plugins/pkg/generated/informers/externalversions"
39
+ "sigs.k8s.io/scheduler-plugins/test/util"
39
40
testutil "sigs.k8s.io/scheduler-plugins/test/util"
40
41
)
41
42
@@ -100,87 +101,87 @@ func TestLess(t *testing.T) {
100
101
{
101
102
name : "p1.priority less than p2.priority" ,
102
103
p1 : & framework.QueuedPodInfo {
103
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (lowPriority ).Obj ()),
104
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (lowPriority ).Obj ()),
104
105
},
105
106
p2 : & framework.QueuedPodInfo {
106
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (highPriority ).Obj ()),
107
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (highPriority ).Obj ()),
107
108
},
108
109
expected : false , // p2 should be ahead of p1 in the queue
109
110
},
110
111
{
111
112
name : "p1.priority greater than p2.priority" ,
112
113
p1 : & framework.QueuedPodInfo {
113
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (highPriority ).Obj ()),
114
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (highPriority ).Obj ()),
114
115
},
115
116
p2 : & framework.QueuedPodInfo {
116
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (lowPriority ).Obj ()),
117
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (lowPriority ).Obj ()),
117
118
},
118
119
expected : true , // p1 should be ahead of p2 in the queue
119
120
},
120
121
{
121
122
name : "equal priority. p1 is added to schedulingQ earlier than p2" ,
122
123
p1 : & framework.QueuedPodInfo {
123
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (highPriority ).Obj ()),
124
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (highPriority ).Obj ()),
124
125
InitialAttemptTimestamp : times [0 ],
125
126
},
126
127
p2 : & framework.QueuedPodInfo {
127
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (highPriority ).Obj ()),
128
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (highPriority ).Obj ()),
128
129
InitialAttemptTimestamp : times [1 ],
129
130
},
130
131
expected : true , // p1 should be ahead of p2 in the queue
131
132
},
132
133
{
133
134
name : "equal priority. p2 is added to schedulingQ earlier than p1" ,
134
135
p1 : & framework.QueuedPodInfo {
135
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (highPriority ).Obj ()),
136
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (highPriority ).Obj ()),
136
137
InitialAttemptTimestamp : times [1 ],
137
138
},
138
139
p2 : & framework.QueuedPodInfo {
139
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (highPriority ).Obj ()),
140
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (highPriority ).Obj ()),
140
141
InitialAttemptTimestamp : times [0 ],
141
142
},
142
143
expected : false , // p2 should be ahead of p1 in the queue
143
144
},
144
145
{
145
146
name : "p1.priority less than p2.priority, p1 belongs to podGroup1" ,
146
147
p1 : & framework.QueuedPodInfo {
147
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (lowPriority ).Label (v1alpha1 .PodGroupLabel , "pg1" ).Obj ()),
148
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (lowPriority ).Label (v1alpha1 .PodGroupLabel , "pg1" ).Obj ()),
148
149
},
149
150
p2 : & framework.QueuedPodInfo {
150
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (highPriority ).Obj ()),
151
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (highPriority ).Obj ()),
151
152
},
152
153
expected : false , // p2 should be ahead of p1 in the queue
153
154
},
154
155
{
155
156
name : "p1.priority greater than p2.priority, p1 belongs to podGroup1" ,
156
157
p1 : & framework.QueuedPodInfo {
157
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg1" ).Obj ()),
158
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg1" ).Obj ()),
158
159
},
159
160
p2 : & framework.QueuedPodInfo {
160
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (lowPriority ).Obj ()),
161
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (lowPriority ).Obj ()),
161
162
},
162
163
expected : true , // p1 should be ahead of p2 in the queue
163
164
},
164
165
{
165
166
name : "equal priority. p1 is added to schedulingQ earlier than p2, p1 belongs to podGroup3" ,
166
167
p1 : & framework.QueuedPodInfo {
167
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg3" ).Obj ()),
168
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg3" ).Obj ()),
168
169
InitialAttemptTimestamp : times [0 ],
169
170
},
170
171
p2 : & framework.QueuedPodInfo {
171
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (highPriority ).Obj ()),
172
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (highPriority ).Obj ()),
172
173
InitialAttemptTimestamp : times [1 ],
173
174
},
174
175
expected : true , // p1 should be ahead of p2 in the queue
175
176
},
176
177
{
177
178
name : "equal priority. p2 is added to schedulingQ earlier than p1, p1 belongs to podGroup3" ,
178
179
p1 : & framework.QueuedPodInfo {
179
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg3" ).Obj ()),
180
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg3" ).Obj ()),
180
181
InitialAttemptTimestamp : times [1 ],
181
182
},
182
183
p2 : & framework.QueuedPodInfo {
183
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (highPriority ).Obj ()),
184
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (highPriority ).Obj ()),
184
185
InitialAttemptTimestamp : times [0 ],
185
186
},
186
187
expected : false , // p2 should be ahead of p1 in the queue
@@ -189,67 +190,67 @@ func TestLess(t *testing.T) {
189
190
{
190
191
name : "p1.priority less than p2.priority, p1 belongs to podGroup1 and p2 belongs to podGroup2" ,
191
192
p1 : & framework.QueuedPodInfo {
192
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (lowPriority ).Label (v1alpha1 .PodGroupLabel , "pg1" ).Obj ()),
193
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (lowPriority ).Label (v1alpha1 .PodGroupLabel , "pg1" ).Obj ()),
193
194
},
194
195
p2 : & framework.QueuedPodInfo {
195
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg2" ).Obj ()),
196
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg2" ).Obj ()),
196
197
},
197
198
expected : false , // p2 should be ahead of p1 in the queue
198
199
},
199
200
{
200
201
name : "p1.priority greater than p2.priority, p1 belongs to podGroup1 and p2 belongs to podGroup2" ,
201
202
p1 : & framework.QueuedPodInfo {
202
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg1" ).Obj ()),
203
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg1" ).Obj ()),
203
204
},
204
205
p2 : & framework.QueuedPodInfo {
205
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (lowPriority ).Label (v1alpha1 .PodGroupLabel , "pg2" ).Obj ()),
206
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (lowPriority ).Label (v1alpha1 .PodGroupLabel , "pg2" ).Obj ()),
206
207
},
207
208
expected : true , // p1 should be ahead of p2 in the queue
208
209
},
209
210
{
210
211
name : "equal priority. p1 is added to schedulingQ earlier than p2, p1 belongs to podGroup1 and p2 belongs to podGroup2" ,
211
212
p1 : & framework.QueuedPodInfo {
212
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg1" ).Obj ()),
213
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg1" ).Obj ()),
213
214
InitialAttemptTimestamp : times [0 ],
214
215
},
215
216
p2 : & framework.QueuedPodInfo {
216
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg2" ).Obj ()),
217
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg2" ).Obj ()),
217
218
InitialAttemptTimestamp : times [1 ],
218
219
},
219
220
expected : true , // p1 should be ahead of p2 in the queue
220
221
},
221
222
{
222
223
name : "equal priority. p2 is added to schedulingQ earlier than p1, p1 belongs to podGroup4 and p2 belongs to podGroup3" ,
223
224
p1 : & framework.QueuedPodInfo {
224
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg4" ).Obj ()),
225
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg4" ).Obj ()),
225
226
InitialAttemptTimestamp : times [1 ],
226
227
},
227
228
p2 : & framework.QueuedPodInfo {
228
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg3" ).Obj ()),
229
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg3" ).Obj ()),
229
230
InitialAttemptTimestamp : times [0 ],
230
231
},
231
232
expected : false , // p2 should be ahead of p1 in the queue
232
233
},
233
234
{
234
235
name : "equal priority and creation time, p1 belongs to podGroup1 and p2 belongs to podGroup2" ,
235
236
p1 : & framework.QueuedPodInfo {
236
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg1" ).Obj ()),
237
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg1" ).Obj ()),
237
238
InitialAttemptTimestamp : times [0 ],
238
239
},
239
240
p2 : & framework.QueuedPodInfo {
240
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg2" ).Obj ()),
241
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg2" ).Obj ()),
241
242
InitialAttemptTimestamp : times [0 ],
242
243
},
243
244
expected : true , // p1 should be ahead of p2 in the queue
244
245
},
245
246
{
246
247
name : "equal priority and creation time, p2 belong to podGroup2" ,
247
248
p1 : & framework.QueuedPodInfo {
248
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (highPriority ).Obj ()),
249
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns1 ).Name ("pod1" ).Priority (highPriority ).Obj ()),
249
250
InitialAttemptTimestamp : times [0 ],
250
251
},
251
252
p2 : & framework.QueuedPodInfo {
252
- PodInfo : framework . NewPodInfo ( st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg2" ).Obj ()),
253
+ PodInfo : util . MustNewPodInfo ( t , st .MakePod ().Namespace (ns2 ).Name ("pod2" ).Priority (highPriority ).Label (v1alpha1 .PodGroupLabel , "pg2" ).Obj ()),
253
254
InitialAttemptTimestamp : times [0 ],
254
255
},
255
256
expected : true , // p1 should be ahead of p2 in the queue
0 commit comments