@@ -154,7 +154,7 @@ func TestInProgressActions(t *testing.T) {
154
154
transition database.WorkspaceTransition
155
155
desired int32
156
156
running int32
157
- pending int32
157
+ inProgress int32
158
158
checkFn func (actions prebuilds.ReconciliationActions ) bool
159
159
}{
160
160
// With no running prebuilds and one starting, no creations/deletions should take place.
@@ -163,7 +163,7 @@ func TestInProgressActions(t *testing.T) {
163
163
transition : database .WorkspaceTransitionStart ,
164
164
desired : 1 ,
165
165
running : 0 ,
166
- pending : 1 ,
166
+ inProgress : 1 ,
167
167
checkFn : func (actions prebuilds.ReconciliationActions ) bool {
168
168
return assert .True (t , validateActions (t , prebuilds.ReconciliationActions {Desired : 1 , Starting : 1 }, actions ))
169
169
},
@@ -174,7 +174,7 @@ func TestInProgressActions(t *testing.T) {
174
174
transition : database .WorkspaceTransitionStart ,
175
175
desired : 2 ,
176
176
running : 1 ,
177
- pending : 1 ,
177
+ inProgress : 1 ,
178
178
checkFn : func (actions prebuilds.ReconciliationActions ) bool {
179
179
return assert .True (t , validateActions (t , prebuilds.ReconciliationActions {Actual : 1 , Desired : 2 , Starting : 1 }, actions ))
180
180
},
@@ -186,7 +186,7 @@ func TestInProgressActions(t *testing.T) {
186
186
transition : database .WorkspaceTransitionStart ,
187
187
desired : 2 ,
188
188
running : 2 ,
189
- pending : 1 ,
189
+ inProgress : 1 ,
190
190
checkFn : func (actions prebuilds.ReconciliationActions ) bool {
191
191
return assert .True (t , validateActions (t , prebuilds.ReconciliationActions {Actual : 2 , Desired : 2 , Starting : 1 }, actions ))
192
192
},
@@ -197,7 +197,7 @@ func TestInProgressActions(t *testing.T) {
197
197
transition : database .WorkspaceTransitionStop ,
198
198
desired : 1 ,
199
199
running : 0 ,
200
- pending : 1 ,
200
+ inProgress : 1 ,
201
201
checkFn : func (actions prebuilds.ReconciliationActions ) bool {
202
202
return assert .True (t , validateActions (t , prebuilds.ReconciliationActions {Desired : 1 , Stopping : 1 , Create : 1 }, actions ))
203
203
},
@@ -208,7 +208,7 @@ func TestInProgressActions(t *testing.T) {
208
208
transition : database .WorkspaceTransitionStop ,
209
209
desired : 3 ,
210
210
running : 2 ,
211
- pending : 1 ,
211
+ inProgress : 1 ,
212
212
checkFn : func (actions prebuilds.ReconciliationActions ) bool {
213
213
return assert .True (t , validateActions (t , prebuilds.ReconciliationActions {Actual : 2 , Desired : 3 , Stopping : 1 , Create : 1 }, actions ))
214
214
},
@@ -219,7 +219,7 @@ func TestInProgressActions(t *testing.T) {
219
219
transition : database .WorkspaceTransitionStop ,
220
220
desired : 3 ,
221
221
running : 3 ,
222
- pending : 1 ,
222
+ inProgress : 1 ,
223
223
checkFn : func (actions prebuilds.ReconciliationActions ) bool {
224
224
return assert .True (t , validateActions (t , prebuilds.ReconciliationActions {Actual : 3 , Desired : 3 , Stopping : 1 }, actions ))
225
225
},
@@ -230,7 +230,7 @@ func TestInProgressActions(t *testing.T) {
230
230
transition : database .WorkspaceTransitionDelete ,
231
231
desired : 1 ,
232
232
running : 0 ,
233
- pending : 1 ,
233
+ inProgress : 1 ,
234
234
checkFn : func (actions prebuilds.ReconciliationActions ) bool {
235
235
return assert .True (t , validateActions (t , prebuilds.ReconciliationActions {Desired : 1 , Deleting : 1 , Create : 1 }, actions ))
236
236
},
@@ -241,7 +241,7 @@ func TestInProgressActions(t *testing.T) {
241
241
transition : database .WorkspaceTransitionDelete ,
242
242
desired : 2 ,
243
243
running : 1 ,
244
- pending : 1 ,
244
+ inProgress : 1 ,
245
245
checkFn : func (actions prebuilds.ReconciliationActions ) bool {
246
246
return assert .True (t , validateActions (t , prebuilds.ReconciliationActions {Actual : 1 , Desired : 2 , Deleting : 1 , Create : 1 }, actions ))
247
247
},
@@ -252,7 +252,7 @@ func TestInProgressActions(t *testing.T) {
252
252
transition : database .WorkspaceTransitionDelete ,
253
253
desired : 2 ,
254
254
running : 2 ,
255
- pending : 1 ,
255
+ inProgress : 1 ,
256
256
checkFn : func (actions prebuilds.ReconciliationActions ) bool {
257
257
return assert .True (t , validateActions (t , prebuilds.ReconciliationActions {Actual : 2 , Desired : 2 , Deleting : 1 }, actions ))
258
258
},
@@ -263,22 +263,21 @@ func TestInProgressActions(t *testing.T) {
263
263
transition : database .WorkspaceTransitionStart ,
264
264
desired : 3 ,
265
265
running : 1 ,
266
- pending : 2 ,
266
+ inProgress : 2 ,
267
267
checkFn : func (actions prebuilds.ReconciliationActions ) bool {
268
268
return assert .True (t , validateActions (t , prebuilds.ReconciliationActions {Actual : 1 , Desired : 3 , Starting : 2 , Create : 0 }, actions ))
269
269
},
270
270
},
271
- // With 3 prebuilds desired, 1 running, and 2 starting , no creations should occur since the builds are in progress.
271
+ // With 3 prebuilds desired, 5 running, and 2 deleting , no deletions should occur since the builds are in progress.
272
272
{
273
273
name : fmt .Sprintf ("%s-inhibit" , database .WorkspaceTransitionDelete ),
274
274
transition : database .WorkspaceTransitionDelete ,
275
275
desired : 3 ,
276
276
running : 5 ,
277
- pending : 2 ,
277
+ inProgress : 2 ,
278
278
checkFn : func (actions prebuilds.ReconciliationActions ) bool {
279
279
expected := prebuilds.ReconciliationActions {Actual : 5 , Desired : 3 , Deleting : 2 , Extraneous : 2 }
280
- //return assert.True(t, validateActions(t, expected, actions))
281
- return assert .Len (t , actions .DeleteIDs , 0 , "'deleteIDs' did not match expectation" ) &&
280
+ return assert .Len (t , actions .DeleteIDs , 2 , "'deleteIDs' did not match expectation" ) &&
282
281
assert .EqualValuesf (t , expected .Create , actions .Create , "'create' did not match expectation" ) &&
283
282
assert .EqualValuesf (t , expected .Desired , actions .Desired , "'desired' did not match expectation" ) &&
284
283
assert .EqualValuesf (t , expected .Actual , actions .Actual , "'actual' did not match expectation" ) &&
@@ -323,7 +322,7 @@ func TestInProgressActions(t *testing.T) {
323
322
TemplateID : current .templateID ,
324
323
TemplateVersionID : current .templateVersionID ,
325
324
Transition : tc .transition ,
326
- Count : tc .pending ,
325
+ Count : tc .inProgress ,
327
326
},
328
327
}
329
328
@@ -381,48 +380,6 @@ func TestExtraneous(t *testing.T) {
381
380
}, * actions )
382
381
}
383
382
384
- // As above, but no actions will be performed because
385
- func TestExtraneousInProgress (t * testing.T ) {
386
- current := opts [optionSet0 ]
387
- clock := quartz .NewMock (t )
388
-
389
- const desiredInstances = 2 ;
390
-
391
- // GIVEN: a preset with 2 desired prebuilds.
392
- presets := []database.GetTemplatePresetsWithPrebuildsRow {
393
- preset (true , desiredInstances , current ),
394
- }
395
-
396
- // GIVEN: 3 running prebuilds for the preset.
397
- running := []database.GetRunningPrebuildsRow {
398
- prebuild (current , clock ),
399
- prebuild (current , clock ),
400
- prebuild (current , clock ),
401
- }
402
-
403
- // GIVEN: a prebuild deletion in progress.
404
- inProgress := []database.GetPrebuildsInProgressRow {
405
- {
406
- TemplateID : current .templateID ,
407
- TemplateVersionID : current .templateVersionID ,
408
- Transition : database .WorkspaceTransitionDelete ,
409
- Count : 1 ,
410
- },
411
- }
412
-
413
- // WHEN: calculating the current preset's state.
414
- state := prebuilds .NewReconciliationState (presets , running , inProgress , nil )
415
- ps , err := state .FilterByPreset (current .presetID )
416
- require .NoError (t , err )
417
-
418
- // THEN: an extraneous prebuild is detected and marked for deletion.
419
- actions , err := ps .CalculateActions (clock , backoffInterval )
420
- require .NoError (t , err )
421
- validateActions (t , prebuilds.ReconciliationActions {
422
- Actual : 3 , Desired : desiredInstances , Extraneous : 1 , Deleting : 1 , DeleteIDs : nil , Eligible : 3 ,
423
- }, * actions )
424
- }
425
-
426
383
// A template marked as deprecated will not have prebuilds running.
427
384
func TestDeprecated (t * testing.T ) {
428
385
current := opts [optionSet0 ]
0 commit comments