Allow min-scale

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis
2017-11-29 21:58:11 +00:00
parent 12c5f4926e
commit 2452fdea0b
6 changed files with 105 additions and 25 deletions

View File

@ -10,7 +10,8 @@ import (
)
func TestScale1to5(t *testing.T) {
newReplicas := handlers.CalculateReplicas("firing", 1, 20)
minReplicas := uint64(1)
newReplicas := handlers.CalculateReplicas("firing", 1, 20, minReplicas)
if newReplicas != 5 {
t.Log("Expected increment in blocks of 5 from 1 to 5")
t.Fail()
@ -18,7 +19,8 @@ func TestScale1to5(t *testing.T) {
}
func TestScale5to10(t *testing.T) {
newReplicas := handlers.CalculateReplicas("firing", 5, 20)
minReplicas := uint64(1)
newReplicas := handlers.CalculateReplicas("firing", 5, 20, minReplicas)
if newReplicas != 10 {
t.Log("Expected increment in blocks of 5 from 5 to 10")
t.Fail()
@ -26,7 +28,8 @@ func TestScale5to10(t *testing.T) {
}
func TestScaleCeilingOf20Replicas_Noaction(t *testing.T) {
newReplicas := handlers.CalculateReplicas("firing", 20, 20)
minReplicas := uint64(1)
newReplicas := handlers.CalculateReplicas("firing", 20, 20, minReplicas)
if newReplicas != 20 {
t.Log("Expected ceiling of 20 replicas")
t.Fail()
@ -34,7 +37,8 @@ func TestScaleCeilingOf20Replicas_Noaction(t *testing.T) {
}
func TestScaleCeilingOf20Replicas(t *testing.T) {
newReplicas := handlers.CalculateReplicas("firing", 19, 20)
minReplicas := uint64(1)
newReplicas := handlers.CalculateReplicas("firing", 19, 20, minReplicas)
if newReplicas != 20 {
t.Log("Expected ceiling of 20 replicas")
t.Fail()
@ -42,7 +46,8 @@ func TestScaleCeilingOf20Replicas(t *testing.T) {
}
func TestBackingOff10to1(t *testing.T) {
newReplicas := handlers.CalculateReplicas("resolved", 10, 20)
minReplicas := uint64(1)
newReplicas := handlers.CalculateReplicas("resolved", 10, 20, minReplicas)
if newReplicas != 1 {
t.Log("Expected backing off to 1 replica")
t.Fail()