From 525d74aebc41dfd5bb70767757ee846ac255743b Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Fri, 17 Oct 2014 14:43:52 -0700 Subject: [PATCH] agent: add test for consul service sync state --- command/agent/agent_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/command/agent/agent_test.go b/command/agent/agent_test.go index 7304b22291..dff36507b5 100644 --- a/command/agent/agent_test.go +++ b/command/agent/agent_test.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/hashicorp/consul/consul" "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/testutil" "io" "io/ioutil" "os" @@ -326,8 +327,21 @@ func TestAgent_ConsulService(t *testing.T) { defer os.RemoveAll(dir) defer agent.Shutdown() + testutil.WaitForLeader(t, agent.RPC, "dc1") + + // Consul service is registered services := agent.state.Services() if _, ok := services[consul.ConsulServiceID]; !ok { t.Fatalf("%s service should be registered", consul.ConsulServiceID) } + + // Perform anti-entropy on consul service + if err := agent.state.syncService(consul.ConsulServiceID); err != nil { + t.Fatalf("err: %s", err) + } + + // Consul service should be in sync + if !agent.state.serviceStatus[consul.ConsulServiceID].inSync { + t.Fatalf("%s service should be in sync", consul.ConsulServiceID) + } }