Fix scheduler cleanup edge cases
This commit is contained in:
@@ -217,7 +217,7 @@ func (c *Config) Validate() error {
|
||||
return fmt.Errorf("check %q: timeout must be > 0", ch.ID)
|
||||
}
|
||||
if ch.Interval.Duration < 0 {
|
||||
return fmt.Errorf("check %q: interval must be > 0", ch.ID)
|
||||
return fmt.Errorf("check %q: interval must not be negative", ch.ID)
|
||||
}
|
||||
ch.Cron = strings.TrimSpace(ch.Cron)
|
||||
hasInterval := ch.Interval.Duration > 0
|
||||
|
||||
@@ -123,6 +123,29 @@ func TestValidateCheckScheduleChoice(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateNegativeIntervalMessage(t *testing.T) {
|
||||
_, err := Load(writeTmp(t, `
|
||||
agent_id = "host-1"
|
||||
state_dir = "/tmp/x"
|
||||
|
||||
[server]
|
||||
enabled = true
|
||||
url = "http://localhost"
|
||||
|
||||
[[checks]]
|
||||
id = "c1"
|
||||
command = "true"
|
||||
interval = "-1s"
|
||||
timeout = "5s"
|
||||
`))
|
||||
if err == nil {
|
||||
t.Fatal("expected negative interval error")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "interval must not be negative") {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadResourceLimits(t *testing.T) {
|
||||
c, err := Load(writeTmp(t, `
|
||||
agent_id = "host-1"
|
||||
|
||||
Reference in New Issue
Block a user