spec: rerun during paralleized_specs runtime and timeout fix

Change-Id: I8e50f989bcbbe762bb5d6d91243f81af1bf2de86
Reviewed-on: https://gerrit.instructure.com/32488
Reviewed-by: Bryan Madsen <bryan@instructure.com>
Product-Review: Bryan Madsen <bryan@instructure.com>
QA-Review: Bryan Madsen <bryan@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
This commit is contained in:
Shawn Meredith 2014-03-27 17:29:27 -06:00
parent c4da555cbd
commit 0a2416cdec
2 changed files with 32 additions and 7 deletions

View File

@ -78,6 +78,9 @@ module SeleniumTestsHelperMethods
tries ||= 3
puts "Thread: provisioning selenium driver"
driver = nil
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 300 ##upping this very high so we catch timeouts in rspec around filter rather than selenium blowing up
options[:http_client] = client
driver = Selenium::WebDriver.for(browser, options)
rescue Exception => e
puts "Thread #{THIS_ENV}\n try ##{tries}\nError attempting to start remote webdriver: #{e}"
@ -97,7 +100,7 @@ module SeleniumTestsHelperMethods
end
raise('error with how selenium is being setup')
end
driver.manage.timeouts.implicit_wait = 10
driver.manage.timeouts.implicit_wait = 3
driver
end
@ -958,7 +961,6 @@ shared_examples_for "all selenium tests" do
else
EncryptedCookieStore.test_secret = SecureRandom.hex(64)
end
enable_forgery_protection
rescue
if ENV['PARALLEL_EXECS'] != nil

View File

@ -25,13 +25,25 @@ if CANVAS_RAILS2
end
end
unless CANVAS_RAILS2
unless CANVAS_RAILS2 || ENV['NO_RERUN']
require 'timeout'
RSpec.configure do |c|
c.around(:each) do |example|
Timeout::timeout(300) {
example.run
}
attempts = 0
begin
Timeout::timeout(180) {
example.run
}
e = @example.instance_variable_get('@exception')
if !e.nil? && (attempts += 1) < 2
puts "FAILURE: #{@example.description} \n #{e}".red
puts "RETRYING: #{@example.description}".yellow
@example.instance_variable_set('@exception', nil)
redo
elsif e.nil? && attempts != 0
puts "SUCCESS: retry passed for \n #{@example.description}".green
end
end until true
end
end
end
@ -185,7 +197,7 @@ unless CANVAS_RAILS2
ActiveRecord::Associations::CollectionProxy.class_eval <<-RUBY
def #{m}; end
remove_method #{m.inspect}
RUBY
RUBY
end
end
@ -1421,6 +1433,17 @@ end
end
end
class String
def red; colorize(self, "\e[1m\e[31m"); end
def green; colorize(self, "\e[1m\e[32m"); end
def dark_green; colorize(self, "\e[32m"); end
def yellow; colorize(self, "\e[1m\e[33m"); end
def blue; colorize(self, "\e[1m\e[34m"); end
def dark_blue; colorize(self, "\e[34m"); end
def pur; colorize(self, "\e[1m\e[35m"); end
def colorize(text, color_code) "#{color_code}#{text}\e[0m" end
end
Dir[Rails.root+'vendor/plugins/*/spec_canvas/spec_helper.rb'].each do |f|
require f
end