Commit b4aa8e60c3c7b7131976e0916f0a559f0e9353cf
1 parent
b55dc73d
Exists in
master
and in
1 other branch
retry failed tests once to verify failure
Showing
1 changed file
with
15 additions
and
2 deletions
Show diff stats
lib/tasks/test_api.rake
| ... | ... | @@ -100,6 +100,7 @@ namespace :test_api do |
| 100 | 100 | |
| 101 | 101 | desc "Description here" |
| 102 | 102 | task(:question_vote_consistency => :environment) do |
| 103 | + first_run_errors = [] | |
| 103 | 104 | errors = [] |
| 104 | 105 | successes = [] |
| 105 | 106 | |
| ... | ... | @@ -111,7 +112,7 @@ namespace :test_api do |
| 111 | 112 | message, error_occurred = send(taskname, question) |
| 112 | 113 | debug("Completed task #{taskname} for question #{question.id}") |
| 113 | 114 | if error_occurred |
| 114 | - errors << message | |
| 115 | + first_run_errors << [taskname, question] | |
| 115 | 116 | else |
| 116 | 117 | successes << message |
| 117 | 118 | end |
| ... | ... | @@ -122,7 +123,7 @@ namespace :test_api do |
| 122 | 123 | @choice_tasks.each do |taskname, description| |
| 123 | 124 | message, error_occurred = send(taskname, choice) |
| 124 | 125 | if error_occurred |
| 125 | - errors << message | |
| 126 | + first_run_errors << [taskname, choice] | |
| 126 | 127 | else |
| 127 | 128 | successes << message |
| 128 | 129 | end |
| ... | ... | @@ -132,6 +133,18 @@ namespace :test_api do |
| 132 | 133 | |
| 133 | 134 | end |
| 134 | 135 | |
| 136 | + # retry the failed tasks in case they failed due to | |
| 137 | + # votes happening while the test was running. | |
| 138 | + debug("Re-running tasks that previously failed") | |
| 139 | + first_run_errors.each do |err| | |
| 140 | + message, error_occurred = send(err[0], err[1].reload) | |
| 141 | + if error_occurred | |
| 142 | + errors << message | |
| 143 | + else | |
| 144 | + successes << message | |
| 145 | + end | |
| 146 | + end | |
| 147 | + | |
| 135 | 148 | @global_tasks.each do |taskname, description| |
| 136 | 149 | debug("Starting global task #{taskname}") |
| 137 | 150 | message, error_occurred = send(taskname) | ... | ... |