Merge pull request #450 from ceh/fix-missing-arguments

Fix missing arguments
This commit is contained in:
Armon Dadgar 2014-11-01 15:23:36 -07:00
commit 916451b96c
5 changed files with 78 additions and 78 deletions

View File

@ -510,7 +510,7 @@ func TestKVS_Apply_LockDelay(t *testing.T) {
// Create and invalidate a session with a lock
state := s1.fsm.State()
if err := state.EnsureNode(1, structs.Node{"foo", "127.0.0.1"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
session := &structs.Session{
ID: generateUUID(),

View File

@ -147,7 +147,7 @@ func (s *Server) nodeJoin(me serf.MemberEvent, wan bool) {
ok, parts := isConsulServer(m)
if !ok {
if wan {
s.logger.Printf("[WARN] consul: non-server in WAN pool: %s %s", m.Name)
s.logger.Printf("[WARN] consul: non-server in WAN pool: %s", m.Name)
}
continue
}

View File

@ -35,7 +35,7 @@ func TestEnsureRegistration(t *testing.T) {
}
if err := store.EnsureRegistration(13, reg); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
idx, found, addr := store.GetNode("foo")
@ -73,7 +73,7 @@ func TestEnsureNode(t *testing.T) {
defer store.Close()
if err := store.EnsureNode(3, structs.Node{"foo", "127.0.0.1"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
idx, found, addr := store.GetNode("foo")
@ -82,7 +82,7 @@ func TestEnsureNode(t *testing.T) {
}
if err := store.EnsureNode(4, structs.Node{"foo", "127.0.0.2"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
idx, found, addr = store.GetNode("foo")
@ -99,11 +99,11 @@ func TestGetNodes(t *testing.T) {
defer store.Close()
if err := store.EnsureNode(40, structs.Node{"foo", "127.0.0.1"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureNode(41, structs.Node{"bar", "127.0.0.2"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
idx, nodes := store.Nodes()
@ -126,11 +126,11 @@ func BenchmarkGetNodes(b *testing.B) {
defer store.Close()
if err := store.EnsureNode(100, structs.Node{"foo", "127.0.0.1"}); err != nil {
b.Fatalf("err: %v")
b.Fatalf("err: %v", err)
}
if err := store.EnsureNode(101, structs.Node{"bar", "127.0.0.2"}); err != nil {
b.Fatalf("err: %v")
b.Fatalf("err: %v", err)
}
for i := 0; i < b.N; i++ {
@ -259,7 +259,7 @@ func TestDeleteNodeService(t *testing.T) {
ServiceID: "api",
}
if err := store.EnsureCheck(13, check); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.DeleteNodeService(14, "foo", "api"); err != nil {
@ -329,11 +329,11 @@ func TestDeleteNode(t *testing.T) {
defer store.Close()
if err := store.EnsureNode(20, structs.Node{"foo", "127.0.0.1"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(21, "foo", &structs.NodeService{"api", "api", nil, 5000}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
check := &structs.HealthCheck{
@ -384,23 +384,23 @@ func TestGetServices(t *testing.T) {
defer store.Close()
if err := store.EnsureNode(30, structs.Node{"foo", "127.0.0.1"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureNode(31, structs.Node{"bar", "127.0.0.2"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(32, "foo", &structs.NodeService{"api", "api", nil, 5000}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(33, "foo", &structs.NodeService{"db", "db", []string{"master"}, 8000}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(34, "bar", &structs.NodeService{"db", "db", []string{"slave"}, 8000}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
idx, services := store.Services()
@ -434,31 +434,31 @@ func TestServiceNodes(t *testing.T) {
defer store.Close()
if err := store.EnsureNode(10, structs.Node{"foo", "127.0.0.1"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureNode(11, structs.Node{"bar", "127.0.0.2"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(12, "foo", &structs.NodeService{"api", "api", nil, 5000}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(13, "bar", &structs.NodeService{"api", "api", nil, 5000}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(14, "foo", &structs.NodeService{"db", "db", []string{"master"}, 8000}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(15, "bar", &structs.NodeService{"db", "db", []string{"slave"}, 8000}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(16, "bar", &structs.NodeService{"db2", "db", []string{"slave"}, 8001}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
idx, nodes := store.ServiceNodes("db")
@ -525,23 +525,23 @@ func TestServiceTagNodes(t *testing.T) {
defer store.Close()
if err := store.EnsureNode(15, structs.Node{"foo", "127.0.0.1"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureNode(16, structs.Node{"bar", "127.0.0.2"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(17, "foo", &structs.NodeService{"db", "db", []string{"master"}, 8000}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(18, "foo", &structs.NodeService{"db2", "db", []string{"slave"}, 8001}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(19, "bar", &structs.NodeService{"db", "db", []string{"slave"}, 8000}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
idx, nodes := store.ServiceTagNodes("db", "master")
@ -573,23 +573,23 @@ func TestServiceTagNodes_MultipleTags(t *testing.T) {
defer store.Close()
if err := store.EnsureNode(15, structs.Node{"foo", "127.0.0.1"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureNode(16, structs.Node{"bar", "127.0.0.2"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(17, "foo", &structs.NodeService{"db", "db", []string{"master", "v2"}, 8000}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(18, "foo", &structs.NodeService{"db2", "db", []string{"slave", "v2", "dev"}, 8001}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(19, "bar", &structs.NodeService{"db", "db", []string{"slave", "v2"}, 8000}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
idx, nodes := store.ServiceTagNodes("db", "master")
@ -649,23 +649,23 @@ func TestStoreSnapshot(t *testing.T) {
defer store.Close()
if err := store.EnsureNode(8, structs.Node{"foo", "127.0.0.1"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureNode(9, structs.Node{"bar", "127.0.0.2"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(10, "foo", &structs.NodeService{"db", "db", []string{"master"}, 8000}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(11, "foo", &structs.NodeService{"db2", "db", []string{"slave"}, 8001}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(12, "bar", &structs.NodeService{"db", "db", []string{"slave"}, 8000}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
check := &structs.HealthCheck{
@ -676,7 +676,7 @@ func TestStoreSnapshot(t *testing.T) {
ServiceID: "db",
}
if err := store.EnsureCheck(13, check); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
// Add some KVS entries
@ -725,7 +725,7 @@ func TestStoreSnapshot(t *testing.T) {
// Take a snapshot
snap, err := store.Snapshot()
if err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
defer snap.Close()
@ -913,7 +913,7 @@ func TestEnsureCheck(t *testing.T) {
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(2, "foo", &structs.NodeService{"db1", "db", []string{"master"}, 8000}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
check := &structs.HealthCheck{
Node: "foo",
@ -923,7 +923,7 @@ func TestEnsureCheck(t *testing.T) {
ServiceID: "db1",
}
if err := store.EnsureCheck(3, check); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
check2 := &structs.HealthCheck{
@ -933,7 +933,7 @@ func TestEnsureCheck(t *testing.T) {
Status: structs.HealthWarning,
}
if err := store.EnsureCheck(4, check2); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
idx, checks := store.NodeChecks("foo")
@ -1009,7 +1009,7 @@ func TestDeleteNodeCheck(t *testing.T) {
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(2, "foo", &structs.NodeService{"db1", "db", []string{"master"}, 8000}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
check := &structs.HealthCheck{
Node: "foo",
@ -1019,7 +1019,7 @@ func TestDeleteNodeCheck(t *testing.T) {
ServiceID: "db1",
}
if err := store.EnsureCheck(3, check); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
check2 := &structs.HealthCheck{
@ -1029,7 +1029,7 @@ func TestDeleteNodeCheck(t *testing.T) {
Status: structs.HealthWarning,
}
if err := store.EnsureCheck(4, check2); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.DeleteNodeCheck(5, "foo", "db"); err != nil {
@ -1059,7 +1059,7 @@ func TestCheckServiceNodes(t *testing.T) {
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(2, "foo", &structs.NodeService{"db1", "db", []string{"master"}, 8000}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
check := &structs.HealthCheck{
Node: "foo",
@ -1069,7 +1069,7 @@ func TestCheckServiceNodes(t *testing.T) {
ServiceID: "db1",
}
if err := store.EnsureCheck(3, check); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
check = &structs.HealthCheck{
Node: "foo",
@ -1078,7 +1078,7 @@ func TestCheckServiceNodes(t *testing.T) {
Status: structs.HealthPassing,
}
if err := store.EnsureCheck(4, check); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
idx, nodes := store.CheckServiceNodes("db")
@ -1140,7 +1140,7 @@ func BenchmarkCheckServiceNodes(t *testing.B) {
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(2, "foo", &structs.NodeService{"db1", "db", []string{"master"}, 8000}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
check := &structs.HealthCheck{
Node: "foo",
@ -1150,7 +1150,7 @@ func BenchmarkCheckServiceNodes(t *testing.B) {
ServiceID: "db1",
}
if err := store.EnsureCheck(3, check); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
check = &structs.HealthCheck{
Node: "foo",
@ -1159,7 +1159,7 @@ func BenchmarkCheckServiceNodes(t *testing.B) {
Status: structs.HealthPassing,
}
if err := store.EnsureCheck(4, check); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
for i := 0; i < t.N; i++ {
@ -1184,7 +1184,7 @@ func TestSS_Register_Deregister_Query(t *testing.T) {
nil,
0}
if err := store.EnsureService(2, "foo", srv); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
srv = &structs.NodeService{
@ -1193,7 +1193,7 @@ func TestSS_Register_Deregister_Query(t *testing.T) {
nil,
0}
if err := store.EnsureService(3, "foo", srv); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.DeleteNode(4, "foo"); err != nil {
@ -1220,7 +1220,7 @@ func TestNodeInfo(t *testing.T) {
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(2, "foo", &structs.NodeService{"db1", "db", []string{"master"}, 8000}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
check := &structs.HealthCheck{
Node: "foo",
@ -1230,7 +1230,7 @@ func TestNodeInfo(t *testing.T) {
ServiceID: "db1",
}
if err := store.EnsureCheck(3, check); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
check = &structs.HealthCheck{
Node: "foo",
@ -1239,7 +1239,7 @@ func TestNodeInfo(t *testing.T) {
Status: structs.HealthPassing,
}
if err := store.EnsureCheck(4, check); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
idx, dump := store.NodeInfo("foo")
@ -1279,13 +1279,13 @@ func TestNodeDump(t *testing.T) {
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(2, "foo", &structs.NodeService{"db1", "db", []string{"master"}, 8000}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.EnsureNode(3, structs.Node{"baz", "127.0.0.2"}); err != nil {
t.Fatalf("err: %v", err)
}
if err := store.EnsureService(4, "baz", &structs.NodeService{"db1", "db", []string{"master"}, 8000}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
idx, dump := store.NodeDump()
@ -1711,7 +1711,7 @@ func TestSessionCreate(t *testing.T) {
defer store.Close()
if err := store.EnsureNode(3, structs.Node{"foo", "127.0.0.1"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
check := &structs.HealthCheck{
Node: "foo",
@ -1719,7 +1719,7 @@ func TestSessionCreate(t *testing.T) {
Status: structs.HealthPassing,
}
if err := store.EnsureCheck(13, check); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
session := &structs.Session{
@ -1756,7 +1756,7 @@ func TestSessionCreate_Invalid(t *testing.T) {
// Check not registered
if err := store.EnsureNode(3, structs.Node{"foo", "127.0.0.1"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
if err := store.SessionCreate(1000, session); err.Error() != "Missing check 'bar' registration" {
t.Fatalf("err: %v", err)
@ -1785,7 +1785,7 @@ func TestSession_Lookups(t *testing.T) {
// Create a session
if err := store.EnsureNode(3, structs.Node{"foo", "127.0.0.1"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
session := &structs.Session{
ID: generateUUID(),
@ -1870,7 +1870,7 @@ func TestSessionInvalidate_CriticalHealthCheck(t *testing.T) {
defer store.Close()
if err := store.EnsureNode(3, structs.Node{"foo", "127.0.0.1"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
check := &structs.HealthCheck{
Node: "foo",
@ -1878,7 +1878,7 @@ func TestSessionInvalidate_CriticalHealthCheck(t *testing.T) {
Status: structs.HealthPassing,
}
if err := store.EnsureCheck(13, check); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
session := &structs.Session{
@ -1914,7 +1914,7 @@ func TestSessionInvalidate_DeleteHealthCheck(t *testing.T) {
defer store.Close()
if err := store.EnsureNode(3, structs.Node{"foo", "127.0.0.1"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
check := &structs.HealthCheck{
Node: "foo",
@ -1922,7 +1922,7 @@ func TestSessionInvalidate_DeleteHealthCheck(t *testing.T) {
Status: structs.HealthPassing,
}
if err := store.EnsureCheck(13, check); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
session := &structs.Session{
@ -1957,7 +1957,7 @@ func TestSessionInvalidate_DeleteNode(t *testing.T) {
defer store.Close()
if err := store.EnsureNode(3, structs.Node{"foo", "127.0.0.1"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
session := &structs.Session{
@ -1970,7 +1970,7 @@ func TestSessionInvalidate_DeleteNode(t *testing.T) {
// Delete the node
if err := store.DeleteNode(15, "foo"); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
// Lookup by ID, should be nil
@ -2004,7 +2004,7 @@ func TestSessionInvalidate_DeleteNodeService(t *testing.T) {
ServiceID: "api",
}
if err := store.EnsureCheck(13, check); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
session := &structs.Session{
@ -2039,7 +2039,7 @@ func TestKVSLock(t *testing.T) {
defer store.Close()
if err := store.EnsureNode(3, structs.Node{"foo", "127.0.0.1"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
session := &structs.Session{ID: generateUUID(), Node: "foo"}
if err := store.SessionCreate(4, session); err != nil {
@ -2112,7 +2112,7 @@ func TestKVSUnlock(t *testing.T) {
defer store.Close()
if err := store.EnsureNode(3, structs.Node{"foo", "127.0.0.1"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
session := &structs.Session{ID: generateUUID(), Node: "foo"}
if err := store.SessionCreate(4, session); err != nil {
@ -2170,7 +2170,7 @@ func TestSessionInvalidate_KeyUnlock(t *testing.T) {
defer store.Close()
if err := store.EnsureNode(3, structs.Node{"foo", "127.0.0.1"}); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
session := &structs.Session{
ID: generateUUID(),
@ -2198,7 +2198,7 @@ func TestSessionInvalidate_KeyUnlock(t *testing.T) {
// Delete the node
if err := store.DeleteNode(6, "foo"); err != nil {
t.Fatalf("err: %v")
t.Fatalf("err: %v", err)
}
// Key should be unlocked

View File

@ -97,7 +97,7 @@ func TestIsConsulNode(t *testing.T) {
}
valid, dc := isConsulNode(m)
if !valid || dc != "east-aws" {
t.Fatalf("bad: %v %v %v", valid, dc)
t.Fatalf("bad: %v %v", valid, dc)
}
}

View File

@ -107,7 +107,7 @@ func assignValue(params map[string]interface{}, name string, out *string) error
if raw, ok := params[name]; ok {
val, ok := raw.(string)
if !ok {
return fmt.Errorf("Expecting %s to be a string")
return fmt.Errorf("Expecting %s to be a string", name)
}
*out = val
delete(params, name)
@ -120,7 +120,7 @@ func assignValueBool(params map[string]interface{}, name string, out *bool) erro
if raw, ok := params[name]; ok {
val, ok := raw.(bool)
if !ok {
return fmt.Errorf("Expecting %s to be a boolean")
return fmt.Errorf("Expecting %s to be a boolean", name)
}
*out = val
delete(params, name)