Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport catch request_timeout #7695

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions testsuite/features/step_definitions/common_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@
Then(/^I should see the power is "([^"]*)"$/) do |status|
within(:xpath, '//*[@for=\'powerStatus\']/..') do
repeat_until_timeout(message: "power is not #{status}") do
break if has_content?(status)
break if check_text_and_catch_request_timeout_popup?(status)
find(:xpath, '//button[@value="Get status"]').click
end
raise "Power status #{status} not found" unless has_content?(status)
raise "Power status #{status} not found" unless check_text_and_catch_request_timeout_popup?(status)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

Then(/^I should see a "([^"]*)" text in the environment "([^"]*)"$/) do |text, env|
within(:xpath, "//h3[text()='#{env}']/../..") do
raise "Text \"#{text}\" not found" unless has_content?(text)
raise "Text \"#{text}\" not found" unless check_text_and_catch_request_timeout_popup?(text)
end
end

Expand All @@ -40,7 +40,7 @@

When(/^I wait until I see "([^"]*)" text in the environment "([^"]*)"$/) do |text, env|
within(:xpath, "//h3[text()='#{env}']/../..") do
raise "Text \"#{text}\" not found" unless has_text?(text, wait: DEFAULT_TIMEOUT)
raise "Text \"#{text}\" not found" unless check_text_and_catch_request_timeout_popup?(text, timeout: DEFAULT_TIMEOUT)
end
end

Expand Down
40 changes: 20 additions & 20 deletions testsuite/features/step_definitions/navigation_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

Then(/^I should see a "(.*)" text in the content area$/) do |text|
within('#spacewalk-content') do
raise "Text '#{text}' not found" unless has_content?(text)
raise "Text '#{text}' not found" unless check_text_and_catch_request_timeout_popup?(text)
end
end

Expand All @@ -37,19 +37,19 @@
end

When(/^I wait until I see "([^"]*)" text$/) do |text|
raise "Text '#{text}' not found" unless has_text?(text, wait: DEFAULT_TIMEOUT)
raise "Text '#{text}' not found" unless check_text_and_catch_request_timeout_popup?(text, timeout: DEFAULT_TIMEOUT)
end

When(/^I wait until I do not see "([^"]*)" text$/) do |text|
raise "Text '#{text}' found" unless has_no_text?(text, wait: DEFAULT_TIMEOUT)
end

When(/^I wait at most (\d+) seconds until I see "([^"]*)" text$/) do |seconds, text|
raise "Text '#{text}' not found" unless has_content?(text, wait: seconds.to_i)
raise "Text '#{text}' not found" unless check_text_and_catch_request_timeout_popup?(text, timeout: seconds.to_i)
end

When(/^I wait until I see "([^"]*)" text or "([^"]*)" text$/) do |text1, text2|
raise "Text '#{text1}' or '#{text2}' not found" unless has_content?(text1, wait: DEFAULT_TIMEOUT) || has_content?(text2, wait: DEFAULT_TIMEOUT)
raise "Text '#{text1}' or '#{text2}' not found" unless check_text_and_catch_request_timeout_popup?(text1, text2: text2, timeout: DEFAULT_TIMEOUT)
end

When(/^I wait until I see "([^"]*)" (text|regex), refreshing the page$/) do |text, type|
Expand Down Expand Up @@ -410,7 +410,7 @@

Given(/^I access the host the first time$/) do
visit Capybara.app_host
raise "Text 'Create #{product} Administrator' not found" unless has_content?("Create #{product} Administrator")
raise "Text 'Create #{product} Administrator' not found" unless check_text_and_catch_request_timeout_popup?("Create #{product} Administrator")
end

# Menu permission check
Expand Down Expand Up @@ -484,7 +484,7 @@
Then(/^I wait until table row for "([^"]*)" contains "([^"]*)"$/) do |arg1, arg2|
xpath_query = "//div[@class=\"table-responsive\"]/table/tbody/tr[.//*[contains(.,'#{arg1}')]]"
within(:xpath, xpath_query) do
raise "xpath: #{xpath_query} has no content #{arg2}" unless has_content?(arg2, wait: DEFAULT_TIMEOUT)
raise "xpath: #{xpath_query} has no content #{arg2}" unless check_text_and_catch_request_timeout_popup?(arg2, timeout: DEFAULT_TIMEOUT)
end
end

Expand Down Expand Up @@ -589,48 +589,48 @@

Then(/^I should see "([^"]*)" systems selected for SSM$/) do |arg|
within(:xpath, '//span[@id="spacewalk-set-system_list-counter"]') do
raise "There are not #{arg} systems selected" unless has_content?(arg)
raise "There are not #{arg} systems selected" unless check_text_and_catch_request_timeout_popup?(arg)
end
end

#
# Test for a text in the whole page
#
Then(/^I should see a "([^"]*)" text$/) do |text|
raise "Text '#{text}' not found" unless has_content?(text)
raise "Text '#{text}' not found" unless check_text_and_catch_request_timeout_popup?(text)
end

Then(/^I should see a "([^"]*)" text or "([^"]*)" text$/) do |text1, text2|
raise "Text '#{text1}' and '#{text2}' not found" unless has_content?(text1) || has_content?(text2)
raise "Text '#{text1}' and '#{text2}' not found" unless check_text_and_catch_request_timeout_popup?(text1, text2: text2)
end

Then(/^I should see "([^"]*)" short hostname$/) do |host|
system_name = get_system_name(host).partition('.').first
raise "Hostname #{system_name} is not present" unless has_content?(system_name)
raise "Hostname #{system_name} is not present" unless check_text_and_catch_request_timeout_popup?(system_name)
end

Then(/^I should see "([^"]*)" hostname$/) do |host|
system_name = get_system_name(host)
raise "Hostname #{system_name} is not present" unless has_content?(system_name)
raise "Hostname #{system_name} is not present" unless check_text_and_catch_request_timeout_popup?(system_name)
end

Then(/^I should not see "([^"]*)" hostname$/) do |host|
system_name = get_system_name(host)
raise "Hostname #{system_name} is present" if has_content?(system_name)
raise "Hostname #{system_name} is present" if check_text_and_catch_request_timeout_popup?(system_name)
end

#
# Test for text in a snippet textarea
#
Then(/^I should see "([^"]*)" in the textarea$/) do |text|
within('textarea') do
raise "Text '#{text}' not found" unless has_content?(text)
raise "Text '#{text}' not found" unless check_text_and_catch_request_timeout_popup?(text)
end
end

Then(/^I should see "([^"]*)" or "([^"]*)" in the textarea$/) do |text1, text2|
within('textarea') do
raise "Text '#{text1}' and '#{text2}' not found" unless has_content?(text1) || has_content?(text2)
raise "Text '#{text1}' and '#{text2}' not found" unless check_text_and_catch_request_timeout_popup?(text1, text2: text2)
end
end

Expand Down Expand Up @@ -674,19 +674,19 @@

Then(/^I should see a "([^"]*)" text in element "([^"]*)"$/) do |text, element|
within(:xpath, "//div[@id=\"#{element}\" or @class=\"#{element}\"]") do
raise "Text '#{text}' not found in #{element}" unless has_content?(text)
raise "Text '#{text}' not found in #{element}" unless check_text_and_catch_request_timeout_popup?(text)
end
end

Then(/^I should not see a "([^"]*)" text in element "([^"]*)"$/) do |text, element|
within(:xpath, "//div[@id=\"#{element}\" or @class=\"#{element}\"]") do
raise "Text '#{text}' found in #{element}" if has_content?(text)
raise "Text '#{text}' found in #{element}" if check_text_and_catch_request_timeout_popup?(text)
end
end

Then(/^I should see a "([^"]*)" or "([^"]*)" text in element "([^"]*)"$/) do |text1, text2, element|
within(:xpath, "//div[@id=\"#{element}\" or @class=\"#{element}\"]") do
raise "Texts #{text1} and #{text2} not found in #{element}" unless has_content?(text1) || has_content?(text2)
raise "Texts #{text1} and #{text2} not found in #{element}" unless check_text_and_catch_request_timeout_popup?(text1, text2: text2)
end
end

Expand Down Expand Up @@ -807,15 +807,15 @@

Then(/^I click on the filter button until page does not contain "([^"]*)" text$/) do |text|
repeat_until_timeout(message: "'#{text}' still found") do
break unless has_content?(text)
break unless check_text_and_catch_request_timeout_popup?(text)
find('button.spacewalk-button-filter').click
has_text?('is filtered', wait: 10)
end
end

Then(/^I click on the filter button until page does contain "([^"]*)" text$/) do |text|
repeat_until_timeout(message: "'#{text}' was not found") do
break if has_content?(text)
break if check_text_and_catch_request_timeout_popup?(text)
find('button.spacewalk-button-filter').click
has_text?('is filtered', wait: 10)
end
Expand Down Expand Up @@ -1156,7 +1156,7 @@
within(:xpath, '//section') do
row = find(:xpath, '//div[@class=\'table-responsive\']/table/tbody/tr[.//td]', match: :first)
within(row) do
raise "Text '#{system_name}' not found" unless has_text?(system_name)
raise "Text '#{system_name}' not found" unless check_text_and_catch_request_timeout_popup?(system_name)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions testsuite/features/step_definitions/salt_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
Then(/^I should see "([^"]*)" in the command output for "([^"]*)"$/) do |text, host|
system_name = get_system_name(host)
within("pre[id='#{system_name}-results']") do
raise "Text '#{text}' not found in the results of #{system_name}" unless has_content?(text)
raise "Text '#{text}' not found in the results of #{system_name}" unless check_text_and_catch_request_timeout_popup?(text)
end
end

Expand Down Expand Up @@ -405,7 +405,7 @@ def pillar_get(key, minion)
salt_call = use_salt_bundle ? 'venv-salt-call' : 'salt-call'
output, _code = node.run("#{salt_call} --local key.finger")
fing = output.split("\n")[1].strip!
raise "Text: #{fing} not found" unless has_content?(fing)
raise "Text: #{fing} not found" unless check_text_and_catch_request_timeout_popup?(fing)
end

When(/^I accept "([^"]*)" key$/) do |host|
Expand Down
2 changes: 1 addition & 1 deletion testsuite/features/step_definitions/setup_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@

When(/^I wait at most (\d+) seconds until the tree item "([^"]+)" contains "([^"]+)" text$/) do |timeout, item, text|
within(:xpath, "//span[contains(text(), '#{item}')]/ancestor::div[contains(@class, 'product-details-wrapper')]") do
raise "could not find text #{text} for tree item #{item}" unless has_text?(text, wait: timeout.to_i)
raise "could not find text #{text} for tree item #{item}" unless check_text_and_catch_request_timeout_popup?(text, timeout: timeout.to_i)
end
end

Expand Down
16 changes: 16 additions & 0 deletions testsuite/features/support/commonlib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,22 @@ def repeat_until_timeout(timeout: DEFAULT_TIMEOUT, retries: nil, message: nil, r
raise "Timeout after #{timeout} seconds (Timeout.timeout)#{format_detail(message, last_result, report_result)}"
end

def check_text_and_catch_request_timeout_popup?(text1, text2: nil, timeout: Capybara.default_max_wait_time)
start_time = Time.now
repeat_until_timeout(message: "'#{text1}' still not visible", timeout: DEFAULT_TIMEOUT) do
while Time.now - start_time <= timeout
return true if has_text?(text1, wait: 4)
return true if !text2.nil? && has_text?(text2, wait: 4)
next unless has_text?('Request has timed out', wait: 0)
log 'Request timeout found, performing reload'
click_button('reload the page')
start_time = Time.now
raise "Request timeout message still present after #{Capybara.default_max_wait_time} seconds." unless has_no_text?('Request has timed out')
end
return false
end
end

def format_detail(message, last_result, report_result)
formatted_message = "#{': ' unless message.nil?}#{message}"
formatted_result = "#{', last result was: ' unless last_result.nil?}#{last_result}" if report_result
Expand Down