tests: restart restartpolicy for all tasks in tests
This commit is contained in:
parent
2698056311
commit
a5b024fdea
|
@ -236,9 +236,9 @@ func TestAllocRunner_PreStartFailuresLeadToFailed(t *testing.T) {
|
||||||
task.Config = map[string]interface{}{
|
task.Config = map[string]interface{}{
|
||||||
"run_for": "2ms",
|
"run_for": "2ms",
|
||||||
}
|
}
|
||||||
alloc.Job.TaskGroups[0].RestartPolicy = &structs.RestartPolicy{
|
rp := &structs.RestartPolicy{Attempts: 0}
|
||||||
Attempts: 0,
|
alloc.Job.TaskGroups[0].RestartPolicy = rp
|
||||||
}
|
task.RestartPolicy = rp
|
||||||
|
|
||||||
conf, cleanup := testAllocRunnerConfig(t, alloc.Copy())
|
conf, cleanup := testAllocRunnerConfig(t, alloc.Copy())
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
|
@ -1502,6 +1502,7 @@ func TestTaskRunner_Download_ChrootExec(t *testing.T) {
|
||||||
alloc := mock.BatchAlloc()
|
alloc := mock.BatchAlloc()
|
||||||
alloc.Job.TaskGroups[0].RestartPolicy = &structs.RestartPolicy{}
|
alloc.Job.TaskGroups[0].RestartPolicy = &structs.RestartPolicy{}
|
||||||
task := alloc.Job.TaskGroups[0].Tasks[0]
|
task := alloc.Job.TaskGroups[0].Tasks[0]
|
||||||
|
task.RestartPolicy = &structs.RestartPolicy{}
|
||||||
task.Driver = "exec"
|
task.Driver = "exec"
|
||||||
task.Config = map[string]interface{}{
|
task.Config = map[string]interface{}{
|
||||||
"command": "noop.sh",
|
"command": "noop.sh",
|
||||||
|
@ -1541,6 +1542,7 @@ func TestTaskRunner_Download_RawExec(t *testing.T) {
|
||||||
alloc := mock.BatchAlloc()
|
alloc := mock.BatchAlloc()
|
||||||
alloc.Job.TaskGroups[0].RestartPolicy = &structs.RestartPolicy{}
|
alloc.Job.TaskGroups[0].RestartPolicy = &structs.RestartPolicy{}
|
||||||
task := alloc.Job.TaskGroups[0].Tasks[0]
|
task := alloc.Job.TaskGroups[0].Tasks[0]
|
||||||
|
task.RestartPolicy = &structs.RestartPolicy{}
|
||||||
task.Driver = "raw_exec"
|
task.Driver = "raw_exec"
|
||||||
task.Config = map[string]interface{}{
|
task.Config = map[string]interface{}{
|
||||||
"command": "noop.sh",
|
"command": "noop.sh",
|
||||||
|
@ -1631,12 +1633,14 @@ func TestTaskRunner_Download_Retries(t *testing.T) {
|
||||||
task.Artifacts = []*structs.TaskArtifact{&artifact}
|
task.Artifacts = []*structs.TaskArtifact{&artifact}
|
||||||
|
|
||||||
// Make the restart policy retry once
|
// Make the restart policy retry once
|
||||||
alloc.Job.TaskGroups[0].RestartPolicy = &structs.RestartPolicy{
|
rp := &structs.RestartPolicy{
|
||||||
Attempts: 1,
|
Attempts: 1,
|
||||||
Interval: 10 * time.Minute,
|
Interval: 10 * time.Minute,
|
||||||
Delay: 1 * time.Second,
|
Delay: 1 * time.Second,
|
||||||
Mode: structs.RestartPolicyModeFail,
|
Mode: structs.RestartPolicyModeFail,
|
||||||
}
|
}
|
||||||
|
alloc.Job.TaskGroups[0].RestartPolicy = rp
|
||||||
|
alloc.Job.TaskGroups[0].Tasks[0].RestartPolicy = rp
|
||||||
|
|
||||||
tr, _, cleanup := runTestTaskRunner(t, alloc, task.Name)
|
tr, _, cleanup := runTestTaskRunner(t, alloc, task.Name)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
@ -1873,12 +1877,14 @@ func TestTaskRunner_Run_RecoverableStartError(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make the restart policy retry once
|
// Make the restart policy retry once
|
||||||
alloc.Job.TaskGroups[0].RestartPolicy = &structs.RestartPolicy{
|
rp := &structs.RestartPolicy{
|
||||||
Attempts: 1,
|
Attempts: 1,
|
||||||
Interval: 10 * time.Minute,
|
Interval: 10 * time.Minute,
|
||||||
Delay: 0,
|
Delay: 0,
|
||||||
Mode: structs.RestartPolicyModeFail,
|
Mode: structs.RestartPolicyModeFail,
|
||||||
}
|
}
|
||||||
|
alloc.Job.TaskGroups[0].RestartPolicy = rp
|
||||||
|
alloc.Job.TaskGroups[0].Tasks[0].RestartPolicy = rp
|
||||||
|
|
||||||
tr, _, cleanup := runTestTaskRunner(t, alloc, task.Name)
|
tr, _, cleanup := runTestTaskRunner(t, alloc, task.Name)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
Loading…
Reference in a new issue