Chase the API bump re: refreshServerRebalanceTimer

If it works in prod, why shouldn't it work in the tests?
This commit is contained in:
Sean Chittenden 2016-03-27 00:04:52 -07:00
parent 3d00208351
commit 060dd49a95
1 changed files with 5 additions and 12 deletions

View File

@ -132,17 +132,8 @@ func TestServerManagerInternal_New(t *testing.T) {
} }
} }
// func (sc *serverConfig) refreshServerRebalanceTimer(timer *time.Timer) { // func (sc *serverConfig) refreshServerRebalanceTimer() {
func TestServerManagerInternal_refreshServerRebalanceTimer(t *testing.T) { func TestServerManagerInternal_refreshServerRebalanceTimer(t *testing.T) {
sm := testServerManager()
timer := time.NewTimer(time.Duration(1 * time.Nanosecond))
time.Sleep(1 * time.Millisecond)
sm.refreshServerRebalanceTimer(timer)
logger := log.New(os.Stderr, "", log.LstdFlags)
shutdownCh := make(chan struct{})
type clusterSizes struct { type clusterSizes struct {
numNodes int numNodes int
numServers int numServers int
@ -177,15 +168,17 @@ func TestServerManagerInternal_refreshServerRebalanceTimer(t *testing.T) {
{1000000, 19, 10 * time.Minute}, {1000000, 19, 10 * time.Minute},
} }
logger := log.New(os.Stderr, "", log.LstdFlags)
shutdownCh := make(chan struct{})
for _, s := range clusters { for _, s := range clusters {
sm := New(logger, shutdownCh, &fauxSerf{numNodes: s.numNodes}, &fauxConnPool{}) sm := New(logger, shutdownCh, &fauxSerf{numNodes: s.numNodes}, &fauxConnPool{})
for i := 0; i < s.numServers; i++ { for i := 0; i < s.numServers; i++ {
nodeName := fmt.Sprintf("s%02d", i) nodeName := fmt.Sprintf("s%02d", i)
sm.AddServer(&server_details.ServerDetails{Name: nodeName}) sm.AddServer(&server_details.ServerDetails{Name: nodeName})
} }
d := sm.refreshServerRebalanceTimer(timer) d := sm.refreshServerRebalanceTimer()
if d < s.minRebalance { if d < s.minRebalance {
t.Errorf("duration too short for cluster of size %d and %d servers (%s < %s)", s.numNodes, s.numServers, d, s.minRebalance) t.Errorf("duration too short for cluster of size %d and %d servers (%s < %s)", s.numNodes, s.numServers, d, s.minRebalance)
} }