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
Show 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
...
@@ -50,6 +50,8 @@ module Gitlab
def
load_status
def
load_status
return
if
loaded?
return
if
loaded?
return
unless
Gitlab
::
Ci
::
Features
.
pipeline_status_omit_commit_sha_in_cache_key?
(
project
)
||
commit
if
has_cache?
if
has_cache?
load_from_cache
load_from_cache
else
else
...
@@ -115,7 +117,11 @@ module Gitlab
...
@@ -115,7 +117,11 @@ module Gitlab
end
end
def
cache_key
def
cache_key
if
Gitlab
::
Ci
::
Features
.
pipeline_status_omit_commit_sha_in_cache_key?
(
project
)
"
#{
Gitlab
::
Redis
::
Cache
::
CACHE_NAMESPACE
}
:project:
#{
project
.
id
}
:pipeline_status"
"
#{
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
end
def
commit
def
commit
...
...
lib/gitlab/ci/features.rb
View file @
440519b6
...
@@ -34,6 +34,10 @@ module Gitlab
...
@@ -34,6 +34,10 @@ module Gitlab
::
Feature
.
enabled?
(
:ci_pipeline_latest
,
default_enabled:
true
)
::
Feature
.
enabled?
(
:ci_pipeline_latest
,
default_enabled:
true
)
end
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?
def
self
.
release_generation_enabled?
::
Feature
.
enabled?
(
:ci_release_generation
)
::
Feature
.
enabled?
(
:ci_release_generation
)
end
end
...
...
spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb
View file @
440519b6
...
@@ -83,11 +83,27 @@ RSpec.describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cac
...
@@ -83,11 +83,27 @@ RSpec.describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cac
expect
(
pipeline_status
).
not_to
be_has_cache
expect
(
pipeline_status
).
not_to
be_has_cache
end
end
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
it
'makes a Gitaly call'
do
expect
{
pipeline_status
.
load_status
}.
to
change
{
Gitlab
::
GitalyClient
.
get_request_count
}.
by
(
1
)
expect
{
pipeline_status
.
load_status
}.
to
change
{
Gitlab
::
GitalyClient
.
get_request_count
}.
by
(
1
)
end
end
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
context
'cached'
do
context
'cached'
do
before
do
before
do
described_class
.
load_in_batch_for_projects
([
project
])
described_class
.
load_in_batch_for_projects
([
project
])
...
@@ -95,10 +111,26 @@ RSpec.describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cac
...
@@ -95,10 +111,26 @@ RSpec.describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cac
expect
(
pipeline_status
).
to
be_has_cache
expect
(
pipeline_status
).
to
be_has_cache
end
end
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
it
'makes no Gitaly calls'
do
expect
{
pipeline_status
.
load_status
}.
to
change
{
Gitlab
::
GitalyClient
.
get_request_count
}.
by
(
0
)
expect
{
pipeline_status
.
load_status
}.
to
change
{
Gitlab
::
GitalyClient
.
get_request_count
}.
by
(
0
)
end
end
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
end
it
'loads the status from the cache when there is one'
do
it
'loads the status from the cache when there is one'
do
...
...
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