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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
f44665c8
Commit
f44665c8
authored
Oct 24, 2017
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slow down requests for dropzone uploads to avoid race conditions
parent
9e538fd0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
lib/gitlab/testing/request_blocker_middleware.rb
lib/gitlab/testing/request_blocker_middleware.rb
+12
-0
spec/features/uploads/user_uploads_file_to_note_spec.rb
spec/features/uploads/user_uploads_file_to_note_spec.rb
+8
-0
No files found.
lib/gitlab/testing/request_blocker_middleware.rb
View file @
f44665c8
...
...
@@ -7,6 +7,7 @@ module Gitlab
class
RequestBlockerMiddleware
@@num_active_requests
=
Concurrent
::
AtomicFixnum
.
new
(
0
)
@@block_requests
=
Concurrent
::
AtomicBoolean
.
new
(
false
)
@@slow_requests
=
Concurrent
::
AtomicBoolean
.
new
(
false
)
# Returns the number of requests the server is currently processing.
def
self
.
num_active_requests
...
...
@@ -19,9 +20,15 @@ module Gitlab
@@block_requests
.
value
=
true
end
# Slows down incoming requests (useful for race conditions).
def
self
.
slow_requests!
@@slow_requests
.
value
=
true
end
# Allows the server to accept requests again.
def
self
.
allow_requests!
@@block_requests
.
value
=
false
@@slow_requests
.
value
=
false
end
def
initialize
(
app
)
...
...
@@ -33,6 +40,7 @@ module Gitlab
if
block_requests?
block_request
(
env
)
else
sleep
0.2
if
slow_requests?
@app
.
call
(
env
)
end
ensure
...
...
@@ -45,6 +53,10 @@ module Gitlab
@@block_requests
.
true?
end
def
slow_requests?
@@slow_requests
.
true?
end
def
block_request
(
env
)
[
503
,
{},
[]]
end
...
...
spec/features/uploads/user_uploads_file_to_note_spec.rb
View file @
f44665c8
...
...
@@ -21,6 +21,14 @@ feature 'User uploads file to note' do
end
context
'uploading is in progress'
do
before
do
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
slow_requests!
end
after
do
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
allow_requests!
end
it
'shows "Cancel" button on uploading'
,
:js
do
dropzone_file
([
Rails
.
root
.
join
(
'spec'
,
'fixtures'
,
'dk.png'
)],
0
,
false
)
...
...
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