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,6 +100,7 @@ namespace :test_api do | ||
100 | 100 | ||
101 | desc "Description here" | 101 | desc "Description here" |
102 | task(:question_vote_consistency => :environment) do | 102 | task(:question_vote_consistency => :environment) do |
103 | + first_run_errors = [] | ||
103 | errors = [] | 104 | errors = [] |
104 | successes = [] | 105 | successes = [] |
105 | 106 | ||
@@ -111,7 +112,7 @@ namespace :test_api do | @@ -111,7 +112,7 @@ namespace :test_api do | ||
111 | message, error_occurred = send(taskname, question) | 112 | message, error_occurred = send(taskname, question) |
112 | debug("Completed task #{taskname} for question #{question.id}") | 113 | debug("Completed task #{taskname} for question #{question.id}") |
113 | if error_occurred | 114 | if error_occurred |
114 | - errors << message | 115 | + first_run_errors << [taskname, question] |
115 | else | 116 | else |
116 | successes << message | 117 | successes << message |
117 | end | 118 | end |
@@ -122,7 +123,7 @@ namespace :test_api do | @@ -122,7 +123,7 @@ namespace :test_api do | ||
122 | @choice_tasks.each do |taskname, description| | 123 | @choice_tasks.each do |taskname, description| |
123 | message, error_occurred = send(taskname, choice) | 124 | message, error_occurred = send(taskname, choice) |
124 | if error_occurred | 125 | if error_occurred |
125 | - errors << message | 126 | + first_run_errors << [taskname, choice] |
126 | else | 127 | else |
127 | successes << message | 128 | successes << message |
128 | end | 129 | end |
@@ -132,6 +133,18 @@ namespace :test_api do | @@ -132,6 +133,18 @@ namespace :test_api do | ||
132 | 133 | ||
133 | end | 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 | @global_tasks.each do |taskname, description| | 148 | @global_tasks.each do |taskname, description| |
136 | debug("Starting global task #{taskname}") | 149 | debug("Starting global task #{taskname}") |
137 | message, error_occurred = send(taskname) | 150 | message, error_occurred = send(taskname) |