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
166458db
Commit
166458db
authored
Oct 13, 2021
by
nmilojevic1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify specs for new Redis instance
- Introduce redis_new_instance_shared_examples
parent
fb810ace
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
147 deletions
+58
-147
spec/lib/gitlab/redis/rate_limiting_spec.rb
spec/lib/gitlab/redis/rate_limiting_spec.rb
+1
-49
spec/lib/gitlab/redis/sessions_spec.rb
spec/lib/gitlab/redis/sessions_spec.rb
+1
-49
spec/lib/gitlab/redis/trace_chunks_spec.rb
spec/lib/gitlab/redis/trace_chunks_spec.rb
+1
-49
spec/support/redis/redis_new_instance_shared_examples.rb
spec/support/redis/redis_new_instance_shared_examples.rb
+55
-0
No files found.
spec/lib/gitlab/redis/rate_limiting_spec.rb
View file @
166458db
...
...
@@ -3,53 +3,5 @@
require
'spec_helper'
RSpec
.
describe
Gitlab
::
Redis
::
RateLimiting
do
let
(
:instance_specific_config_file
)
{
"config/redis.rate_limiting.yml"
}
let
(
:environment_config_file_name
)
{
"GITLAB_REDIS_RATE_LIMITING_CONFIG_FILE"
}
let
(
:cache_config_file
)
{
nil
}
before
do
allow
(
Gitlab
::
Redis
::
Cache
).
to
receive
(
:config_file_name
).
and_return
(
cache_config_file
)
end
include_examples
"redis_shared_examples"
describe
'.config_file_name'
do
subject
{
described_class
.
config_file_name
}
let
(
:rails_root
)
{
Dir
.
mktmpdir
(
'redis_shared_examples'
)
}
before
do
# Undo top-level stub of config_file_name because we are testing that method now.
allow
(
described_class
).
to
receive
(
:config_file_name
).
and_call_original
allow
(
described_class
).
to
receive
(
:rails_root
).
and_return
(
rails_root
)
FileUtils
.
mkdir_p
(
File
.
join
(
rails_root
,
'config'
))
end
after
do
FileUtils
.
rm_rf
(
rails_root
)
end
context
'when there is only a resque.yml'
do
before
do
FileUtils
.
touch
(
File
.
join
(
rails_root
,
'config/resque.yml'
))
end
it
{
expect
(
subject
).
to
eq
(
"
#{
rails_root
}
/config/resque.yml"
)
}
context
'and there is a global env override'
do
before
do
stub_env
(
'GITLAB_REDIS_CONFIG_FILE'
,
'global override'
)
end
it
{
expect
(
subject
).
to
eq
(
'global override'
)
}
context
'and Cache has a different config file'
do
let
(
:cache_config_file
)
{
'cache config file'
}
it
{
expect
(
subject
).
to
eq
(
'cache config file'
)
}
end
end
end
end
include_examples
"redis_new_instance_shared_examples"
,
'rate_limiting'
,
Gitlab
::
Redis
::
Cache
end
spec/lib/gitlab/redis/sessions_spec.rb
View file @
166458db
...
...
@@ -3,53 +3,5 @@
require
'spec_helper'
RSpec
.
describe
Gitlab
::
Redis
::
Sessions
do
let
(
:instance_specific_config_file
)
{
"config/redis.sessions.yml"
}
let
(
:environment_config_file_name
)
{
"GITLAB_REDIS_SESSIONS_CONFIG_FILE"
}
let
(
:shared_state_config_file
)
{
nil
}
before
do
allow
(
Gitlab
::
Redis
::
SharedState
).
to
receive
(
:config_file_name
).
and_return
(
shared_state_config_file
)
end
include_examples
"redis_shared_examples"
describe
'.config_file_name'
do
subject
{
described_class
.
config_file_name
}
let
(
:rails_root
)
{
Dir
.
mktmpdir
(
'redis_shared_examples'
)
}
before
do
# Undo top-level stub of config_file_name because we are testing that method now.
allow
(
described_class
).
to
receive
(
:config_file_name
).
and_call_original
allow
(
described_class
).
to
receive
(
:rails_root
).
and_return
(
rails_root
)
FileUtils
.
mkdir_p
(
File
.
join
(
rails_root
,
'config'
))
end
after
do
FileUtils
.
rm_rf
(
rails_root
)
end
context
'when there is only a resque.yml'
do
before
do
FileUtils
.
touch
(
File
.
join
(
rails_root
,
'config/resque.yml'
))
end
it
{
expect
(
subject
).
to
eq
(
"
#{
rails_root
}
/config/resque.yml"
)
}
context
'and there is a global env override'
do
before
do
stub_env
(
'GITLAB_REDIS_CONFIG_FILE'
,
'global override'
)
end
it
{
expect
(
subject
).
to
eq
(
'global override'
)
}
context
'and SharedState has a different config file'
do
let
(
:shared_state_config_file
)
{
'shared state config file'
}
it
{
expect
(
subject
).
to
eq
(
'shared state config file'
)
}
end
end
end
end
include_examples
"redis_new_instance_shared_examples"
,
'sessions'
,
Gitlab
::
Redis
::
SharedState
end
spec/lib/gitlab/redis/trace_chunks_spec.rb
View file @
166458db
...
...
@@ -3,53 +3,5 @@
require
'spec_helper'
RSpec
.
describe
Gitlab
::
Redis
::
TraceChunks
do
let
(
:instance_specific_config_file
)
{
"config/redis.trace_chunks.yml"
}
let
(
:environment_config_file_name
)
{
"GITLAB_REDIS_TRACE_CHUNKS_CONFIG_FILE"
}
let
(
:shared_state_config_file
)
{
nil
}
before
do
allow
(
Gitlab
::
Redis
::
SharedState
).
to
receive
(
:config_file_name
).
and_return
(
shared_state_config_file
)
end
include_examples
"redis_shared_examples"
describe
'.config_file_name'
do
subject
{
described_class
.
config_file_name
}
let
(
:rails_root
)
{
Dir
.
mktmpdir
(
'redis_shared_examples'
)
}
before
do
# Undo top-level stub of config_file_name because we are testing that method now.
allow
(
described_class
).
to
receive
(
:config_file_name
).
and_call_original
allow
(
described_class
).
to
receive
(
:rails_root
).
and_return
(
rails_root
)
FileUtils
.
mkdir_p
(
File
.
join
(
rails_root
,
'config'
))
end
after
do
FileUtils
.
rm_rf
(
rails_root
)
end
context
'when there is only a resque.yml'
do
before
do
FileUtils
.
touch
(
File
.
join
(
rails_root
,
'config/resque.yml'
))
end
it
{
expect
(
subject
).
to
eq
(
"
#{
rails_root
}
/config/resque.yml"
)
}
context
'and there is a global env override'
do
before
do
stub_env
(
'GITLAB_REDIS_CONFIG_FILE'
,
'global override'
)
end
it
{
expect
(
subject
).
to
eq
(
'global override'
)
}
context
'and SharedState has a different config file'
do
let
(
:shared_state_config_file
)
{
'shared state config file'
}
it
{
expect
(
subject
).
to
eq
(
'shared state config file'
)
}
end
end
end
end
include_examples
"redis_new_instance_shared_examples"
,
'trace_chunks'
,
Gitlab
::
Redis
::
SharedState
end
spec/support/redis/redis_new_instance_shared_examples.rb
0 → 100644
View file @
166458db
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
shared_examples
"redis_new_instance_shared_examples"
do
|
name
,
fallback_class
|
let
(
:instance_specific_config_file
)
{
"config/redis.
#{
name
}
.yml"
}
let
(
:environment_config_file_name
)
{
"GITLAB_REDIS_
#{
name
.
upcase
}
_CONFIG_FILE"
}
let
(
:shared_state_config_file
)
{
nil
}
before
do
allow
(
fallback_class
).
to
receive
(
:config_file_name
).
and_return
(
shared_state_config_file
)
end
include_examples
"redis_shared_examples"
describe
'.config_file_name'
do
subject
{
described_class
.
config_file_name
}
let
(
:rails_root
)
{
Dir
.
mktmpdir
(
'redis_shared_examples'
)
}
before
do
# Undo top-level stub of config_file_name because we are testing that method now.
allow
(
described_class
).
to
receive
(
:config_file_name
).
and_call_original
allow
(
described_class
).
to
receive
(
:rails_root
).
and_return
(
rails_root
)
FileUtils
.
mkdir_p
(
File
.
join
(
rails_root
,
'config'
))
end
after
do
FileUtils
.
rm_rf
(
rails_root
)
end
context
'when there is only a resque.yml'
do
before
do
FileUtils
.
touch
(
File
.
join
(
rails_root
,
'config/resque.yml'
))
end
it
{
expect
(
subject
).
to
eq
(
"
#{
rails_root
}
/config/resque.yml"
)
}
context
'and there is a global env override'
do
before
do
stub_env
(
'GITLAB_REDIS_CONFIG_FILE'
,
'global override'
)
end
it
{
expect
(
subject
).
to
eq
(
'global override'
)
}
context
'and SharedState has a different config file'
do
let
(
:shared_state_config_file
)
{
'shared state config file'
}
it
{
expect
(
subject
).
to
eq
(
'shared state config file'
)
}
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