@@ -42,16 +42,13 @@ func defaultConfig() api.AutoscalerConfig {
4242 MaxScaleUpRate : 1000.0 ,
4343 MaxScaleDownRate : 2.0 ,
4444 TargetValue : 100.0 ,
45- TotalValue : 1000.0 ,
46- TargetBurstCapacity : 211.0 ,
4745 PanicThreshold : 2.0 , // 200%
4846 PanicWindowPercentage : 10.0 ,
4947 StableWindow : 60 * time .Second ,
5048 ScaleDownDelay : 0 ,
5149 MinScale : 0 ,
5250 MaxScale : 0 ,
5351 ActivationScale : 1 ,
54- Reachable : true ,
5552 }
5653}
5754
@@ -120,7 +117,6 @@ func TestSlidingWindowAutoscaler_Scale_BasicScaling(t *testing.T) {
120117 config api.AutoscalerConfig
121118 snapshot mockMetricSnapshot
122119 expectedPodCount int32
123- expectedEBC int32 // excess burst capacity
124120 }{
125121 {
126122 name : "scale up based on stable value" ,
@@ -131,7 +127,6 @@ func TestSlidingWindowAutoscaler_Scale_BasicScaling(t *testing.T) {
131127 readyPodCount : 2 , // start with 2 pods instead of 1
132128 },
133129 expectedPodCount : 3 , // ceil(250/100)
134- expectedEBC : 1539 , // floor(2*1000 - 211 - 250)
135130 },
136131 {
137132 name : "scale down based on stable value" ,
@@ -142,7 +137,6 @@ func TestSlidingWindowAutoscaler_Scale_BasicScaling(t *testing.T) {
142137 readyPodCount : 5 ,
143138 },
144139 expectedPodCount : 2 , // limited by max scale down rate (5/2.0)
145- expectedEBC : 4739 , // floor(5*1000 - 211 - 50)
146140 },
147141 {
148142 name : "respect min scale" ,
@@ -217,11 +211,6 @@ func TestSlidingWindowAutoscaler_Scale_BasicScaling(t *testing.T) {
217211 if recommendation .DesiredPodCount != tt .expectedPodCount {
218212 t .Errorf ("expected pod count %d, got %d" , tt .expectedPodCount , recommendation .DesiredPodCount )
219213 }
220- if tt .expectedEBC != 0 && (tt .name == "scale up based on stable value" || tt .name == "scale down based on stable value" ) {
221- if recommendation .ExcessBurstCapacity != tt .expectedEBC {
222- t .Errorf ("expected excess burst capacity %d, got %d" , tt .expectedEBC , recommendation .ExcessBurstCapacity )
223- }
224- }
225214 })
226215 }
227216}
@@ -356,27 +345,6 @@ func TestSlidingWindowAutoscaler_Scale_ScaleToZero(t *testing.T) {
356345 }
357346}
358347
359- func TestSlidingWindowAutoscaler_Scale_NotReachable (t * testing.T ) {
360- config := defaultConfig ()
361- config .Reachable = false
362-
363- autoscaler := NewSlidingWindowAutoscaler (config )
364- now := time .Now ()
365-
366- // When not reachable, maxScaleDown should be 0
367- snapshot := & mockMetricSnapshot {
368- stableValue : 10 , // very low load
369- panicValue : 10 ,
370- readyPodCount : 5 ,
371- timestamp : now ,
372- }
373-
374- recommendation := autoscaler .Scale (snapshot , now )
375- if recommendation .DesiredPodCount != 1 {
376- t .Errorf ("expected pod count 1 (no scale down limit when not reachable), got %d" , recommendation .DesiredPodCount )
377- }
378- }
379-
380348func TestSlidingWindowAutoscaler_Scale_ActivationScaleWithZeroMetrics (t * testing.T ) {
381349 config := defaultConfig ()
382350 config .ActivationScale = 3
@@ -420,59 +388,6 @@ func TestSlidingWindowAutoscaler_Scale_ReadyPodCountZero(t *testing.T) {
420388 }
421389}
422390
423- func TestCalculateExcessBurstCapacity (t * testing.T ) {
424- tests := []struct {
425- name string
426- readyPods int32
427- totalValue float64
428- targetBurstCapacity float64
429- observedPanicValue float64
430- expected int32
431- }{
432- {
433- name : "positive excess capacity" ,
434- readyPods : 5 ,
435- totalValue : 1000 ,
436- targetBurstCapacity : 211 ,
437- observedPanicValue : 500 ,
438- expected : 4289 , // floor(5*1000 - 211 - 500)
439- },
440- {
441- name : "negative excess capacity" ,
442- readyPods : 1 ,
443- totalValue : 1000 ,
444- targetBurstCapacity : 211 ,
445- observedPanicValue : 1000 ,
446- expected : - 211 , // floor(1*1000 - 211 - 1000)
447- },
448- {
449- name : "zero target burst capacity" ,
450- readyPods : 5 ,
451- totalValue : 1000 ,
452- targetBurstCapacity : 0 ,
453- observedPanicValue : 500 ,
454- expected : 0 ,
455- },
456- {
457- name : "negative target burst capacity (unlimited)" ,
458- readyPods : 5 ,
459- totalValue : 1000 ,
460- targetBurstCapacity : - 1 ,
461- observedPanicValue : 500 ,
462- expected : - 1 ,
463- },
464- }
465-
466- for _ , tt := range tests {
467- t .Run (tt .name , func (t * testing.T ) {
468- result := calculateExcessBurstCapacity (tt .readyPods , tt .totalValue , tt .targetBurstCapacity , tt .observedPanicValue )
469- if result != tt .expected {
470- t .Errorf ("expected %d, got %d" , tt .expected , result )
471- }
472- })
473- }
474- }
475-
476391// Tests for PanicModeCalculator
477392func TestNewPanicModeCalculator (t * testing.T ) {
478393 config := defaultConfig ()
0 commit comments