summaryrefslogtreecommitdiff
path: root/lib/tasks
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2016-03-09 14:08:19 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2016-03-09 14:08:19 +0000
commit5956ddd8b2a633bd9ff1664bcad74e2d17eeebd0 (patch)
tree4e5b262720dee893656136cad1f6bd9095939fbc /lib/tasks
parent500337c4b23700a30876c6d2f8e7c612f8114432 (diff)
parentb651cd227efae152ef56c112576c5464af4ee725 (diff)
downloadgitlab-ce-5956ddd8b2a633bd9ff1664bcad74e2d17eeebd0.tar.gz
Merge branch 'retry-tests' into 'master'
Retry failed tests This is to make the CI builds more reliable due to large amount of timeouts and deadlocks recently. See merge request !1793
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/spinach.rake62
1 files changed, 34 insertions, 28 deletions
diff --git a/lib/tasks/spinach.rake b/lib/tasks/spinach.rake
index 3acfc6e2075..01d23b89bb7 100644
--- a/lib/tasks/spinach.rake
+++ b/lib/tasks/spinach.rake
@@ -4,53 +4,59 @@ namespace :spinach do
namespace :project do
desc "GitLab | Spinach | Run project commits, issues and merge requests spinach features"
task :half do
- cmds = [
- %W(rake gitlab:setup),
- %W(spinach --tags @project_commits,@project_issues,@project_merge_requests),
- ]
- run_commands(cmds)
+ run_spinach_tests('@project_commits,@project_issues,@project_merge_requests')
end
desc "GitLab | Spinach | Run remaining project spinach features"
task :rest do
- cmds = [
- %W(rake gitlab:setup),
- %W(spinach --tags ~@admin,~@dashboard,~@profile,~@public,~@snippets,~@project_commits,~@project_issues,~@project_merge_requests),
- ]
- run_commands(cmds)
+ run_spinach_tests('~@admin,~@dashboard,~@profile,~@public,~@snippets,~@project_commits,~@project_issues,~@project_merge_requests')
end
end
desc "GitLab | Spinach | Run project spinach features"
task :project do
- cmds = [
- %W(rake gitlab:setup),
- %W(spinach --tags ~@admin,~@dashboard,~@profile,~@public,~@snippets),
- ]
- run_commands(cmds)
+ run_spinach_tests('~@admin,~@dashboard,~@profile,~@public,~@snippets')
end
desc "GitLab | Spinach | Run other spinach features"
task :other do
- cmds = [
- %W(rake gitlab:setup),
- %W(spinach --tags @admin,@dashboard,@profile,@public,@snippets),
- ]
- run_commands(cmds)
+ run_spinach_tests('@admin,@dashboard,@profile,@public,@snippets')
+ end
+
+ desc "GitLab | Spinach | Run other spinach features"
+ task :builds do
+ run_spinach_tests('@builds')
end
end
desc "GitLab | Run spinach"
task :spinach do
- cmds = [
- %W(rake gitlab:setup),
- %W(spinach),
- ]
- run_commands(cmds)
+ run_spinach_tests(nil)
+end
+
+def run_command(cmd)
+ system({'RAILS_ENV' => 'test', 'force' => 'yes'}, *cmd)
end
-def run_commands(cmds)
- cmds.each do |cmd|
- system({'RAILS_ENV' => 'test', 'force' => 'yes'}, *cmd) or raise("#{cmd} failed!")
+def run_spinach_command(args)
+ run_command(%w(spinach -r rerun) + args)
+end
+
+def run_spinach_tests(tags)
+ #run_command(%w(rake gitlab:setup)) or raise('gitlab:setup failed!')
+
+ success = run_spinach_command(%W(--tags #{tags}))
+ 3.times do |_|
+ break if success
+ break unless File.exists?('tmp/spinach-rerun.txt')
+
+ tests = File.foreach('tmp/spinach-rerun.txt').map(&:chomp)
+ puts ''
+ puts "Spinach tests for #{tags}: Retrying tests... #{tests}".red
+ puts ''
+ sleep(3)
+ success = run_spinach_command(tests)
end
+
+ raise("spinach tests for #{tags} failed!") unless success
end