mirror of
https://github.com/kemko/nomad.git
synced 2026-01-11 12:55:42 +03:00
Added a test for modifying check
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user