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
440519b6
Commit
440519b6
authored
Jul 06, 2020
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wrap changed code in feature flag
parent
b12be5c7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
5 deletions
+47
-5
lib/gitlab/cache/ci/project_pipeline_status.rb
lib/gitlab/cache/ci/project_pipeline_status.rb
+7
-1
lib/gitlab/ci/features.rb
lib/gitlab/ci/features.rb
+4
-0
spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb
spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb
+36
-4
No files found.
lib/gitlab/cache/ci/project_pipeline_status.rb
View file @
440519b6
...
...
@@ -50,6 +50,8 @@ module Gitlab
def
load_status
return
if
loaded?
return
unless
Gitlab
::
Ci
::
Features
.
pipeline_status_omit_commit_sha_in_cache_key?
(
project
)
||
commit
if
has_cache?
load_from_cache
else
...
...
@@ -115,7 +117,11 @@ module Gitlab
end
def
cache_key
"
#{
Gitlab
::
Redis
::
Cache
::
CACHE_NAMESPACE
}
:project:
#{
project
.
id
}
:pipeline_status"
if
Gitlab
::
Ci
::
Features
.
pipeline_status_omit_commit_sha_in_cache_key?
(
project
)
"
#{
Gitlab
::
Redis
::
Cache
::
CACHE_NAMESPACE
}
:project:
#{
project
.
id
}
:pipeline_status"
else
"
#{
Gitlab
::
Redis
::
Cache
::
CACHE_NAMESPACE
}
:project:
#{
project
.
id
}
:pipeline_status:
#{
commit
&
.
sha
}
"
end
end
def
commit
...
...
lib/gitlab/ci/features.rb
View file @
440519b6
...
...
@@ -34,6 +34,10 @@ module Gitlab
::
Feature
.
enabled?
(
:ci_pipeline_latest
,
default_enabled:
true
)
end
def
self
.
pipeline_status_omit_commit_sha_in_cache_key?
(
project
)
Feature
.
enabled?
(
:ci_pipeline_status_omit_commit_sha_in_cache_key
,
project
)
end
def
self
.
release_generation_enabled?
::
Feature
.
enabled?
(
:ci_release_generation
)
end
...
...
spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb
View file @
440519b6
...
...
@@ -83,8 +83,24 @@ RSpec.describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cac
expect
(
pipeline_status
).
not_to
be_has_cache
end
it
'makes a Gitaly call'
do
expect
{
pipeline_status
.
load_status
}.
to
change
{
Gitlab
::
GitalyClient
.
get_request_count
}.
by
(
1
)
context
'ci_pipeline_status_omit_commit_sha_in_cache_key is enabled'
do
before
do
stub_feature_flags
(
ci_pipeline_status_omit_commit_sha_in_cache_key:
project
)
end
it
'makes a Gitaly call'
do
expect
{
pipeline_status
.
load_status
}.
to
change
{
Gitlab
::
GitalyClient
.
get_request_count
}.
by
(
1
)
end
end
context
'ci_pipeline_status_omit_commit_sha_in_cache_key is disabled'
do
before
do
stub_feature_flags
(
ci_pipeline_status_omit_commit_sha_in_cache_key:
false
)
end
it
'makes a Gitaly calls'
do
expect
{
pipeline_status
.
load_status
}.
to
change
{
Gitlab
::
GitalyClient
.
get_request_count
}.
by
(
1
)
end
end
end
...
...
@@ -95,8 +111,24 @@ RSpec.describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cac
expect
(
pipeline_status
).
to
be_has_cache
end
it
'makes no Gitaly calls'
do
expect
{
pipeline_status
.
load_status
}.
to
change
{
Gitlab
::
GitalyClient
.
get_request_count
}.
by
(
0
)
context
'ci_pipeline_status_omit_commit_sha_in_cache_key is enabled'
do
before
do
stub_feature_flags
(
ci_pipeline_status_omit_commit_sha_in_cache_key:
project
)
end
it
'makes no Gitaly calls'
do
expect
{
pipeline_status
.
load_status
}.
to
change
{
Gitlab
::
GitalyClient
.
get_request_count
}.
by
(
0
)
end
end
context
'ci_pipeline_status_omit_commit_sha_in_cache_key is disabled'
do
before
do
stub_feature_flags
(
ci_pipeline_status_omit_commit_sha_in_cache_key:
false
)
end
it
'makes a Gitaly calls'
do
expect
{
pipeline_status
.
load_status
}.
to
change
{
Gitlab
::
GitalyClient
.
get_request_count
}.
by
(
1
)
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