diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-19 12:09:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-19 12:09:58 +0300 |
commit | 7866b83bf40c94e8a32d21fdea97a5e142e08f80 (patch) | |
tree | 5102a3fd55f3908048de22a20f25a39425cc87a8 /qa | |
parent | 0bfb62457ba5122c9bf30bed3ecd20759a9a16bd (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa/specs/features/api/3_create/gitaly/distributed_reads_spec.rb | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/qa/qa/specs/features/api/3_create/gitaly/distributed_reads_spec.rb b/qa/qa/specs/features/api/3_create/gitaly/distributed_reads_spec.rb index 6bbfab653a6..6292ca821ca 100644 --- a/qa/qa/specs/features/api/3_create/gitaly/distributed_reads_spec.rb +++ b/qa/qa/specs/features/api/3_create/gitaly/distributed_reads_spec.rb @@ -7,7 +7,7 @@ module QA context 'Gitaly' do # Issue to track removal of feature flag: https://gitlab.com/gitlab-org/quality/team-tasks/-/issues/602 describe 'Distributed reads', :orchestrated, :gitaly_cluster, :skip_live_env, :requires_admin do - let(:number_of_reads) { 100 } + let(:number_of_reads_per_loop) { 9 } let(:praefect_manager) { Service::PraefectManager.new } let(:project) do Resource::Project.fabricate! do |project| @@ -28,16 +28,14 @@ module QA it 'reads from each node' do pre_read_data = praefect_manager.query_read_distribution - QA::Runtime::Logger.info('Fetching commits from the repository') - Parallel.each((1..number_of_reads)) { project.commits } - - praefect_manager.wait_for_read_count_change(pre_read_data) + wait_for_reads_to_increase(project, number_of_reads_per_loop, pre_read_data) aggregate_failures "each gitaly node" do praefect_manager.query_read_distribution.each_with_index do |data, index| - expect(data[:value]) - .to be > praefect_manager.value_for_node(pre_read_data, data[:node]), - "Read counts did not differ for node #{data[:node]}" + pre_read_count = praefect_manager.value_for_node(pre_read_data, data[:node]) + QA::Runtime::Logger.debug("Node: #{data[:node]}; before: #{pre_read_count}; now: #{data[:value]}") + expect(data[:value]).to be > pre_read_count, + "Read counts did not differ for node #{data[:node]}" end end end @@ -58,8 +56,7 @@ module QA it 'does not read from the unhealthy node' do pre_read_data = praefect_manager.query_read_distribution - QA::Runtime::Logger.info('Fetching commits from the repository') - Parallel.each((1..number_of_reads)) { project.commits } + read_from_project(project, number_of_reads_per_loop * 10) praefect_manager.wait_for_read_count_change(pre_read_data) @@ -72,6 +69,30 @@ module QA end end end + + def read_from_project(project, number_of_reads) + QA::Runtime::Logger.info('Reading from the repository') + Parallel.each((1..number_of_reads)) do + Git::Repository.perform do |repository| + repository.uri = project.repository_http_location.uri + repository.use_default_credentials + repository.clone + end + end + end + + def wait_for_reads_to_increase(project, number_of_reads, pre_read_data) + diff_found = pre_read_data + + Support::Waiter.wait_until(sleep_interval: 5, raise_on_failure: false) do + read_from_project(project, number_of_reads) + + praefect_manager.query_read_distribution.each_with_index do |data, index| + diff_found[index][:diff] = true if data[:value] > praefect_manager.value_for_node(pre_read_data, data[:node]) + end + diff_found.all? { |node| node.key?(:diff) && node[:diff] } + end + end end end end |