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/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-06 12:10:16 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-06 12:10:16 +0300
commitff490fb7dfd0f4fedbd45b9079fcfa13ade3144c (patch)
treeddd60efa57e53b4e278a928824e61258f4368f38 /spec
parent8f5ebbe2c7488fd8285e528cc3c0b2b3fdd0d2e0 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/diffs/store/actions_spec.js5
-rw-r--r--spec/lib/gitlab/database/load_balancing/load_balancer_spec.rb23
2 files changed, 21 insertions, 7 deletions
diff --git a/spec/frontend/diffs/store/actions_spec.js b/spec/frontend/diffs/store/actions_spec.js
index 4681b4f9d45..6d005b868a9 100644
--- a/spec/frontend/diffs/store/actions_spec.js
+++ b/spec/frontend/diffs/store/actions_spec.js
@@ -874,6 +874,7 @@ describe('DiffsStoreActions', () => {
describe('scrollToFile', () => {
let commit;
+ const getters = { isVirtualScrollingEnabled: false };
beforeEach(() => {
commit = jest.fn();
@@ -888,7 +889,7 @@ describe('DiffsStoreActions', () => {
},
};
- scrollToFile({ state, commit }, 'path');
+ scrollToFile({ state, commit, getters }, 'path');
expect(document.location.hash).toBe('#test');
});
@@ -902,7 +903,7 @@ describe('DiffsStoreActions', () => {
},
};
- scrollToFile({ state, commit }, 'path');
+ scrollToFile({ state, commit, getters }, 'path');
expect(commit).toHaveBeenCalledWith(types.VIEW_DIFF_FILE, 'test');
});
diff --git a/spec/lib/gitlab/database/load_balancing/load_balancer_spec.rb b/spec/lib/gitlab/database/load_balancing/load_balancer_spec.rb
index 2c3858e68bf..01a17cb2805 100644
--- a/spec/lib/gitlab/database/load_balancing/load_balancer_spec.rb
+++ b/spec/lib/gitlab/database/load_balancing/load_balancer_spec.rb
@@ -7,6 +7,7 @@ RSpec.describe Gitlab::Database::LoadBalancing::LoadBalancer, :request_store do
let(:conflict_error) { Class.new(RuntimeError) }
let(:lb) { described_class.new(%w(localhost localhost)) }
+ let(:request_cache) { lb.send(:request_cache) }
before do
allow(Gitlab::Database.main).to receive(:create_connection_pool)
@@ -123,8 +124,9 @@ RSpec.describe Gitlab::Database::LoadBalancing::LoadBalancer, :request_store do
describe '#read_write' do
it 'yields a connection for a write' do
- expect { |b| lb.read_write(&b) }
- .to yield_with_args(ActiveRecord::Base.retrieve_connection)
+ connection = ActiveRecord::Base.connection_pool.connection
+
+ expect { |b| lb.read_write(&b) }.to yield_with_args(connection)
end
it 'uses a retry with exponential backoffs' do
@@ -260,13 +262,24 @@ RSpec.describe Gitlab::Database::LoadBalancing::LoadBalancer, :request_store do
end
it 'stores the host in a thread-local variable' do
- RequestStore.delete(described_class::CACHE_KEY)
+ request_cache.delete(described_class::CACHE_KEY)
expect(lb.host_list).to receive(:next).once.and_call_original
lb.host
lb.host
end
+
+ it 'does not create conflicts with other load balancers when caching hosts' do
+ lb1 = described_class.new(%w(localhost localhost), ActiveRecord::Base)
+ lb2 = described_class.new(%w(localhost localhost), Ci::CiDatabaseRecord)
+
+ host1 = lb1.host
+ host2 = lb2.host
+
+ expect(lb1.send(:request_cache)[described_class::CACHE_KEY]).to eq(host1)
+ expect(lb2.send(:request_cache)[described_class::CACHE_KEY]).to eq(host2)
+ end
end
describe '#release_host' do
@@ -277,7 +290,7 @@ RSpec.describe Gitlab::Database::LoadBalancing::LoadBalancer, :request_store do
lb.release_host
- expect(RequestStore[described_class::CACHE_KEY]).to be_nil
+ expect(request_cache[described_class::CACHE_KEY]).to be_nil
end
end
@@ -415,7 +428,7 @@ RSpec.describe Gitlab::Database::LoadBalancing::LoadBalancer, :request_store do
describe '#select_up_to_date_host' do
let(:location) { 'AB/12345'}
let(:hosts) { lb.host_list.hosts }
- let(:set_host) { RequestStore[described_class::CACHE_KEY] }
+ let(:set_host) { request_cache[described_class::CACHE_KEY] }
subject { lb.select_up_to_date_host(location) }