Add parsing test cases
This commit is contained in:
parent
1ab8f2b57a
commit
bdae052ead
|
@ -679,8 +679,42 @@ func TestParse(t *testing.T) {
|
|||
Type: helper.StringToPtr("batch"),
|
||||
Datacenters: []string{"dc1"},
|
||||
Reschedule: &api.ReschedulePolicy{
|
||||
Attempts: helper.IntToPtr(15),
|
||||
Interval: helper.TimeToPtr(30 * time.Minute),
|
||||
Attempts: helper.IntToPtr(15),
|
||||
Interval: helper.TimeToPtr(30 * time.Minute),
|
||||
DelayFunction: helper.StringToPtr("linear"),
|
||||
Delay: helper.TimeToPtr(10 * time.Second),
|
||||
},
|
||||
TaskGroups: []*api.TaskGroup{
|
||||
{
|
||||
Name: helper.StringToPtr("bar"),
|
||||
Count: helper.IntToPtr(3),
|
||||
Tasks: []*api.Task{
|
||||
{
|
||||
Name: "bar",
|
||||
Driver: "raw_exec",
|
||||
Config: map[string]interface{}{
|
||||
"command": "bash",
|
||||
"args": []interface{}{"-c", "echo hi"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"reschedule-job-unlimited.hcl",
|
||||
&api.Job{
|
||||
ID: helper.StringToPtr("foo"),
|
||||
Name: helper.StringToPtr("foo"),
|
||||
Type: helper.StringToPtr("batch"),
|
||||
Datacenters: []string{"dc1"},
|
||||
Reschedule: &api.ReschedulePolicy{
|
||||
DelayFunction: helper.StringToPtr("exponential"),
|
||||
Delay: helper.TimeToPtr(10 * time.Second),
|
||||
DelayCeiling: helper.TimeToPtr(120 * time.Second),
|
||||
Unlimited: helper.BoolToPtr(true),
|
||||
},
|
||||
TaskGroups: []*api.TaskGroup{
|
||||
{
|
||||
|
|
20
jobspec/test-fixtures/reschedule-job-unlimited.hcl
Normal file
20
jobspec/test-fixtures/reschedule-job-unlimited.hcl
Normal file
|
@ -0,0 +1,20 @@
|
|||
job "foo" {
|
||||
datacenters = ["dc1"]
|
||||
type = "batch"
|
||||
reschedule {
|
||||
delay = "10s",
|
||||
delay_function = "exponential"
|
||||
delay_ceiling="120s"
|
||||
unlimited = true
|
||||
}
|
||||
group "bar" {
|
||||
count = 3
|
||||
task "bar" {
|
||||
driver = "raw_exec"
|
||||
config {
|
||||
command = "bash"
|
||||
args = ["-c", "echo hi"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,8 @@ job "foo" {
|
|||
reschedule {
|
||||
attempts = 15
|
||||
interval = "30m"
|
||||
delay = "10s",
|
||||
delay_function = "linear"
|
||||
}
|
||||
group "bar" {
|
||||
count = 3
|
||||
|
|
Loading…
Reference in a new issue