Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-04 06:09:50 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-04 06:09:50 +0300
commit5da864991125a56a48b005389f84ecedf46f09eb (patch)
tree93c00d53e68a34a78e4a03c1044db5a280b5bdcf /qa
parent20922701092f8a34c6ca6afca09e38587662c00e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
-rw-r--r--qa/qa/resource/repository/commit.rb13
-rw-r--r--qa/qa/service/praefect_manager.rb26
-rw-r--r--qa/qa/specs/features/api/3_create/repository/distributed_reads_spec.rb51
3 files changed, 86 insertions, 4 deletions
diff --git a/qa/qa/resource/repository/commit.rb b/qa/qa/resource/repository/commit.rb
index 3243eacdb28..d15210aa736 100644
--- a/qa/qa/resource/repository/commit.rb
+++ b/qa/qa/resource/repository/commit.rb
@@ -59,14 +59,19 @@ module QA
@update_files = files
end
- def resource_web_url(resource)
+ # If `actions` are specified, it performs the actions to create,
+ # update, or delete commits. If no actions are specified it
+ # gets existing commits.
+ def fabricate_via_api!
+ return api_get if actions.empty?
+
+ super
+ rescue ResourceNotFoundError
super
- rescue ResourceURLMissingError
- # this particular resource does not expose a web_url property
end
def api_get_path
- "#{api_post_path}/#{@sha}"
+ api_post_path
end
def api_post_path
diff --git a/qa/qa/service/praefect_manager.rb b/qa/qa/service/praefect_manager.rb
index ce57cd9e074..53fd3036be5 100644
--- a/qa/qa/service/praefect_manager.rb
+++ b/qa/qa/service/praefect_manager.rb
@@ -7,6 +7,8 @@ module QA
attr_accessor :gitlab
+ PrometheusQueryError = Class.new(StandardError)
+
def initialize
@gitlab = 'gitlab-gitaly-ha'
@praefect = 'praefect'
@@ -106,6 +108,18 @@ module QA
)
end
+ def query_read_distribution
+ output = shell "docker exec gitlab-gitaly-ha bash -c 'curl -s http://localhost:9090/api/v1/query?query=gitaly_praefect_read_distribution'" do |line|
+ QA::Runtime::Logger.debug(line)
+ break line
+ end
+ result = JSON.parse(output)
+
+ raise PrometheusQueryError, "Unable to query read distribution metrics" unless result['status'] == 'success'
+
+ result['data']['result'].map { |result| { node: result['metric']['storage'], value: result['value'][1].to_i } }
+ end
+
def replication_queue_lock_count
result = []
shell sql_to_docker_exec_cmd("select count(*) from replication_queue_lock where acquired = 't';") do |line|
@@ -285,6 +299,18 @@ module QA
)
end
+ # Waits until there is an increase in the number of reads for
+ # any node compared to the number of reads provided
+ def wait_for_read_count_change(pre_read_data)
+ diff_found = false
+ Support::Waiter.wait_until(sleep_interval: 5) do
+ query_read_distribution.each_with_index do |data, index|
+ diff_found = true if data[:value] > pre_read_data[index][:value]
+ end
+ diff_found
+ end
+ end
+
def wait_for_reliable_connection
QA::Runtime::Logger.info('Wait until GitLab and Praefect can communicate reliably')
wait_for_praefect
diff --git a/qa/qa/specs/features/api/3_create/repository/distributed_reads_spec.rb b/qa/qa/specs/features/api/3_create/repository/distributed_reads_spec.rb
new file mode 100644
index 00000000000..cff4b06b1ec
--- /dev/null
+++ b/qa/qa/specs/features/api/3_create/repository/distributed_reads_spec.rb
@@ -0,0 +1,51 @@
+# frozen_string_literal: true
+
+require 'parallel'
+
+module QA
+ RSpec.describe 'Create' do
+ 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_ha, :skip_live_env, :requires_admin do
+ let(:number_of_reads) { 100 }
+ let(:praefect_manager) { Service::PraefectManager.new }
+ let(:project) do
+ Resource::Project.fabricate! do |project|
+ project.name = "gitaly_cluster"
+ project.initialize_with_readme = true
+ end
+ end
+
+ before do
+ Runtime::Feature.enable_and_verify('gitaly_distributed_reads')
+ praefect_manager.wait_for_replication(project.id)
+ end
+
+ after do
+ Runtime::Feature.disable_and_verify('gitaly_distributed_reads')
+ end
+
+ 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)) do |index|
+ Resource::Repository::Commit.fabricate_via_api! do |commits|
+ commits.project = project
+ end
+ end
+
+ praefect_manager.wait_for_read_count_change(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 > pre_read_data[index][:value],
+ "Read counts did not differ for node #{pre_read_data[index][:node]}"
+ end
+ end
+ end
+ end
+ end
+ end
+end