Merge branch 'qa-nightly-79-fix-create-issue-spec' into 'master'

Fixes transient failure in create_issue_spec.rb

Closes gitlab-org/quality/nightly#79

See merge request gitlab-org/gitlab-ce!25383
This commit is contained in:
Ramya Authappan 2019-02-19 12:54:55 +00:00
commit 61b606a803
4 changed files with 48 additions and 17 deletions

View File

@ -367,6 +367,7 @@ module QA
end
autoload :Api, 'qa/support/api'
autoload :Waiter, 'qa/support/waiter'
autoload :Retrier, 'qa/support/retrier'
end
end

View File

@ -39,18 +39,9 @@ module QA
false
end
def retry_on_exception(max_attempts: 3, reload: false, sleep_interval: 0.0)
attempts = 0
begin
def retry_on_exception(max_attempts: 3, reload: false, sleep_interval: 0.5)
QA::Support::Retrier.retry_on_exception(max_attempts: max_attempts, reload_page: (reload && self), sleep_interval: sleep_interval) do
yield
rescue StandardError
sleep sleep_interval
refresh if reload
attempts += 1
retry if attempts < max_attempts
raise
end
end
@ -162,6 +153,10 @@ module QA
click_link text
end
def click_body
find('body').click
end
def self.path
raise NotImplementedError
end

View File

@ -37,18 +37,25 @@ module QA
end
def select_comments_only_filter
click_element :discussion_filter
find_element(:filter_options, "Show comments only").click
select_filter_with_text('Show comments only')
end
def select_history_only_filter
click_element :discussion_filter
find_element(:filter_options, "Show history only").click
select_filter_with_text('Show history only')
end
def select_all_activities_filter
click_element :discussion_filter
find_element(:filter_options, "Show all activity").click
select_filter_with_text('Show all activity')
end
private
def select_filter_with_text(text)
retry_on_exception do
click_body
click_element :discussion_filter
find_element(:filter_options, text).click
end
end
end
end

28
qa/qa/support/retrier.rb Normal file
View File

@ -0,0 +1,28 @@
# frozen_string_literal: true
module QA
module Support
module Retrier
module_function
def retry_on_exception(max_attempts: 3, reload_page: nil, sleep_interval: 0.5)
QA::Runtime::Logger.debug("with retry_on_exception: max_attempts #{max_attempts}; sleep_interval #{sleep_interval}")
attempts = 0
begin
QA::Runtime::Logger.debug("Attempt number #{attempts + 1}")
yield
rescue StandardError, RSpec::Expectations::ExpectationNotMetError
sleep sleep_interval
reload_page.refresh if reload_page
attempts += 1
retry if attempts < max_attempts
QA::Runtime::Logger.debug("Raising exception after #{max_attempts} attempts")
raise
end
end
end
end
end