Commit a113ecef authored by Ramya Authappan's avatar Ramya Authappan

Merge branch 'qa-shl-fix-jenkins-spec' into 'master'

Fix Jenkins spec by asserting on logs in .console-output element

Closes #213953

See merge request gitlab-org/gitlab!29918
parents 3ed77673 bbf3b0c8
...@@ -46,7 +46,7 @@ module QA ...@@ -46,7 +46,7 @@ module QA
job_console.visit! job_console.visit!
Support::Waiter.wait_until(sleep_interval: 1, reload_page: page) do Support::Waiter.wait_until(sleep_interval: 2, reload_page: page) do
job_console.has_successful_build? && job_console.no_failed_status_update? job_console.has_successful_build? && job_console.no_failed_status_update?
end end
end end
...@@ -91,6 +91,7 @@ module QA ...@@ -91,6 +91,7 @@ module QA
end end
Vendor::Jenkins::Page::ConfigureJob.perform do |configure_job| Vendor::Jenkins::Page::ConfigureJob.perform do |configure_job|
configure_job.job_name = project_name
configure_job.configure(scm_url: patch_host_name(project.repository_http_location.git_uri, 'gitlab')) configure_job.configure(scm_url: patch_host_name(project.repository_http_location.git_uri, 'gitlab'))
end end
end end
......
...@@ -9,17 +9,20 @@ module QA ...@@ -9,17 +9,20 @@ module QA
class ConfigureJob < Page::Base class ConfigureJob < Page::Base
attr_accessor :job_name attr_accessor :job_name
def initialize def path
@path = "/job/#{@job_name}/configure" "/job/#{@job_name}/configure"
end end
def configure(scm_url:) def configure(scm_url:)
set_git_source_code_management_url(scm_url) set_git_source_code_management_url(scm_url)
click_build_when_change_is_pushed_to_gitlab click_build_when_change_is_pushed_to_gitlab
set_publish_status_to_gitlab set_publish_status_to_gitlab
Support::Retrier.retry_until(sleep_interval: 0.5) do
click_save click_save
wait_for_configuration_to_save wait_for_configuration_to_save
end end
end
private private
...@@ -58,8 +61,8 @@ module QA ...@@ -58,8 +61,8 @@ module QA
end end
def wait_for_configuration_to_save def wait_for_configuration_to_save
QA::Support::Waiter.wait_until(sleep_interval: 1.0) do QA::Support::Waiter.wait_until(max_duration: 10, raise_on_failure: false) do
!page.current_url.include?(@path) !page.current_url.include?(path)
end end
end end
end end
......
...@@ -9,6 +9,8 @@ module QA ...@@ -9,6 +9,8 @@ module QA
class LastJobConsole < Page::Base class LastJobConsole < Page::Base
attr_accessor :job_name attr_accessor :job_name
CONSOLE_OUTPUT_SELECTOR = '.console-output'
def path def path
"/job/#{@job_name}/lastBuild/console" "/job/#{@job_name}/lastBuild/console"
end end
...@@ -17,13 +19,23 @@ module QA ...@@ -17,13 +19,23 @@ module QA
# Retry on errors such as: # Retry on errors such as:
# Selenium::WebDriver::Error::JavascriptError: # Selenium::WebDriver::Error::JavascriptError:
# javascript error: this.each is not a function # javascript error: this.each is not a function
Support::Retrier.retry_on_exception(reload_page: page) do Support::Retrier.retry_on_exception(reload_page: page, sleep_interval: 1) do
page.has_text?('Finished: SUCCESS') has_console_output? && console_output.include?('Finished: SUCCESS')
end end
end end
def no_failed_status_update? def no_failed_status_update?
page.has_no_text?('Failed to update Gitlab commit status') !console_output.include?('Failed to update Gitlab commit status')
end
private
def has_console_output?
page.has_selector?(CONSOLE_OUTPUT_SELECTOR, wait: 1)
end
def console_output
page.find(CONSOLE_OUTPUT_SELECTOR).text
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment