Fixing the test

This commit is contained in:
Diptanu Choudhury 2016-03-23 15:36:46 -07:00
parent 7dab719a66
commit 9b966ec1e6
2 changed files with 10 additions and 1 deletions

View File

@ -334,3 +334,8 @@ func (c *ConsulService) filterConsulChecks(chks map[string]*consul.AgentCheck) m
return nomadChecks
}
func (c *ConsulService) consulPresent() bool {
_, err := c.client.Agent().Self()
return err == nil
}

View File

@ -16,6 +16,10 @@ func TestConsulServiceRegisterServices(t *testing.T) {
if err != nil {
t.Fatalf("Err: %v", err)
}
// Skipping the test if consul isn't present
if !cs.consulPresent() {
return
}
task := structs.Task{
Name: "foo",
Services: []*structs.Service{
@ -76,7 +80,7 @@ func TestConsulServiceRegisterServices(t *testing.T) {
if _, ok := services["2"]; ok {
t.Fatalf("Service with ID 2 should not be registered")
}
if err := cs.Deregister(); err != nil {
if err := cs.Shutdown(); err != nil {
t.Fatalf("err: %v", err)
}
time.Sleep(1 * time.Second)