func TestBalancerEmptyNodes(t *testing.T) { b := cluster.NewNodeBalancer([]meta.NodeInfo{}) got := b.Next() if got != nil { t.Errorf("expected nil, got %v", got) } }
func TestBalancerUp(t *testing.T) { nodes := NewNodes() b := cluster.NewNodeBalancer(nodes) // First node in randomized round-robin order first := b.Next() if first == nil { t.Errorf("expected datanode, got %v", first) } // Second node in randomized round-robin order second := b.Next() if second == nil { t.Errorf("expected datanode, got %v", second) } // Should never get the same node in order twice if first.ID == second.ID { t.Errorf("expected first != second. got %v = %v", first.ID, second.ID) } }