77 "testing"
88 "time"
99
10- "github.com/hashicorp/nomad/helper/pointer"
1110 "github.com/hashicorp/nomad/nomad/mock"
1211 "github.com/hashicorp/nomad/nomad/structs"
1312 "github.com/shoenig/test/must"
@@ -75,7 +74,7 @@ func TestReconciler_filterServerTerminalAllocs(t *testing.T) {
7574 })
7675}
7776
78- func TestAllocSet_filterByTainted_ClassificationRules (t * testing.T ) {
77+ func TestAllocSet_classifyAllocs_ClassificationRules (t * testing.T ) {
7978 now := time .Now ()
8079
8180 nodes := map [string ]* structs.Node {
@@ -136,30 +135,26 @@ func TestAllocSet_filterByTainted_ClassificationRules(t *testing.T) {
136135 a .AllocStates = unknownState
137136 return a
138137 }(),
139- nodeMap : nodes ,
140138 expected : "reconnecting" ,
141139 },
142140 {
143141 name : "terminal server status ignored" ,
144142 alloc : makeAlloc ("c2" , "ready" , structs .AllocClientStatusRunning , structs .AllocDesiredStatusStop ),
145- nodeMap : nodes ,
146143 expected : "ignore" ,
147144 },
148145 {
149146 name : "terminal canary migrate" ,
150147 alloc : func () * structs.Allocation {
151148 a := makeAlloc ("c3" , "ready" , structs .AllocClientStatusComplete , structs .AllocDesiredStatusRun )
152149 a .DeploymentStatus = & structs.AllocDeploymentStatus {Canary : true }
153- a .DesiredTransition = structs.DesiredTransition {Migrate : new (true )}
150+ a .DesiredTransition = structs.DesiredTransition {Migrate : (true )}
154151 return a
155152 }(),
156- nodeMap : nodes ,
157153 expected : "migrate" ,
158154 },
159155 {
160156 name : "terminal untainted" ,
161157 alloc : makeAlloc ("c4" , "ready" , structs .AllocClientStatusComplete , structs .AllocDesiredStatusRun ),
162- nodeMap : nodes ,
163158 expected : "untainted" ,
164159 },
165160 {
@@ -170,7 +165,6 @@ func TestAllocSet_filterByTainted_ClassificationRules(t *testing.T) {
170165 a .AllocStates = unknownState
171166 return a
172167 }(),
173- nodeMap : nodes ,
174168 expected : "expiring" ,
175169 },
176170 {
@@ -180,19 +174,16 @@ func TestAllocSet_filterByTainted_ClassificationRules(t *testing.T) {
180174 a .AllocStates = unknownState
181175 return a
182176 }(),
183- nodeMap : nodes ,
184177 expected : "ignore" ,
185178 },
186179 {
187180 name : "disconnected unknown becomes untainted" ,
188181 alloc : makeAlloc ("c7" , "disconnected" , structs .AllocClientStatusUnknown , structs .AllocDesiredStatusRun ),
189- nodeMap : nodes ,
190182 expected : "untainted" ,
191183 },
192184 {
193185 name : "disconnected pending lost" ,
194186 alloc : makeAlloc ("c8" , "disconnected" , structs .AllocClientStatusPending , structs .AllocDesiredStatusRun ),
195- nodeMap : nodes ,
196187 expected : "lost" ,
197188 },
198189 {
@@ -202,23 +193,20 @@ func TestAllocSet_filterByTainted_ClassificationRules(t *testing.T) {
202193 a .Job = nil
203194 return a
204195 }(),
205- nodeMap : nodes ,
206196 expected : "lost" ,
207197 },
208198 {
209199 name : "disconnected grace period" ,
210200 alloc : makeAlloc ("c10" , "disconnected" , structs .AllocClientStatusRunning , structs .AllocDesiredStatusRun ),
211- nodeMap : nodes ,
212201 expected : "disconnecting" ,
213202 },
214203 {
215204 name : "migrate flag" ,
216205 alloc : func () * structs.Allocation {
217206 a := makeAlloc ("c11" , "ready" , structs .AllocClientStatusPending , structs .AllocDesiredStatusRun )
218- a .DesiredTransition = structs.DesiredTransition {Migrate : new (true )}
207+ a .DesiredTransition = structs.DesiredTransition {Migrate : (true )}
219208 return a
220209 }(),
221- nodeMap : nodes ,
222210 expected : "migrate" ,
223211 },
224212 {
@@ -228,19 +216,16 @@ func TestAllocSet_filterByTainted_ClassificationRules(t *testing.T) {
228216 a .AllocStates = unknownState
229217 return a
230218 }(),
231- nodeMap : nodes ,
232219 expected : "reconnecting" ,
233220 },
234221 {
235222 name : "untainted on non tainted node" ,
236223 alloc : makeAlloc ("c13" , "missing" , structs .AllocClientStatusRunning , structs .AllocDesiredStatusRun ),
237- nodeMap : nodes ,
238224 expected : "untainted" ,
239225 },
240226 {
241227 name : "gc node lost" ,
242228 alloc : makeAlloc ("c14" , "gc" , structs .AllocClientStatusRunning , structs .AllocDesiredStatusRun ),
243- nodeMap : nodes ,
244229 expected : "lost" ,
245230 },
246231 {
@@ -250,7 +235,6 @@ func TestAllocSet_filterByTainted_ClassificationRules(t *testing.T) {
250235 setDisconnect (a , 5 * time .Minute , false )
251236 return a
252237 }(),
253- nodeMap : nodes ,
254238 expected : "untainted" ,
255239 },
256240 {
@@ -260,19 +244,16 @@ func TestAllocSet_filterByTainted_ClassificationRules(t *testing.T) {
260244 setDisconnect (a , 5 * time .Minute , false )
261245 return a
262246 }(),
263- nodeMap : nodes ,
264247 expected : "disconnecting" ,
265248 },
266249 {
267250 name : "terminal node default lost" ,
268251 alloc : makeAlloc ("c17" , "down" , structs .AllocClientStatusPending , structs .AllocDesiredStatusRun ),
269- nodeMap : nodes ,
270252 expected : "lost" ,
271253 },
272254 {
273255 name : "other tainted node defaults to untainted" ,
274256 alloc : makeAlloc ("c18" , "initializing" , structs .AllocClientStatusPending , structs .AllocDesiredStatusRun ),
275- nodeMap : nodes ,
276257 expected : "untainted" ,
277258 },
278259 }
@@ -282,7 +263,7 @@ func TestAllocSet_filterByTainted_ClassificationRules(t *testing.T) {
282263 all := allocSet {tc .alloc .ID : tc .alloc }
283264 state := ClusterState {Now : now , TaintedNodes : nodes }
284265
285- untainted , migrate , lost , disconnecting , reconnecting , ignore , expiring := all .filterByTainted (state )
266+ untainted , migrate , lost , disconnecting , reconnecting , ignore , expiring := all .classifyAllocs (state )
286267
287268 buckets := map [string ]allocSet {
288269 "untainted" : untainted ,
0 commit comments