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
a86e1774
Commit
a86e1774
authored
Mar 11, 2022
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more specs for tracking transactions with HTTP requests
parent
63e5197e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
2 deletions
+50
-2
spec/lib/gitlab/database/transaction/context_spec.rb
spec/lib/gitlab/database/transaction/context_spec.rb
+20
-0
spec/lib/gitlab/database/transaction/observer_spec.rb
spec/lib/gitlab/database/transaction/observer_spec.rb
+30
-2
No files found.
spec/lib/gitlab/database/transaction/context_spec.rb
View file @
a86e1774
...
@@ -135,4 +135,24 @@ RSpec.describe Gitlab::Database::Transaction::Context do
...
@@ -135,4 +135,24 @@ RSpec.describe Gitlab::Database::Transaction::Context do
it_behaves_like
'logs transaction data'
it_behaves_like
'logs transaction data'
end
end
context
'when there are too many external HTTP requests'
do
before
do
allow
(
::
Gitlab
::
Metrics
::
Subscribers
::
ExternalHttp
)
.
to
receive
(
:request_count
)
.
and_return
(
100
)
end
it_behaves_like
'logs transaction data'
end
context
'when there are too many too long external HTTP requests'
do
before
do
allow
(
::
Gitlab
::
Metrics
::
Subscribers
::
ExternalHttp
)
.
to
receive
(
:duration
)
.
and_return
(
5.5
)
end
it_behaves_like
'logs transaction data'
end
end
end
spec/lib/gitlab/database/transaction/observer_spec.rb
View file @
a86e1774
...
@@ -57,8 +57,36 @@ RSpec.describe Gitlab::Database::Transaction::Observer do
...
@@ -57,8 +57,36 @@ RSpec.describe Gitlab::Database::Transaction::Observer do
end
end
end
end
pending
'logs a transaction if external requests rate has been exceeded'
do
context
'when external HTTP requests duration has been exceeded'
do
raise
it
'logs transaction details including exceeding thresholds'
do
expect
(
Gitlab
::
AppJsonLogger
).
to
receive
(
:info
).
with
(
hash_including
(
external_http_requests_count:
2
,
external_http_requests_duration:
12
)
)
ActiveRecord
::
Base
.
transaction
do
User
.
first
perform_stubbed_external_http_request
(
duration:
2
)
perform_stubbed_external_http_request
(
duration:
10
)
end
end
end
context
'when external HTTP requests count has been exceeded'
do
it
'logs transaction details including exceeding thresholds'
do
expect
(
Gitlab
::
AppJsonLogger
).
to
receive
(
:info
).
with
(
hash_including
(
external_http_requests_count:
55
)
)
ActiveRecord
::
Base
.
transaction
do
User
.
first
55
.
times
{
perform_stubbed_external_http_request
(
duration:
0.01
)
}
end
end
end
end
def
perform_stubbed_external_http_request
(
duration
:)
def
perform_stubbed_external_http_request
(
duration
:)
...
...
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