@@ -207,10 +207,11 @@ func TestGitLabRunnerScaler_GetMetricsAndActivity(t *testing.T) {
207
207
pipelineWaitingForResourceQueueLength int64
208
208
pipelineRunningQueueLength int64
209
209
210
- targetPipelineQueueLength int64
211
- expectedMetricValue int64
212
- expectedActive bool
213
- expectError bool
210
+ targetPipelineQueueLength int64
211
+ activationTargetPipelineQueueLength int64
212
+ expectedMetricValue int64
213
+ expectedActive bool
214
+ expectError bool
214
215
}{
215
216
{
216
217
name : "Queue length below target" ,
@@ -219,10 +220,11 @@ func TestGitLabRunnerScaler_GetMetricsAndActivity(t *testing.T) {
219
220
pipelineWaitingForResourceQueueLength : 0 ,
220
221
pipelineRunningQueueLength : 0 ,
221
222
222
- targetPipelineQueueLength : 5 ,
223
- expectedMetricValue : 2 ,
224
- expectedActive : false ,
225
- expectError : false ,
223
+ targetPipelineQueueLength : 5 ,
224
+ activationTargetPipelineQueueLength : 3 ,
225
+ expectedMetricValue : 2 ,
226
+ expectedActive : false ,
227
+ expectError : false ,
226
228
},
227
229
{
228
230
name : "Queue length equal to target" ,
@@ -231,10 +233,11 @@ func TestGitLabRunnerScaler_GetMetricsAndActivity(t *testing.T) {
231
233
pipelineWaitingForResourceQueueLength : 0 ,
232
234
pipelineRunningQueueLength : 0 ,
233
235
234
- targetPipelineQueueLength : 5 ,
235
- expectedMetricValue : 5 ,
236
- expectedActive : true ,
237
- expectError : false ,
236
+ targetPipelineQueueLength : 5 ,
237
+ activationTargetPipelineQueueLength : 3 ,
238
+ expectedMetricValue : 5 ,
239
+ expectedActive : true ,
240
+ expectError : false ,
238
241
},
239
242
{
240
243
name : "Queue length above target" ,
@@ -243,10 +246,11 @@ func TestGitLabRunnerScaler_GetMetricsAndActivity(t *testing.T) {
243
246
pipelineWaitingForResourceQueueLength : 0 ,
244
247
pipelineRunningQueueLength : 0 ,
245
248
246
- targetPipelineQueueLength : 5 ,
247
- expectedMetricValue : 10 ,
248
- expectedActive : true ,
249
- expectError : false ,
249
+ targetPipelineQueueLength : 5 ,
250
+ activationTargetPipelineQueueLength : 3 ,
251
+ expectedMetricValue : 10 ,
252
+ expectedActive : true ,
253
+ expectError : false ,
250
254
},
251
255
{
252
256
name : "Queue length is sum of statuses" ,
@@ -255,10 +259,11 @@ func TestGitLabRunnerScaler_GetMetricsAndActivity(t *testing.T) {
255
259
pipelineWaitingForResourceQueueLength : 3 ,
256
260
pipelineRunningQueueLength : 5 ,
257
261
258
- targetPipelineQueueLength : 5 ,
259
- expectedMetricValue : 9 ,
260
- expectedActive : true ,
261
- expectError : false ,
262
+ targetPipelineQueueLength : 5 ,
263
+ activationTargetPipelineQueueLength : 3 ,
264
+ expectedMetricValue : 9 ,
265
+ expectedActive : true ,
266
+ expectError : false ,
262
267
},
263
268
{
264
269
name : "Error retrieving queue length" ,
@@ -267,10 +272,11 @@ func TestGitLabRunnerScaler_GetMetricsAndActivity(t *testing.T) {
267
272
pipelineWaitingForResourceQueueLength : 0 ,
268
273
pipelineRunningQueueLength : 0 ,
269
274
270
- targetPipelineQueueLength : 5 ,
271
- expectedMetricValue : 0 ,
272
- expectedActive : false ,
273
- expectError : true ,
275
+ targetPipelineQueueLength : 5 ,
276
+ activationTargetPipelineQueueLength : 3 ,
277
+ expectedMetricValue : 0 ,
278
+ expectedActive : false ,
279
+ expectError : true ,
274
280
},
275
281
}
276
282
@@ -323,10 +329,11 @@ func TestGitLabRunnerScaler_GetMetricsAndActivity(t *testing.T) {
323
329
defer server .Close ()
324
330
325
331
meta := & gitlabRunnerMetadata {
326
- GitLabAPIURL : mustParseURL (server .URL ),
327
- PersonalAccessToken : "test-token" ,
328
- TargetPipelineQueueLength : tc .targetPipelineQueueLength ,
329
- ProjectID : "12345" ,
332
+ GitLabAPIURL : mustParseURL (server .URL ),
333
+ PersonalAccessToken : "test-token" ,
334
+ TargetPipelineQueueLength : tc .targetPipelineQueueLength ,
335
+ ActivationTargetPipelineQueueLength : tc .activationTargetPipelineQueueLength ,
336
+ ProjectID : "12345" ,
330
337
}
331
338
332
339
scaler := gitlabRunnerScaler {
@@ -354,7 +361,7 @@ func TestGitLabRunnerScaler_GetMetricSpecForScaling(t *testing.T) {
354
361
meta := & gitlabRunnerMetadata {
355
362
ProjectID : "12345" ,
356
363
TargetPipelineQueueLength : 5 ,
357
- TriggerIndex : 0 ,
364
+ TriggerIndex : 1 ,
358
365
}
359
366
360
367
scaler := gitlabRunnerScaler {
@@ -367,7 +374,7 @@ func TestGitLabRunnerScaler_GetMetricSpecForScaling(t *testing.T) {
367
374
368
375
metricSpec := metricSpecs [0 ]
369
376
assert .Equal (t , v2 .ExternalMetricSourceType , metricSpec .Type )
370
- assert .Equal (t , "s0 -gitlab-runner-12345" , metricSpec .External .Metric .Name )
377
+ assert .Equal (t , "s1 -gitlab-runner-12345" , metricSpec .External .Metric .Name )
371
378
assert .Equal (t , int64 (5 ), metricSpec .External .Target .AverageValue .Value ())
372
379
}
373
380
0 commit comments