Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
019958c0
Commit
019958c0
authored
May 09, 2019
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract EE specs
Fix esclusive lease, sidekiq config, and usage data spec.
parent
d8486732
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
102 deletions
+92
-102
ee/spec/lib/gitlab/exclusive_lease_spec.rb
ee/spec/lib/gitlab/exclusive_lease_spec.rb
+50
-0
ee/spec/lib/gitlab/sidekiq_config_spec.rb
ee/spec/lib/gitlab/sidekiq_config_spec.rb
+42
-0
spec/lib/gitlab/exclusive_lease_spec.rb
spec/lib/gitlab/exclusive_lease_spec.rb
+0
-45
spec/lib/gitlab/sidekiq_config_spec.rb
spec/lib/gitlab/sidekiq_config_spec.rb
+0
-56
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+0
-1
No files found.
ee/spec/lib/gitlab/exclusive_lease_spec.rb
0 → 100644
View file @
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
ee/spec/lib/gitlab/sidekiq_config_spec.rb
0 → 100644
View file @
019958c0
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
spec/lib/gitlab/exclusive_lease_spec.rb
View file @
019958c0
...
...
@@ -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
...
...
spec/lib/gitlab/sidekiq_config_spec.rb
View file @
019958c0
...
...
@@ -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
spec/lib/gitlab/usage_data_spec.rb
View file @
019958c0
require
'spec_helper'
describe
Gitlab
::
UsageData
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:projects
)
{
create_list
(
:project
,
3
)
}
let!
(
:board
)
{
create
(
:board
,
project:
projects
[
0
])
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment