Update for scaling edge-case

- as reported on Slack and in issue #931 the gateway scaling code
was scaling to zero replicas as a result of the "proportional
scaling" added by @Templum's PR. This commit added a failing test
which was fixed by adding boundary checking - now if the scaling
amount is "0" we keep the current amount of replicas.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis (VMware)
2018-10-25 09:54:02 +01:00
committed by Alex Ellis
parent 4a6c6afe94
commit f5939c9a60
2 changed files with 15 additions and 5 deletions

View File

@ -11,8 +11,8 @@ func TestDisabledScale(t *testing.T) {
minReplicas := uint64(1)
scalingFactor := uint64(0)
newReplicas := CalculateReplicas("firing", DefaultMinReplicas, DefaultMaxReplicas, minReplicas, scalingFactor)
if newReplicas != 0 {
t.Log("Expected not to scale")
if newReplicas != minReplicas {
t.Logf("Expected not to scale, but replicas were: %d", newReplicas)
t.Fail()
}
}
@ -27,6 +27,17 @@ func TestParameterEdge(t *testing.T) {
}
}
func TestScalingWithSameUpperLowerLimit(t *testing.T) {
minReplicas := uint64(1)
scalingFactor := uint64(20)
// status string, currentReplicas uint64, maxReplicas uint64, minReplicas uint64, scalingFactor uint64)
newReplicas := CalculateReplicas("firing", minReplicas, minReplicas, minReplicas, scalingFactor)
if newReplicas != 1 {
t.Logf("Replicas - want: %d, got: %d", minReplicas, newReplicas)
t.Fail()
}
}
func TestMaxScale(t *testing.T) {
minReplicas := uint64(1)
scalingFactor := uint64(100)