Commit 8859e606 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'mk/fix-qa-specs-for-gstg-qa' into 'master'

QA: Fix waiting for Geo replication tests when replication is slow

See merge request gitlab-org/gitlab-ee!5675
parents b864c262 8b4dc1d0
......@@ -3,7 +3,16 @@ module QA
# GitLab EE extensions
#
module EE
module Runtime
autoload :Env, 'qa/ee/runtime/env'
autoload :Geo, 'qa/ee/runtime/geo'
end
module Page
module Dashboard
autoload :Projects, 'qa/ee/page/dashboard/projects'
end
module Main
autoload :Banner, 'qa/ee/page/main/banner'
end
......@@ -24,6 +33,12 @@ module QA
end
module Project
autoload :Show, 'qa/ee/page/project/show'
module Issue
autoload :Index, 'qa/ee/page/project/issue/index'
end
module Settings
autoload :ProtectedBranches, 'qa/ee/page/project/settings/protected_branches'
end
......
module QA
module EE
module Page
module Dashboard
module Projects
def wait_for_project_replication(project_name)
wait(max: Runtime::Geo.max_db_replication_time) do
filter_by_name(project_name)
page.has_text?(project_name)
end
end
end
end
end
end
end
module QA
module EE
module Page
module Project
module Issue
module Index
def self.prepended(page)
page.module_eval do
view 'app/views/shared/issuable/_search_bar.html.haml' do
element :issue_filter_form, /form_tag.+class: 'filter-form /
element :issue_filter_input, /%input.form-control.filtered-search/
end
end
end
def wait_for_issue_replication(issue)
wait do
filter_by_title(issue.title)
page.has_content?(issue.title)
end
go_to_issue(issue.title)
end
def filter_by_title(title)
page.within('form.filter-form') do
fill_in class: 'filtered-search', with: title
end
end
end
end
end
end
end
end
module QA
module EE
module Page
module Project
module Show
def wait_for_repository_replication
wait(max: Runtime::Geo.max_file_replication_time) do
!page.has_text?(/No repository|The repository for this project is empty/)
end
end
end
end
end
end
end
# Prepended onto ::QA::Runtime::Env
module QA
module EE
module Runtime
module Env
def geo_max_db_replication_time
ENV['GEO_MAX_DB_REPLICATION_TIME']
end
def geo_max_file_replication_time
ENV['GEO_MAX_FILE_REPLICATION_TIME']
end
end
end
end
end
# EE-only singleton
module QA
module EE
module Runtime
module Geo
extend self
def default_max_db_replication_time
120
end
def max_db_replication_time
(QA::Runtime::Env.geo_max_db_replication_time || default_max_db_replication_time).to_f
end
def default_max_file_replication_time
120
end
def max_file_replication_time
(QA::Runtime::Env.geo_max_file_replication_time || default_max_file_replication_time).to_f
end
end
end
end
end
......@@ -2,6 +2,8 @@ module QA
module Page
module Dashboard
class Projects < Page::Base
prepend QA::EE::Page::Dashboard::Projects
view 'app/views/dashboard/projects/index.html.haml'
view 'app/views/shared/projects/_search_form.html.haml' do
element :form_filter_by_name, /form_tag.+id: 'project-filter-form'/
......
......@@ -3,6 +3,8 @@ module QA
module Project
module Issue
class Index < Page::Base
prepend QA::EE::Page::Project::Issue::Index
view 'app/views/projects/issues/_issue.html.haml' do
element :issue_link, 'link_to issue.title'
end
......
......@@ -2,6 +2,8 @@ module QA
module Page
module Project
class Show < Page::Base
prepend QA::EE::Page::Project::Show
include Page::Shared::ClonePanel
view 'app/views/projects/_last_push.html.haml' do
......
module QA
module Runtime
module Env
prepend QA::EE::Runtime::Env
extend self
attr_writer :user_type
......
......@@ -36,13 +36,15 @@ module QA
end
Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(project.name)
dashboard.go_to_project(project.name)
end
Page::Menu::Side.act { click_issues }
Page::Project::Issue::Index.perform do |index|
index.go_to_issue(issue.title)
index.wait_for_issue_replication(issue)
end
image_url = find('a[href$="banana_sample.gif"]')[:href]
......
......@@ -36,8 +36,6 @@ module QA
end
end
sleep 2 # wait for replication
# check renamed project exist on secondary node
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do
Page::Main::OAuth.act do
......@@ -50,15 +48,17 @@ module QA
Page::Menu::Main.perform do |menu|
menu.go_to_projects
expect(page).to have_content(geo_project_renamed)
end
Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(geo_project_renamed)
dashboard.go_to_project(geo_project_renamed)
end
Page::Project::Show.perform do
Page::Project::Show.perform do |show|
show.wait_for_repository_replication
expect(page).to have_content 'README.md'
expect(page).to have_content 'This is Geo project!'
end
......
......@@ -30,17 +30,17 @@ module QA
Page::Menu::Main.perform do |menu|
menu.go_to_projects
expect(page).to have_content(geo_project_name)
end
sleep 10 # wait for repository replication
Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(geo_project_name)
dashboard.go_to_project(geo_project_name)
end
Page::Project::Show.perform do
Page::Project::Show.perform do |show|
show.wait_for_repository_replication
expect(page).to have_content 'README.md'
expect(page).to have_content 'This is Geo project!'
end
......
describe ::QA::EE::Runtime::Geo do
describe '.max_db_replication_time' do
subject { described_class.max_db_replication_time }
context 'when the environment variable is set' do
it 'returns the environment variable as a float' do
expect(QA::Runtime::Env).to receive(:geo_max_db_replication_time).and_return('2345')
expect(subject).to eq(2345.0)
end
end
context 'when the environment variable is not set' do
it 'returns the default' do
expect(subject).to eq(120.0)
end
end
end
describe '.max_file_replication_time' do
subject { described_class.max_file_replication_time }
context 'when the environment variable is set' do
it 'returns the environment variable as a float' do
expect(QA::Runtime::Env).to receive(:geo_max_file_replication_time).and_return('4321')
expect(subject).to eq(4321.0)
end
end
context 'when the environment variable is not set' do
it 'returns the default' do
expect(subject).to eq(120.0)
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