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
b9d605b6
Commit
b9d605b6
authored
Nov 25, 2021
by
nmilojevic1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename the feature flags
- Fix specs for multi_store and sessions
parent
2bf1b322
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
74 deletions
+66
-74
config/feature_flags/development/use_primary_and_secondary_stores_for_sessions.yml
...lopment/use_primary_and_secondary_stores_for_sessions.yml
+1
-1
config/feature_flags/development/use_primary_store_as_default_for_sessions.yml
...development/use_primary_store_as_default_for_sessions.yml
+1
-1
lib/gitlab/redis/multi_store.rb
lib/gitlab/redis/multi_store.rb
+8
-16
spec/lib/gitlab/redis/multi_store_spec.rb
spec/lib/gitlab/redis/multi_store_spec.rb
+42
-42
spec/lib/gitlab/redis/sessions_spec.rb
spec/lib/gitlab/redis/sessions_spec.rb
+1
-1
spec/support/shared_examples/lib/gitlab/redis/multi_store_feature_flags_shared_examples.rb
...gitlab/redis/multi_store_feature_flags_shared_examples.rb
+13
-13
No files found.
config/feature_flags/development/
sessions_use_multi_store
.yml
→
config/feature_flags/development/
use_primary_and_secondary_stores_for_sessions
.yml
View file @
b9d605b6
---
name
:
sessions_use_multi_store
name
:
use_primary_and_secondary_stores_for_sessions
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/73660
rollout_issue_url
:
https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/1429
milestone
:
'
14.6'
...
...
config/feature_flags/development/
sessions_use_primary_store
.yml
→
config/feature_flags/development/
use_primary_store_as_default_for_sessions
.yml
View file @
b9d605b6
---
name
:
sessions_use_primary_store
name
:
use_primary_store_as_default_for_sessions
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/75258
rollout_issue_url
:
milestone
:
'
14.6'
...
...
lib/gitlab/redis/multi_store.rb
View file @
b9d605b6
...
...
@@ -49,7 +49,7 @@ module Gitlab
# rubocop:disable GitlabSecurity/PublicSend
READ_COMMANDS
.
each
do
|
name
|
define_method
(
name
)
do
|*
args
,
&
block
|
if
multi_store_enabled
?
if
use_primary_and_secondary_stores
?
read_command
(
name
,
*
args
,
&
block
)
else
default_store
.
send
(
name
,
*
args
,
&
block
)
...
...
@@ -59,7 +59,7 @@ module Gitlab
WRITE_COMMANDS
.
each
do
|
name
|
define_method
(
name
)
do
|*
args
,
&
block
|
if
multi_store_enabled
?
if
use_primary_and_secondary_stores
?
write_command
(
name
,
*
args
,
&
block
)
else
default_store
.
send
(
name
,
*
args
,
&
block
)
...
...
@@ -91,29 +91,21 @@ module Gitlab
alias_method
:kind_of?
,
:is_a?
def
to_s
if
multi_store_enabled?
primary_store
.
to_s
else
default_store
.
to_s
end
use_primary_and_secondary_stores?
?
primary_store
.
to_s
:
default_store
.
to_s
end
def
multi_store_enabled
?
Feature
.
enabled?
(
"
#{
instance_name
.
underscore
}
_use_multi_store
"
,
default_enabled: :yaml
)
&&
!
same_redis_store?
def
use_primary_and_secondary_stores
?
Feature
.
enabled?
(
"
use_primary_and_secondary_stores_for_
#{
instance_name
.
underscore
}
"
,
default_enabled: :yaml
)
&&
!
same_redis_store?
end
def
primary_store_enabled
?
Feature
.
enabled?
(
"
#{
instance_name
.
underscore
}
_use_primary_store
"
,
default_enabled: :yaml
)
&&
!
same_redis_store?
def
use_primary_store_as_default
?
Feature
.
enabled?
(
"
use_primary_store_as_default_for_
#{
instance_name
.
underscore
}
"
,
default_enabled: :yaml
)
&&
!
same_redis_store?
end
private
def
default_store
if
primary_store_enabled?
primary_store
else
secondary_store
end
use_primary_store_as_default?
?
primary_store
:
secondary_store
end
def
log_method_missing
(
command_name
,
*
_args
)
...
...
spec/lib/gitlab/redis/multi_store_spec.rb
View file @
b9d605b6
...
...
@@ -189,9 +189,9 @@ RSpec.describe Gitlab::Redis::MultiStore do
allow
(
secondary_store
).
to
receive
(
name
).
and_call_original
end
context
'with feature flag :
test_store_use_multi_store enabled
'
do
context
'with feature flag :
use_primary_and_secondary_stores_for_test_store
'
do
before
do
stub_feature_flags
(
test_store_use_multi
_store:
true
)
stub_feature_flags
(
use_primary_and_secondary_stores_for_test
_store:
true
)
end
context
'when reading from the primary is successful'
do
...
...
@@ -266,22 +266,22 @@ RSpec.describe Gitlab::Redis::MultiStore do
end
end
context
'with feature flag :
test_store_use_multi_store is disabled
'
do
context
'with feature flag :
use_primary_and_secondary_stores_for_test_store
'
do
before
do
stub_feature_flags
(
test_store_use_multi
_store:
false
)
stub_feature_flags
(
use_primary_and_secondary_stores_for_test
_store:
false
)
end
context
'with feature flag :
test_store_use_primary
_store is disabled'
do
context
'with feature flag :
use_primary_store_as_default_for_test
_store is disabled'
do
before
do
stub_feature_flags
(
test_store_use_primary
_store:
false
)
stub_feature_flags
(
use_primary_store_as_default_for_test
_store:
false
)
end
it_behaves_like
'secondary store'
end
context
'with feature flag :
test_store_use_primary
_store is enabled'
do
context
'with feature flag :
use_primary_store_as_default_for_test
_store is enabled'
do
before
do
stub_feature_flags
(
test_store_use_primary
_store:
true
)
stub_feature_flags
(
use_primary_store_as_default_for_test
_store:
true
)
end
it
'execute on the primary instance'
do
...
...
@@ -375,9 +375,9 @@ RSpec.describe Gitlab::Redis::MultiStore do
allow
(
secondary_store
).
to
receive
(
name
).
and_call_original
end
context
'with feature flag :
test_store_use_multi_store enabled
'
do
context
'with feature flag :
use_primary_and_secondary_stores_for_test_store
'
do
before
do
stub_feature_flags
(
test_store_use_multi
_store:
true
)
stub_feature_flags
(
use_primary_and_secondary_stores_for_test
_store:
true
)
end
context
'when executing on primary instance is successful'
do
...
...
@@ -428,14 +428,14 @@ RSpec.describe Gitlab::Redis::MultiStore do
end
end
context
'with feature flag :
test_store_use_multi
_store is disabled'
do
context
'with feature flag :
use_primary_and_secondary_stores_for_test
_store is disabled'
do
before
do
stub_feature_flags
(
test_store_use_multi
_store:
false
)
stub_feature_flags
(
use_primary_and_secondary_stores_for_test
_store:
false
)
end
context
'with feature flag :
test_store_use_primary
_store is disabled'
do
context
'with feature flag :
use_primary_store_as_default_for_test
_store is disabled'
do
before
do
stub_feature_flags
(
test_store_use_primary
_store:
false
)
stub_feature_flags
(
use_primary_store_as_default_for_test
_store:
false
)
end
it
'executes only on the secondary redis store'
,
:aggregate_errors
do
...
...
@@ -448,9 +448,9 @@ RSpec.describe Gitlab::Redis::MultiStore do
include_examples
'verify that store contains values'
,
:secondary_store
end
context
'with feature flag :
test_store_use_primary
_store is enabled'
do
context
'with feature flag :
use_primary_store_as_default_for_test
_store is enabled'
do
before
do
stub_feature_flags
(
test_store_use_primary
_store:
true
)
stub_feature_flags
(
use_primary_store_as_default_for_test
_store:
true
)
end
it
'executes only on the primary_redis redis store'
,
:aggregate_errors
do
...
...
@@ -501,9 +501,9 @@ RSpec.describe Gitlab::Redis::MultiStore do
subject
end
context
'with feature flag :
test_store_use_primary
_store is enabled'
do
context
'with feature flag :
use_primary_store_as_default_for_test
_store is enabled'
do
before
do
stub_feature_flags
(
test_store_use_primary
_store:
true
)
stub_feature_flags
(
use_primary_store_as_default_for_test
_store:
true
)
end
it
'fallback and executes only on the secondary store'
,
:aggregate_errors
do
...
...
@@ -521,9 +521,9 @@ RSpec.describe Gitlab::Redis::MultiStore do
end
end
context
'with feature flag :
test_store_use_primary
_store is disabled'
do
context
'with feature flag :
use_primary_store_as_default_for_test
_store is disabled'
do
before
do
stub_feature_flags
(
test_store_use_primary
_store:
false
)
stub_feature_flags
(
use_primary_store_as_default_for_test
_store:
false
)
end
it
'fallback and executes only on the secondary store'
,
:aggregate_errors
do
...
...
@@ -567,9 +567,9 @@ RSpec.describe Gitlab::Redis::MultiStore do
describe
'#to_s'
do
subject
{
multi_store
.
to_s
}
context
'with feature flag :
test_store_use_multi
_store is enabled'
do
context
'with feature flag :
use_primary_and_secondary_stores_for_test
_store is enabled'
do
before
do
stub_feature_flags
(
test_store_use_multi
_store:
true
)
stub_feature_flags
(
use_primary_and_secondary_stores_for_test
_store:
true
)
end
it
'returns same value as primary_store'
do
...
...
@@ -577,14 +577,14 @@ RSpec.describe Gitlab::Redis::MultiStore do
end
end
context
'with feature flag :
test_store_use_multi
_store is disabled'
do
context
'with feature flag :
use_primary_and_secondary_stores_for_test
_store is disabled'
do
before
do
stub_feature_flags
(
test_store_use_multi
_store:
false
)
stub_feature_flags
(
use_primary_and_secondary_stores_for_test
_store:
false
)
end
context
'with feature flag :
test_store_use_primary
_store is enabled'
do
context
'with feature flag :
use_primary_store_as_default_for_test
_store is enabled'
do
before
do
stub_feature_flags
(
test_store_use_primary
_store:
true
)
stub_feature_flags
(
use_primary_store_as_default_for_test
_store:
true
)
end
it
'returns same value as primary_store'
do
...
...
@@ -592,9 +592,9 @@ RSpec.describe Gitlab::Redis::MultiStore do
end
end
context
'with feature flag :
test_store_use_primary
_store is disabled'
do
context
'with feature flag :
use_primary_store_as_default_for_test
_store is disabled'
do
before
do
stub_feature_flags
(
test_store_use_primary
_store:
false
)
stub_feature_flags
(
use_primary_store_as_default_for_test
_store:
false
)
end
it
'returns same value as primary_store'
do
...
...
@@ -610,46 +610,46 @@ RSpec.describe Gitlab::Redis::MultiStore do
end
end
describe
'#
multi_store_enabled
?'
do
context
'with feature flag :
test_store_use_multi
_store is enabled'
do
describe
'#
use_primary_and_secondary_stores
?'
do
context
'with feature flag :
use_primary_and_secondary_stores_for_test
_store is enabled'
do
before
do
stub_feature_flags
(
test_store_use_multi
_store:
true
)
stub_feature_flags
(
use_primary_and_secondary_stores_for_test
_store:
true
)
end
it
'multi store is disabled'
do
expect
(
multi_store
.
multi_store_enabled
?
).
to
be
true
expect
(
multi_store
.
use_primary_and_secondary_stores
?
).
to
be
true
end
end
context
'with feature flag :
test_store_use_multi
_store is disabled'
do
context
'with feature flag :
use_primary_and_secondary_stores_for_test
_store is disabled'
do
before
do
stub_feature_flags
(
test_store_use_multi
_store:
false
)
stub_feature_flags
(
use_primary_and_secondary_stores_for_test
_store:
false
)
end
it
'multi store is disabled'
do
expect
(
multi_store
.
multi_store_enabled
?
).
to
be
false
expect
(
multi_store
.
use_primary_and_secondary_stores
?
).
to
be
false
end
end
end
describe
'#
primary_store_enabled
?'
do
context
'with feature flag :
test_store_use_primary
_store is enabled'
do
describe
'#
use_primary_store_as_default
?'
do
context
'with feature flag :
use_primary_store_as_default_for_test
_store is enabled'
do
before
do
stub_feature_flags
(
test_store_use_primary
_store:
true
)
stub_feature_flags
(
use_primary_store_as_default_for_test
_store:
true
)
end
it
'multi store is disabled'
do
expect
(
multi_store
.
primary_store_enabled
?
).
to
be
true
expect
(
multi_store
.
use_primary_store_as_default
?
).
to
be
true
end
end
context
'with feature flag :
test_store_use_primary
_store is disabled'
do
context
'with feature flag :
use_primary_store_as_default_for_test
_store is disabled'
do
before
do
stub_feature_flags
(
test_store_use_primary
_store:
false
)
stub_feature_flags
(
use_primary_store_as_default_for_test
_store:
false
)
end
it
'multi store is disabled'
do
expect
(
multi_store
.
primary_store_enabled
?
).
to
be
false
expect
(
multi_store
.
use_primary_store_as_default
?
).
to
be
false
end
end
end
...
...
spec/lib/gitlab/redis/sessions_spec.rb
View file @
b9d605b6
...
...
@@ -54,6 +54,6 @@ RSpec.describe Gitlab::Redis::Sessions do
end
end
it_behaves_like
'multi store feature flags'
,
:
sessions_use_multi_store
,
:sessions_use_primary_store
it_behaves_like
'multi store feature flags'
,
:
use_primary_and_secondary_stores_for_sessions
,
:use_primary_store_as_default_for_sessions
end
end
spec/support/shared_examples/lib/gitlab/redis/multi_store_feature_flags_shared_examples.rb
View file @
b9d605b6
# frozen_string_literal: true
RSpec
.
shared_examples
'multi store feature flags'
do
|
use_
multi_store
,
use_primary_store
|
context
"with feature flag :
#{
use_
multi_store
}
is enabled"
do
RSpec
.
shared_examples
'multi store feature flags'
do
|
use_
primary_and_secondary_stores
,
use_primary_store_as_default
|
context
"with feature flag :
#{
use_
primary_and_secondary_stores
}
is enabled"
do
before
do
stub_feature_flags
(
use_
multi_store
=>
true
)
stub_feature_flags
(
use_
primary_and_secondary_stores
=>
true
)
end
it
'multi store is enabled'
do
expect
(
subject
.
multi_store_enabled
?
).
to
be
true
expect
(
subject
.
use_primary_and_secondary_stores
?
).
to
be
true
end
end
context
"with feature flag :
#{
use_
multi_store
}
is disabled"
do
context
"with feature flag :
#{
use_
primary_and_secondary_stores
}
is disabled"
do
before
do
stub_feature_flags
(
use_
multi_store
=>
false
)
stub_feature_flags
(
use_
primary_and_secondary_stores
=>
false
)
end
it
'multi store is disabled'
do
expect
(
subject
.
multi_store_enabled
?
).
to
be
false
expect
(
subject
.
use_primary_and_secondary_stores
?
).
to
be
false
end
end
context
"with feature flag :
#{
use_primary_store
}
is enabled"
do
context
"with feature flag :
#{
use_primary_store
_as_default
}
is enabled"
do
before
do
stub_feature_flags
(
use_primary_store
=>
true
)
stub_feature_flags
(
use_primary_store
_as_default
=>
true
)
end
it
'primary store is enabled'
do
expect
(
subject
.
primary_store_enabled
?
).
to
be
true
expect
(
subject
.
use_primary_store_as_default
?
).
to
be
true
end
end
context
"with feature flag :
#{
use_primary_store
}
is disabled"
do
context
"with feature flag :
#{
use_primary_store
_as_default
}
is disabled"
do
before
do
stub_feature_flags
(
use_primary_store
=>
false
)
stub_feature_flags
(
use_primary_store
_as_default
=>
false
)
end
it
'primary store is disabled'
do
expect
(
subject
.
primary_store_enabled
?
).
to
be
false
expect
(
subject
.
use_primary_store_as_default
?
).
to
be
false
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