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