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
09dad69c
Commit
09dad69c
authored
Jan 10, 2018
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removes potential race condition specs from Groups::DestroyService
parent
402c3d13
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
56 deletions
+0
-56
spec/services/groups/destroy_service_spec.rb
spec/services/groups/destroy_service_spec.rb
+0
-56
No files found.
spec/services/groups/destroy_service_spec.rb
View file @
09dad69c
...
@@ -82,62 +82,6 @@ describe Groups::DestroyService do
...
@@ -82,62 +82,6 @@ describe Groups::DestroyService do
expect
(
Group
.
unscoped
.
count
).
to
eq
(
2
)
expect
(
Group
.
unscoped
.
count
).
to
eq
(
2
)
end
end
end
end
context
'potential race conditions'
do
context
"when the `GroupDestroyWorker` task runs immediately"
do
around
do
|
example
|
connections
=
[
ActiveRecord
::
Base
,
Geo
::
BaseRegistry
]
old_connections
=
connections
.
each_with_object
({})
do
|
connection
,
memo
|
memo
[
connection
]
=
DatabaseCleaner
[
:active_record
,
{
connection:
connection
}].
strategy
DatabaseCleaner
[
:active_record
,
{
connection:
connection
}].
strategy
=
:deletion
memo
end
begin
example
.
run
ensure
old_connections
.
each
do
|
connection
,
old_strategy
|
DatabaseCleaner
[
:active_record
,
{
connection:
connection
}].
strategy
=
old_strategy
end
end
end
it
"deletes the group"
do
# Commit the contents of this spec's transaction so far
# so subsequent db connections can see it.
#
# DO NOT REMOVE THIS LINE, even if you see a WARNING with "No
# transaction is currently in progress". Without this, this
# spec will always be green, since the group created in setup
# cannot be seen by any other connections / threads in this spec.
Group
.
connection
.
commit_db_transaction
group_record
=
run_with_new_database_connection
do
|
conn
|
conn
.
execute
(
"SELECT * FROM namespaces WHERE id =
#{
group
.
id
}
"
).
first
end
expect
(
group_record
).
not_to
be_nil
# Execute the contents of `GroupDestroyWorker` in a separate thread, to
# simulate data manipulation by the Sidekiq worker (different database
# connection / transaction).
expect
(
GroupDestroyWorker
).
to
receive
(
:perform_async
).
and_wrap_original
do
|
m
,
group_id
,
user_id
|
Thread
.
new
{
m
[
group_id
,
user_id
]
}.
join
(
5
)
end
# Kick off the initial group destroy in a new thread, so that
# it doesn't share this spec's database transaction.
Thread
.
new
{
described_class
.
new
(
group
,
user
).
async_execute
}.
join
(
5
)
group_record
=
run_with_new_database_connection
do
|
conn
|
conn
.
execute
(
"SELECT * FROM namespaces WHERE id =
#{
group
.
id
}
"
).
first
end
expect
(
group_record
).
to
be_nil
end
end
end
end
end
describe
'synchronous delete'
do
describe
'synchronous delete'
do
...
...
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