Add parsing test cases

This commit is contained in:
Preetha Appan 2018-03-07 15:26:45 -06:00
parent 1ab8f2b57a
commit bdae052ead
No known key found for this signature in database
GPG key ID: 9F7C19990A50EAFC
3 changed files with 58 additions and 2 deletions

View file

@ -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{
{

View 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"]
}
}
}
}

View file

@ -4,6 +4,8 @@ job "foo" {
reschedule {
attempts = 15
interval = "30m"
delay = "10s",
delay_function = "linear"
}
group "bar" {
count = 3