Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some flaky tests #7482

Merged
merged 3 commits into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .circleci/config.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .circleci/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ references:
GOMAXPROCS: 1
NOMAD_SLOW_TEST: 1
GOTESTSUM_JUNITFILE: /tmp/test-reports/results.xml
GOTESTSUM_JSONFILE: /tmp/test-reports/testjsonfile.json
# disable implicit git paging. CircleCI runs commands with in a tty
# making git assume it's an interactive session.
PAGER: cat
Expand Down
6 changes: 3 additions & 3 deletions client/allocrunner/alloc_runner_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ func TestAllocRunner_PreStartFailuresLeadToFailed(t *testing.T) {
task.Config = map[string]interface{}{
"run_for": "2ms",
}
alloc.Job.TaskGroups[0].RestartPolicy = &structs.RestartPolicy{
Attempts: 0,
}
rp := &structs.RestartPolicy{Attempts: 0}
alloc.Job.TaskGroups[0].RestartPolicy = rp
task.RestartPolicy = rp

conf, cleanup := testAllocRunnerConfig(t, alloc.Copy())
defer cleanup()
Expand Down
14 changes: 11 additions & 3 deletions client/allocrunner/taskrunner/task_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1502,6 +1502,7 @@ func TestTaskRunner_Download_ChrootExec(t *testing.T) {
alloc := mock.BatchAlloc()
alloc.Job.TaskGroups[0].RestartPolicy = &structs.RestartPolicy{}
task := alloc.Job.TaskGroups[0].Tasks[0]
task.RestartPolicy = &structs.RestartPolicy{}
task.Driver = "exec"
task.Config = map[string]interface{}{
"command": "noop.sh",
Expand Down Expand Up @@ -1541,6 +1542,7 @@ func TestTaskRunner_Download_RawExec(t *testing.T) {
alloc := mock.BatchAlloc()
alloc.Job.TaskGroups[0].RestartPolicy = &structs.RestartPolicy{}
task := alloc.Job.TaskGroups[0].Tasks[0]
task.RestartPolicy = &structs.RestartPolicy{}
task.Driver = "raw_exec"
task.Config = map[string]interface{}{
"command": "noop.sh",
Expand Down Expand Up @@ -1631,12 +1633,14 @@ func TestTaskRunner_Download_Retries(t *testing.T) {
task.Artifacts = []*structs.TaskArtifact{&artifact}

// Make the restart policy retry once
alloc.Job.TaskGroups[0].RestartPolicy = &structs.RestartPolicy{
rp := &structs.RestartPolicy{
Attempts: 1,
Interval: 10 * time.Minute,
Delay: 1 * time.Second,
Mode: structs.RestartPolicyModeFail,
}
alloc.Job.TaskGroups[0].RestartPolicy = rp
alloc.Job.TaskGroups[0].Tasks[0].RestartPolicy = rp

tr, _, cleanup := runTestTaskRunner(t, alloc, task.Name)
defer cleanup()
Expand Down Expand Up @@ -1873,12 +1877,14 @@ func TestTaskRunner_Run_RecoverableStartError(t *testing.T) {
}

// Make the restart policy retry once
alloc.Job.TaskGroups[0].RestartPolicy = &structs.RestartPolicy{
rp := &structs.RestartPolicy{
Attempts: 1,
Interval: 10 * time.Minute,
Delay: 0,
Mode: structs.RestartPolicyModeFail,
}
alloc.Job.TaskGroups[0].RestartPolicy = rp
alloc.Job.TaskGroups[0].Tasks[0].RestartPolicy = rp

tr, _, cleanup := runTestTaskRunner(t, alloc, task.Name)
defer cleanup()
Expand Down Expand Up @@ -2245,13 +2251,15 @@ func TestTaskRunner_UnregisterConsul_Retries(t *testing.T) {

alloc := mock.Alloc()
// Make the restart policy try one ctx.update
alloc.Job.TaskGroups[0].RestartPolicy = &structs.RestartPolicy{
rp := &structs.RestartPolicy{
Attempts: 1,
Interval: 10 * time.Minute,
Delay: time.Nanosecond,
Mode: structs.RestartPolicyModeFail,
}
alloc.Job.TaskGroups[0].RestartPolicy = rp
task := alloc.Job.TaskGroups[0].Tasks[0]
task.RestartPolicy = rp
task.Driver = "mock_driver"
task.Config = map[string]interface{}{
"exit_code": "1",
Expand Down