Commit 8ce82be9 authored by Michael Kozono's avatar Michael Kozono

Make Geo DB/file replication timeouts configurable

…with environment variables GEO_MAX_DB_REPLICATION_TIME and GEO_MAX_FILE_REPLICATION_TIME.
parent 9b6d93fe
......@@ -3,6 +3,11 @@ 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'
......
......@@ -4,10 +4,10 @@ module QA
module Dashboard
module Projects
def wait_for_project_replication(project_name)
wait(max: 180) do
wait(max: Runtime::Geo.max_db_replication_time) do
filter_by_name(project_name)
page.has_content?(project_name)
page.has_text?(project_name)
end
end
end
......
......@@ -4,8 +4,8 @@ module QA
module Project
module Show
def wait_for_repository_replication
wait(max: 180) do
!page.has_content?('The repository for this project is empty')
wait(max: Runtime::Geo.max_file_replication_time) do
!page.has_text?(/No repository|The repository for this project is empty/)
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
module QA
module Runtime
module Env
prepend QA::EE::Runtime::Env
extend self
attr_writer :user_type
......
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