Add cron schedules and sync docs
This commit is contained in:
@@ -48,9 +48,84 @@ func TestLoadMinimal(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadCronCheck(t *testing.T) {
|
||||
c, err := Load(writeTmp(t, `
|
||||
agent_id = "host-1"
|
||||
state_dir = "/tmp/x"
|
||||
|
||||
[server]
|
||||
enabled = true
|
||||
url = "http://localhost"
|
||||
|
||||
[[checks]]
|
||||
id = "c1"
|
||||
command = "true"
|
||||
cron = "CRON_TZ=UTC 0 6 * * *"
|
||||
timeout = "5m"
|
||||
`))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !c.Checks[0].UsesCron() || c.Checks[0].UsesInterval() {
|
||||
t.Fatalf("unexpected schedule mode: %+v", c.Checks[0])
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateCheckScheduleChoice(t *testing.T) {
|
||||
for name, body := range map[string]string{
|
||||
"both_interval_and_cron": `
|
||||
interval = "10s"
|
||||
cron = "0 * * * *"
|
||||
timeout = "5s"
|
||||
`,
|
||||
"neither_interval_nor_cron": `
|
||||
timeout = "5s"
|
||||
`,
|
||||
"invalid_cron": `
|
||||
cron = "not a cron"
|
||||
timeout = "5s"
|
||||
`,
|
||||
"seconds_cron": `
|
||||
cron = "0 0 * * * *"
|
||||
timeout = "5s"
|
||||
`,
|
||||
"every_cron": `
|
||||
cron = "@every 10s"
|
||||
timeout = "5s"
|
||||
`,
|
||||
"tz_every_cron": `
|
||||
cron = "CRON_TZ=UTC @every 10s"
|
||||
timeout = "5s"
|
||||
`,
|
||||
"reboot_cron": `
|
||||
cron = "@reboot"
|
||||
timeout = "5s"
|
||||
`,
|
||||
} {
|
||||
t.Run(name, func(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"
|
||||
`+body+`
|
||||
`))
|
||||
if err == nil {
|
||||
t.Fatal("expected schedule validation error")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadResourceLimits(t *testing.T) {
|
||||
c, err := Load(writeTmp(t, `
|
||||
agent_id = "host-1"
|
||||
agent_id = "host-1"
|
||||
state_dir = "/tmp/x"
|
||||
|
||||
[server]
|
||||
|
||||
Reference in New Issue
Block a user