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
b1359422
Commit
b1359422
authored
Dec 02, 2021
by
nmilojevic1
Committed by
Nikola Milojevic
Dec 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix specs for sidekiq server middleware
parent
0fa65e87
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
+6
-7
spec/lib/gitlab/database/load_balancing/sidekiq_server_middleware_spec.rb
...database/load_balancing/sidekiq_server_middleware_spec.rb
+6
-7
No files found.
spec/lib/gitlab/database/load_balancing/sidekiq_server_middleware_spec.rb
View file @
b1359422
...
@@ -5,7 +5,9 @@ require 'spec_helper'
...
@@ -5,7 +5,9 @@ require 'spec_helper'
RSpec
.
describe
Gitlab
::
Database
::
LoadBalancing
::
SidekiqServerMiddleware
,
:clean_gitlab_redis_queues
do
RSpec
.
describe
Gitlab
::
Database
::
LoadBalancing
::
SidekiqServerMiddleware
,
:clean_gitlab_redis_queues
do
let
(
:middleware
)
{
described_class
.
new
}
let
(
:middleware
)
{
described_class
.
new
}
let
(
:worker
)
{
worker_class
.
new
}
let
(
:worker
)
{
worker_class
.
new
}
let
(
:job
)
{
{
"retry"
=>
3
,
"job_id"
=>
"a180b47c-3fd6-41b8-81e9-34da61c3400e"
,
'database_replica_location'
=>
'0/D525E3A8'
}
}
let
(
:location
)
{
'0/D525E3A8'
}
let
(
:wal_locations
)
{
{
Gitlab
::
Database
::
MAIN_DATABASE_NAME
.
to_sym
=>
location
}
}
let
(
:job
)
{
{
"retry"
=>
3
,
"job_id"
=>
"a180b47c-3fd6-41b8-81e9-34da61c3400e"
,
'wal_locations'
=>
wal_locations
}
}
before
do
before
do
skip_feature_flags_yaml_validation
skip_feature_flags_yaml_validation
...
@@ -60,9 +62,6 @@ RSpec.describe Gitlab::Database::LoadBalancing::SidekiqServerMiddleware, :clean_
...
@@ -60,9 +62,6 @@ RSpec.describe Gitlab::Database::LoadBalancing::SidekiqServerMiddleware, :clean_
end
end
shared_examples_for
'replica is up to date'
do
|
expected_strategy
|
shared_examples_for
'replica is up to date'
do
|
expected_strategy
|
let
(
:location
)
{
'0/D525E3A8'
}
let
(
:wal_locations
)
{
{
Gitlab
::
Database
::
MAIN_DATABASE_NAME
.
to_sym
=>
location
}
}
it
'does not stick to the primary'
,
:aggregate_failures
do
it
'does not stick to the primary'
,
:aggregate_failures
do
expect
(
ActiveRecord
::
Base
.
load_balancer
)
expect
(
ActiveRecord
::
Base
.
load_balancer
)
.
to
receive
(
:select_up_to_date_host
)
.
to
receive
(
:select_up_to_date_host
)
...
@@ -133,7 +132,7 @@ RSpec.describe Gitlab::Database::LoadBalancing::SidekiqServerMiddleware, :clean_
...
@@ -133,7 +132,7 @@ RSpec.describe Gitlab::Database::LoadBalancing::SidekiqServerMiddleware, :clean_
end
end
context
'when WAL locations are present'
,
:freeze_time
do
context
'when WAL locations are present'
,
:freeze_time
do
let
(
:job
)
{
{
"retry"
=>
3
,
"job_id"
=>
"a180b47c-3fd6-41b8-81e9-34da61c3400e"
,
"database_replica_location"
=>
"0/D525E3A8"
,
"created_at"
=>
Time
.
current
.
to_f
-
elapsed_time
}
}
let
(
:job
)
{
{
"retry"
=>
3
,
"job_id"
=>
"a180b47c-3fd6-41b8-81e9-34da61c3400e"
,
'wal_locations'
=>
wal_locations
,
"created_at"
=>
Time
.
current
.
to_f
-
elapsed_time
}
}
context
'when delay interval has not elapsed'
do
context
'when delay interval has not elapsed'
do
let
(
:elapsed_time
)
{
described_class
::
MINIMUM_DELAY_INTERVAL
-
0.3
}
let
(
:elapsed_time
)
{
described_class
::
MINIMUM_DELAY_INTERVAL
-
0.3
}
...
@@ -179,7 +178,7 @@ RSpec.describe Gitlab::Database::LoadBalancing::SidekiqServerMiddleware, :clean_
...
@@ -179,7 +178,7 @@ RSpec.describe Gitlab::Database::LoadBalancing::SidekiqServerMiddleware, :clean_
include_examples
'stick to the primary'
,
'primary'
include_examples
'stick to the primary'
,
'primary'
context
'when delay interval has not elapsed'
,
:freeze_time
do
context
'when delay interval has not elapsed'
,
:freeze_time
do
let
(
:job
)
{
{
"retry"
=>
3
,
"job_id"
=>
"a180b47c-3fd6-41b8-81e9-34da61c3400e"
,
'
database_replica_location'
=>
'0/D525E3A8'
,
"created_at"
=>
Time
.
current
.
to_f
-
elapsed_time
}
}
let
(
:job
)
{
{
"retry"
=>
3
,
"job_id"
=>
"a180b47c-3fd6-41b8-81e9-34da61c3400e"
,
'
wal_locations'
=>
wal_locations
,
"created_at"
=>
Time
.
current
.
to_f
-
elapsed_time
}
}
let
(
:elapsed_time
)
{
described_class
::
MINIMUM_DELAY_INTERVAL
-
0.3
}
let
(
:elapsed_time
)
{
described_class
::
MINIMUM_DELAY_INTERVAL
-
0.3
}
it
'does not sleep'
do
it
'does not sleep'
do
...
@@ -222,7 +221,7 @@ RSpec.describe Gitlab::Database::LoadBalancing::SidekiqServerMiddleware, :clean_
...
@@ -222,7 +221,7 @@ RSpec.describe Gitlab::Database::LoadBalancing::SidekiqServerMiddleware, :clean_
end
end
context
'when job is retried'
do
context
'when job is retried'
do
let
(
:job
)
{
{
"retry"
=>
3
,
"job_id"
=>
"a180b47c-3fd6-41b8-81e9-34da61c3400e"
,
'
database_replica_location'
=>
'0/D525E3A8'
,
'retry_count'
=>
0
}
}
let
(
:job
)
{
{
"retry"
=>
3
,
"job_id"
=>
"a180b47c-3fd6-41b8-81e9-34da61c3400e"
,
'
wal_locations'
=>
wal_locations
,
'retry_count'
=>
0
}
}
context
'and replica still lagging behind'
do
context
'and replica still lagging behind'
do
include_examples
'stick to the primary'
,
'primary'
include_examples
'stick to the primary'
,
'primary'
...
...
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