@@ -153,35 +153,39 @@ func TestAllocResource(t *testing.T) {
153
153
c .scheduler = sched
154
154
// wrong select
155
155
sched .On ("SelectMemoryNodes" , mock .Anything , mock .Anything , mock .Anything ).Return (nil , 0 , types .ErrInsufficientMEM ).Once ()
156
- _ , err = c .doAllocResource (ctx , opts , scheduler .MEMORY_PRIOR )
156
+ _ , err = c .doAllocResource (ctx , opts , scheduler .MemoryPrior )
157
157
assert .Error (t , err )
158
158
//cpu select
159
159
total := 3
160
160
sched .On ("SelectCPUNodes" , mock .Anything , mock .Anything , mock .Anything ).Return (nodesInfo , nodeCPUPlans , total , nil )
161
161
// wrong DeployMethod
162
- _ , err = c .doAllocResource (ctx , opts , scheduler .CPU_PRIOR )
162
+ _ , err = c .doAllocResource (ctx , opts , scheduler .CPUPrior )
163
163
assert .Error (t , err )
164
164
// other methods
165
165
sched .On ("CommonDivision" , mock .Anything , mock .Anything , mock .Anything ).Return (nil , types .ErrInsufficientRes )
166
166
opts .DeployMethod = cluster .DeployAuto
167
- _ , err = c .doAllocResource (ctx , opts , scheduler .CPU_PRIOR )
167
+ _ , err = c .doAllocResource (ctx , opts , scheduler .CPUPrior )
168
+ assert .Error (t , err )
169
+ sched .On ("GlobalDivision" , mock .Anything , mock .Anything , mock .Anything ).Return (nil , types .ErrInsufficientRes )
170
+ opts .DeployMethod = cluster .DeployGlobal
171
+ _ , err = c .doAllocResource (ctx , opts , scheduler .CPUPrior )
168
172
assert .Error (t , err )
169
173
sched .On ("EachDivision" , mock .Anything , mock .Anything , mock .Anything ).Return (nil , types .ErrInsufficientRes )
170
174
opts .DeployMethod = cluster .DeployEach
171
- _ , err = c .doAllocResource (ctx , opts , scheduler .CPU_PRIOR )
175
+ _ , err = c .doAllocResource (ctx , opts , scheduler .CPUPrior )
172
176
assert .Error (t , err )
173
177
// fill division but no nodes failed
174
178
sched .On ("FillDivision" , mock .Anything , mock .Anything , mock .Anything ).Return ([]types.NodeInfo {}, nil ).Once ()
175
179
opts .DeployMethod = cluster .DeployFill
176
- _ , err = c .doAllocResource (ctx , opts , scheduler .CPU_PRIOR )
180
+ _ , err = c .doAllocResource (ctx , opts , scheduler .CPUPrior )
177
181
assert .Error (t , err )
178
182
// fill division but UpdateNodeResource failed
179
183
sched .On ("FillDivision" , mock .Anything , mock .Anything , mock .Anything ).Return (nodesInfo , nil )
180
184
store .On ("UpdateNodeResource" ,
181
185
mock .Anything , mock .Anything , mock .Anything ,
182
186
mock .Anything , mock .Anything , mock .Anything ,
183
187
).Return (types .ErrNoETCD ).Once ()
184
- _ , err = c .doAllocResource (ctx , opts , scheduler .CPU_PRIOR )
188
+ _ , err = c .doAllocResource (ctx , opts , scheduler .CPUPrior )
185
189
assert .Error (t , err )
186
190
// fill division sucessed
187
191
store .On ("UpdateNodeResource" ,
@@ -192,13 +196,13 @@ func TestAllocResource(t *testing.T) {
192
196
store .On ("SaveProcessing" ,
193
197
mock .Anything , mock .Anything , mock .Anything ,
194
198
).Return (types .ErrNoETCD ).Once ()
195
- _ , err = c .doAllocResource (ctx , opts , scheduler .CPU_PRIOR )
199
+ _ , err = c .doAllocResource (ctx , opts , scheduler .CPUPrior )
196
200
assert .Error (t , err )
197
201
// bind process
198
202
store .On ("SaveProcessing" ,
199
203
mock .Anything , mock .Anything , mock .Anything ,
200
204
).Return (nil )
201
- nsi , err := c .doAllocResource (ctx , opts , scheduler .CPU_PRIOR )
205
+ nsi , err := c .doAllocResource (ctx , opts , scheduler .CPUPrior )
202
206
assert .NoError (t , err )
203
207
assert .Len (t , nsi , 1 )
204
208
assert .Equal (t , nsi [0 ].Name , n2 )
0 commit comments