Added a test for modifying check

This commit is contained in:
Diptanu Choudhury
2015-11-25 18:37:51 -08:00
parent 75d95a4c83
commit cdb28bf46f
2 changed files with 35 additions and 1 deletions

View File

@@ -155,7 +155,6 @@ func (c *ConsulService) performSync(agent *consul.Agent) (int, int) {
// Add services and checks which Consul doesn't know about
for _, trackedTask := range c.trackedTasks {
fmt.Printf("DIPTANU services in Task %v \n", len(trackedTask.task.Services))
for _, service := range trackedTask.task.Services {
knownServices[service.Id] = struct{}{}
if _, ok := consulServices[service.Id]; !ok {

View File

@@ -202,3 +202,38 @@ func TestConsul_AddCheck_To_Service(t *testing.T) {
t.Fatalf("Expected tracked checks: %v, actual: %v", 1, totalChecks)
}
}
func TestConsul_ModifyCheck(t *testing.T) {
c := newConsulService()
task := newTask()
var checks []*structs.ServiceCheck
s1 := structs.Service{
Id: "1-example-cache-redis",
Name: "example-cache-redis",
Tags: []string{"global"},
PortLabel: "db",
Checks: checks,
}
task.Services = append(task.Services, &s1)
c.Register(task, "1")
check1 := structs.ServiceCheck{
Name: "alive",
Type: "tcp",
Interval: 10 * time.Second,
Timeout: 5 * time.Second,
}
s1.Checks = append(s1.Checks, &check1)
_, totalChecks := c.performSync(c.client.Agent())
if totalChecks != 1 {
t.Fatalf("Expected tracked checks: %v, actual: %v", 1, totalChecks)
}
check1.Timeout = 2 * time.Second
_, totalChecks = c.performSync(c.client.Agent())
if totalChecks != 1 {
t.Fatalf("Expected tracked checks: %v, actual: %v", 1, totalChecks)
}
}