mirror of https://github.com/hashicorp/consul
33 lines
587 B
Go
33 lines
587 B
Go
package agent
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestAEScale(t *testing.T) {
|
|
intv := time.Minute
|
|
if v := aeScale(intv, 100); v != intv {
|
|
t.Fatalf("Bad: %v", v)
|
|
}
|
|
if v := aeScale(intv, 200); v != 2*intv {
|
|
t.Fatalf("Bad: %v", v)
|
|
}
|
|
if v := aeScale(intv, 1000); v != 4*intv {
|
|
t.Fatalf("Bad: %v", v)
|
|
}
|
|
if v := aeScale(intv, 10000); v != 8*intv {
|
|
t.Fatalf("Bad: %v", v)
|
|
}
|
|
}
|
|
|
|
func TestRandomStagger(t *testing.T) {
|
|
intv := time.Minute
|
|
for i := 0; i < 10; i++ {
|
|
stagger := randomStagger(intv)
|
|
if stagger < 0 || stagger >= intv {
|
|
t.Fatalf("Bad: %v", stagger)
|
|
}
|
|
}
|
|
}
|