Commit 2f86bc74 authored by Sanad Liaquat's avatar Sanad Liaquat

Merge branch 'ml-update-distributed-reads-spec' into 'master'

Update distributed reads spec

See merge request gitlab-org/gitlab!39412
parents 456e4ac6 24fc2bad
...@@ -7,7 +7,7 @@ module QA ...@@ -7,7 +7,7 @@ module QA
context 'Gitaly' do context 'Gitaly' do
# Issue to track removal of feature flag: https://gitlab.com/gitlab-org/quality/team-tasks/-/issues/602 # 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 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(:praefect_manager) { Service::PraefectManager.new }
let(:project) do let(:project) do
Resource::Project.fabricate! do |project| Resource::Project.fabricate! do |project|
...@@ -28,15 +28,13 @@ module QA ...@@ -28,15 +28,13 @@ module QA
it 'reads from each node' do it 'reads from each node' do
pre_read_data = praefect_manager.query_read_distribution pre_read_data = praefect_manager.query_read_distribution
QA::Runtime::Logger.info('Fetching commits from the repository') wait_for_reads_to_increase(project, number_of_reads_per_loop, pre_read_data)
Parallel.each((1..number_of_reads)) { project.commits }
praefect_manager.wait_for_read_count_change(pre_read_data)
aggregate_failures "each gitaly node" do aggregate_failures "each gitaly node" do
praefect_manager.query_read_distribution.each_with_index do |data, index| praefect_manager.query_read_distribution.each_with_index do |data, index|
expect(data[:value]) pre_read_count = praefect_manager.value_for_node(pre_read_data, data[:node])
.to be > 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]}" "Read counts did not differ for node #{data[:node]}"
end end
end end
...@@ -58,8 +56,7 @@ module QA ...@@ -58,8 +56,7 @@ module QA
it 'does not read from the unhealthy node' do it 'does not read from the unhealthy node' do
pre_read_data = praefect_manager.query_read_distribution pre_read_data = praefect_manager.query_read_distribution
QA::Runtime::Logger.info('Fetching commits from the repository') read_from_project(project, number_of_reads_per_loop * 10)
Parallel.each((1..number_of_reads)) { project.commits }
praefect_manager.wait_for_read_count_change(pre_read_data) praefect_manager.wait_for_read_count_change(pre_read_data)
...@@ -72,6 +69,30 @@ module QA ...@@ -72,6 +69,30 @@ module QA
end end
end 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 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