Commit 9cbe44b6 authored by Yorick Peterse's avatar Yorick Peterse

Merge branch '6659-extract-ee-specific-files-lines-for-spec-lib-gitlab-easier-ones' into 'master'

Resolve "Extract EE specific files/lines for spec/lib/gitlab easier ones"

Closes #6659

See merge request gitlab-org/gitlab-ee!12510
parents c52fdd6e 019958c0
require 'spec_helper'
describe Gitlab::ExclusiveLease, :clean_gitlab_redis_shared_state do
let(:unique_key) { SecureRandom.hex(10) }
describe '#try_obtain_with_ttl' do
it 'cannot obtain twice before the lease has expired' do
lease = described_class.new(unique_key, timeout: 3600)
ttl_lease = lease.try_obtain_with_ttl
expect(ttl_lease[:uuid]).to be_present
expect(ttl_lease[:ttl]).to eq(0)
second_ttl_lease = lease.try_obtain_with_ttl
expect(second_ttl_lease[:uuid]).to be false
expect(second_ttl_lease[:ttl]).to be > 0
end
it 'can obtain after the lease has expired' do
timeout = 1
lease = described_class.new(unique_key, timeout: 1)
sleep(2 * timeout) # lease should have expired now
ttl_lease = lease.try_obtain_with_ttl
expect(ttl_lease[:uuid]).to be_present
expect(ttl_lease[:ttl]).to eq(0)
end
end
describe '#same_uuid?' do
it 'returns true for an existing lease' do
lease = described_class.new(unique_key, timeout: 3600)
lease.try_obtain
expect(lease.same_uuid?).to eq(true)
end
it 'returns false for a lease that does not exist' do
described_class.new(unique_key, timeout: 3600).try_obtain
lease = described_class.new(unique_key, timeout: 3600)
expect(lease.same_uuid?).to eq(false)
end
end
end
require 'rails_helper'
describe Gitlab::SidekiqConfig do
describe '.workers' do
it 'includes EE workers' do
workers = described_class.workers
expect(workers).to include(RepositoryUpdateMirrorWorker)
expect(workers).to include(LdapGroupSyncWorker)
end
end
describe '.worker_queues' do
it 'includes EE queues' do
queues = described_class.worker_queues
expect(queues).to include('repository_update_mirror')
expect(queues).to include('ldap_group_sync')
end
end
describe '.expand_queues' do
it 'expands queue namespaces to concrete queue names' do
queues = described_class.expand_queues(%w[cronjob])
expect(queues).to include('cronjob:stuck_import_jobs')
expect(queues).to include('cronjob:stuck_merge_jobs')
end
it 'lets concrete queue names pass through' do
queues = described_class.expand_queues(%w[post_receive])
expect(queues).to include('post_receive')
end
it 'lets unknown queues pass through' do
queues = described_class.expand_queues(%w[unknown])
expect(queues).to include('unknown')
end
end
end
......@@ -19,34 +19,6 @@ describe Gitlab::ExclusiveLease, :clean_gitlab_redis_shared_state do
end
end
describe '#try_obtain_with_ttl' do
it 'cannot obtain twice before the lease has expired' do
lease = described_class.new(unique_key, timeout: 3600)
ttl_lease = lease.try_obtain_with_ttl
expect(ttl_lease[:uuid]).to be_present
expect(ttl_lease[:ttl]).to eq(0)
second_ttl_lease = lease.try_obtain_with_ttl
expect(second_ttl_lease[:uuid]).to be false
expect(second_ttl_lease[:ttl]).to be > 0
end
it 'can obtain after the lease has expired' do
timeout = 1
lease = described_class.new(unique_key, timeout: 1)
sleep(2 * timeout) # lease should have expired now
ttl_lease = lease.try_obtain_with_ttl
expect(ttl_lease[:uuid]).to be_present
expect(ttl_lease[:ttl]).to eq(0)
end
end
describe '#renew' do
it 'returns true when we have the existing lease' do
lease = described_class.new(unique_key, timeout: 3600)
......@@ -75,23 +47,6 @@ describe Gitlab::ExclusiveLease, :clean_gitlab_redis_shared_state do
end
end
describe '#same_uuid?' do
it 'returns true for an existing lease' do
lease = described_class.new(unique_key, timeout: 3600)
lease.try_obtain
expect(lease.same_uuid?).to eq(true)
end
it 'returns false for a lease that does not exist' do
described_class.new(unique_key, timeout: 3600).try_obtain
lease = described_class.new(unique_key, timeout: 3600)
expect(lease.same_uuid?).to eq(false)
end
end
describe '.get_uuid' do
it 'gets the uuid if lease with the key associated exists' do
uuid = described_class.new(unique_key, timeout: 3600).try_obtain
......
......@@ -8,13 +8,6 @@ describe Gitlab::SidekiqConfig do
expect(workers).to include(PostReceive)
expect(workers).to include(MergeWorker)
end
it 'includes EE workers' do
workers = described_class.workers
expect(workers).to include(RepositoryUpdateMirrorWorker)
expect(workers).to include(LdapGroupSyncWorker)
end
end
describe '.worker_queues' do
......@@ -27,54 +20,5 @@ describe Gitlab::SidekiqConfig do
expect(queues).to include('mailers')
expect(queues).to include('default')
end
it 'includes EE queues' do
queues = described_class.worker_queues
expect(queues).to include('repository_update_mirror')
expect(queues).to include('ldap_group_sync')
end
end
describe '.expand_queues' do
it 'expands queue namespaces to concrete queue names' do
queues = described_class.expand_queues(%w[cronjob])
expect(queues).to include('cronjob:stuck_import_jobs')
expect(queues).to include('cronjob:stuck_merge_jobs')
end
it 'lets concrete queue names pass through' do
queues = described_class.expand_queues(%w[post_receive])
expect(queues).to include('post_receive')
end
it 'lets unknown queues pass through' do
queues = described_class.expand_queues(%w[unknown])
expect(queues).to include('unknown')
end
end
describe '.expand_queues' do
it 'expands queue namespaces to concrete queue names' do
queues = described_class.expand_queues(%w[cronjob])
expect(queues).to include('cronjob:stuck_import_jobs')
expect(queues).to include('cronjob:stuck_merge_jobs')
end
it 'lets concrete queue names pass through' do
queues = described_class.expand_queues(%w[post_receive])
expect(queues).to include('post_receive')
end
it 'lets unknown queues pass through' do
queues = described_class.expand_queues(%w[unknown])
expect(queues).to include('unknown')
end
end
end
require 'spec_helper'
describe Gitlab::UsageData do
let(:project) { create(:project) }
let(:projects) { create_list(:project, 3) }
let!(:board) { create(:board, project: projects[0]) }
......
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