1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# frozen_string_literal: true
require 'parallel'
module QA
RSpec.describe 'Create' do
context 'Gitaly Cluster replication queue', :orchestrated, :gitaly_cluster, :skip_live_env do
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
praefect_manager.start_all_nodes
end
after do
praefect_manager.start_all_nodes
praefect_manager.clear_replication_queue
end
it 'allows replication of different repository after interruption', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347829' do
# We want to fill the replication queue with 10 `in_progress` jobs,
# while a lock has been acquired, which is when the problem occurred
# as reported in https://gitlab.com/gitlab-org/gitaly/-/issues/2801
#
# We'll do this by creating 10 branches and pushing them all at once,
# and then stop Praefect when a lock is acquired, set all the jobs
# to `in_progress`, and create a job lock for each one.
queue_size_target = 10
Git::Repository.perform do |repository|
repository.uri = project.repository_http_location.uri
repository.use_default_credentials
repository.clone
repository.configure_identity('GitLab QA', 'root@gitlab.com')
1.upto(queue_size_target) do |i|
repository.checkout("branch#{i}", new_branch: true)
repository.commit_file("file#{i}", SecureRandom.random_bytes(10000000), "Add file#{i}")
end
repository.push_all_branches
end
count = 0
while count < 1
count = praefect_manager.replication_queue_lock_count
QA::Runtime::Logger.debug("Lock count: #{count}")
end
praefect_manager.stop_praefect
praefect_manager.create_stalled_replication_queue
praefect_manager.start_praefect
# Create a new project, push to it, and check that replication occurs
project_push = Resource::Repository::ProjectPush.fabricate! do |push|
push.project_name = "gitaly_cluster"
end
expect(praefect_manager.replicated?(project_push.project.id)).to be true
end
end
end
end
|