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
1526964e
Commit
1526964e
authored
Jun 04, 2021
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move LB-related specs to Core
This was missed from earlier moves
parent
faa85a41
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
78 deletions
+54
-78
ee/spec/initializers/lograge_spec.rb
ee/spec/initializers/lograge_spec.rb
+0
-76
spec/initializers/lograge_spec.rb
spec/initializers/lograge_spec.rb
+54
-2
No files found.
ee/spec/initializers/lograge_spec.rb
deleted
100644 → 0
View file @
faa85a41
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
'lograge'
,
type: :request
do
context
'with a log subscriber'
do
include_context
'parsed logs'
include_context
'clear DB Load Balancing configuration'
let
(
:subscriber
)
{
Lograge
::
LogSubscribers
::
ActionController
.
new
}
let
(
:event
)
do
ActiveSupport
::
Notifications
::
Event
.
new
(
'process_action.action_controller'
,
Time
.
now
,
Time
.
now
,
2
,
status:
200
,
controller:
'HomeController'
,
action:
'index'
,
format:
'application/json'
,
method:
'GET'
,
path:
'/home?foo=bar'
,
params:
{},
db_runtime:
0.02
,
view_runtime:
0.01
)
end
let
(
:logging_keys
)
do
%w[db_primary_wal_count
db_replica_wal_count
db_replica_count
db_replica_cached_count
db_primary_count
db_primary_cached_count
db_primary_duration_s
db_replica_duration_s]
end
context
'when load balancing is enabled'
do
before
do
allow
(
Gitlab
::
Database
::
LoadBalancing
).
to
receive
(
:enable?
).
and_return
(
true
)
end
context
'with db payload'
do
context
'when RequestStore is enabled'
,
:request_store
do
it
'includes db counters'
do
subscriber
.
process_action
(
event
)
expect
(
log_data
).
to
include
(
*
logging_keys
)
end
end
context
'when RequestStore is disabled'
do
it
'does not include db counters'
do
subscriber
.
process_action
(
event
)
expect
(
log_data
).
not_to
include
(
*
logging_keys
)
end
end
end
end
context
'when load balancing is disabled'
do
before
do
allow
(
Gitlab
::
Database
::
LoadBalancing
).
to
receive
(
:enable?
).
and_return
(
false
)
end
it
'does not include db counters'
do
subscriber
.
process_action
(
event
)
expect
(
log_data
).
not_to
include
(
*
logging_keys
)
end
end
end
end
spec/initializers/lograge_spec.rb
View file @
1526964e
...
@@ -120,6 +120,7 @@ RSpec.describe 'lograge', type: :request do
...
@@ -120,6 +120,7 @@ RSpec.describe 'lograge', type: :request do
context
'with a log subscriber'
do
context
'with a log subscriber'
do
include_context
'parsed logs'
include_context
'parsed logs'
include_context
'clear DB Load Balancing configuration'
let
(
:subscriber
)
{
Lograge
::
LogSubscribers
::
ActionController
.
new
}
let
(
:subscriber
)
{
Lograge
::
LogSubscribers
::
ActionController
.
new
}
...
@@ -195,9 +196,25 @@ RSpec.describe 'lograge', type: :request do
...
@@ -195,9 +196,25 @@ RSpec.describe 'lograge', type: :request do
end
end
context
'with db payload'
do
context
'with db payload'
do
let
(
:db_load_balancing_logging_keys
)
do
%w[
db_primary_wal_count
db_replica_wal_count
db_replica_count
db_replica_cached_count
db_primary_count
db_primary_cached_count
db_primary_duration_s
db_replica_duration_s
]
end
before
do
ActiveRecord
::
Base
.
connection
.
execute
(
'SELECT pg_sleep(0.1);'
)
end
context
'when RequestStore is enabled'
,
:request_store
do
context
'when RequestStore is enabled'
,
:request_store
do
it
'includes db counters'
do
it
'includes db counters'
do
ActiveRecord
::
Base
.
connection
.
execute
(
'SELECT pg_sleep(0.1);'
)
subscriber
.
process_action
(
event
)
subscriber
.
process_action
(
event
)
expect
(
log_data
).
to
include
(
"db_count"
=>
a_value
>=
1
,
"db_write_count"
=>
0
,
"db_cached_count"
=>
0
)
expect
(
log_data
).
to
include
(
"db_count"
=>
a_value
>=
1
,
"db_write_count"
=>
0
,
"db_cached_count"
=>
0
)
...
@@ -206,12 +223,47 @@ RSpec.describe 'lograge', type: :request do
...
@@ -206,12 +223,47 @@ RSpec.describe 'lograge', type: :request do
context
'when RequestStore is disabled'
do
context
'when RequestStore is disabled'
do
it
'does not include db counters'
do
it
'does not include db counters'
do
ActiveRecord
::
Base
.
connection
.
execute
(
'SELECT pg_sleep(0.1);'
)
subscriber
.
process_action
(
event
)
subscriber
.
process_action
(
event
)
expect
(
log_data
).
not_to
include
(
"db_count"
,
"db_write_count"
,
"db_cached_count"
)
expect
(
log_data
).
not_to
include
(
"db_count"
,
"db_write_count"
,
"db_cached_count"
)
end
end
end
end
context
'when load balancing is enabled'
do
before
do
allow
(
Gitlab
::
Database
::
LoadBalancing
).
to
receive
(
:enable?
).
and_return
(
true
)
end
context
'with db payload'
do
context
'when RequestStore is enabled'
,
:request_store
do
it
'includes db counters for load balancing'
do
subscriber
.
process_action
(
event
)
expect
(
log_data
).
to
include
(
*
db_load_balancing_logging_keys
)
end
end
context
'when RequestStore is disabled'
do
it
'does not include db counters for load balancing'
do
subscriber
.
process_action
(
event
)
expect
(
log_data
).
not_to
include
(
*
db_load_balancing_logging_keys
)
end
end
end
end
context
'when load balancing is disabled'
do
before
do
allow
(
Gitlab
::
Database
::
LoadBalancing
).
to
receive
(
:enable?
).
and_return
(
false
)
end
it
'does not include db counters for load balancing'
do
subscriber
.
process_action
(
event
)
expect
(
log_data
).
not_to
include
(
*
db_load_balancing_logging_keys
)
end
end
end
end
end
end
end
end
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