@@ -76,6 +76,7 @@ func TestAutoscalerScaleDownDelay(t *testing.T) {
76
76
MaxScaleUpRate : 10 ,
77
77
PanicThreshold : 100 ,
78
78
ScaleDownDelay : 5 * time .Minute ,
79
+ Reachable : true ,
79
80
}
80
81
as := New (context .Background (), testNamespace , testRevision , metrics , pc , spec )
81
82
@@ -128,6 +129,50 @@ func TestAutoscalerScaleDownDelay(t *testing.T) {
128
129
})
129
130
}
130
131
132
+ func TestAutoscalerScaleDownDelayNotReachable (t * testing.T ) {
133
+ pc := & fakePodCounter {}
134
+ metrics := & metricClient {}
135
+ spec := & DeciderSpec {
136
+ TargetValue : 10 ,
137
+ MaxScaleDownRate : 10 ,
138
+ MaxScaleUpRate : 10 ,
139
+ PanicThreshold : 100 ,
140
+ ScaleDownDelay : 5 * time .Minute ,
141
+ Reachable : true ,
142
+ }
143
+ as := New (context .Background (), testNamespace , testRevision , metrics , pc , spec )
144
+
145
+ now := time.Time {}
146
+
147
+ // scale up.
148
+ metrics .SetStableAndPanicConcurrency (40 , 40 )
149
+ expectScale (t , as , now .Add (2 * time .Second ), ScaleResult {
150
+ ScaleValid : true ,
151
+ DesiredPodCount : 4 ,
152
+ })
153
+ // one minute passes at reduced concurrency - should not scale down (less than delay).
154
+ metrics .SetStableAndPanicConcurrency (0 , 0 )
155
+ expectScale (t , as , now .Add (1 * time .Minute ), ScaleResult {
156
+ ScaleValid : true ,
157
+ DesiredPodCount : 4 ,
158
+ })
159
+ // mark as unreachable to simulate another revision coming up
160
+ unreachableSpec := & DeciderSpec {
161
+ TargetValue : 10 ,
162
+ MaxScaleDownRate : 10 ,
163
+ MaxScaleUpRate : 10 ,
164
+ PanicThreshold : 100 ,
165
+ ScaleDownDelay : 5 * time .Minute ,
166
+ Reachable : false ,
167
+ }
168
+ as .Update (unreachableSpec )
169
+ // 2 seconds pass at reduced concurrency - now we scale down.
170
+ expectScale (t , as , now .Add (2 * time .Second ), ScaleResult {
171
+ ScaleValid : true ,
172
+ DesiredPodCount : 0 ,
173
+ })
174
+ }
175
+
131
176
func TestAutoscalerScaleDownDelayZero (t * testing.T ) {
132
177
pc := & fakePodCounter {}
133
178
metrics := & metricClient {}
0 commit comments