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
f7e24cbf
Commit
f7e24cbf
authored
Sep 09, 2020
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change tier to EEU for environment alerts
This commit fixes the tier for the feature environment alerts.
parent
4f3af541
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
97 additions
and
26 deletions
+97
-26
app/serializers/environment_entity.rb
app/serializers/environment_entity.rb
+0
-6
changelogs/unreleased/change-tier-eeu-environment-alerts.yml
changelogs/unreleased/change-tier-eeu-environment-alerts.yml
+5
-0
ee/app/models/license.rb
ee/app/models/license.rb
+1
-0
ee/app/serializers/ee/environment_entity.rb
ee/app/serializers/ee/environment_entity.rb
+6
-0
ee/spec/features/projects/environments/environments_spec.rb
ee/spec/features/projects/environments/environments_spec.rb
+49
-0
ee/spec/serializers/environment_entity_spec.rb
ee/spec/serializers/environment_entity_spec.rb
+36
-0
spec/serializers/environment_entity_spec.rb
spec/serializers/environment_entity_spec.rb
+0
-20
No files found.
app/serializers/environment_entity.rb
View file @
f7e24cbf
...
...
@@ -71,8 +71,6 @@ class EnvironmentEntity < Grape::Entity
can?
(
current_user
,
:destroy_environment
,
environment
)
end
expose
:has_opened_alert?
,
if:
->
(
*
)
{
can_read_alert_management_alert?
},
expose_nil:
false
,
as: :has_opened_alert
private
alias_method
:environment
,
:object
...
...
@@ -93,10 +91,6 @@ class EnvironmentEntity < Grape::Entity
can?
(
current_user
,
:read_pod_logs
,
environment
.
project
)
end
def
can_read_alert_management_alert?
can?
(
current_user
,
:read_alert_management_alert
,
environment
.
project
)
end
def
cluster_platform_kubernetes?
deployment_platform
&&
deployment_platform
.
is_a?
(
Clusters
::
Platforms
::
Kubernetes
)
end
...
...
changelogs/unreleased/change-tier-eeu-environment-alerts.yml
0 → 100644
View file @
f7e24cbf
---
title
:
Fix the tier of environment alerts feature
merge_request
:
41855
author
:
type
:
fixed
ee/app/models/license.rb
View file @
f7e24cbf
...
...
@@ -132,6 +132,7 @@ class License < ApplicationRecord
prometheus_alerts
pseudonymizer
release_evidence_test_artifacts
environment_alerts
report_approver_rules
requirements
sast
...
...
ee/app/serializers/ee/environment_entity.rb
View file @
f7e24cbf
...
...
@@ -7,6 +7,7 @@ module EE
prepended
do
expose
:rollout_status
,
if:
->
(
*
)
{
can_read_deploy_board?
},
using:
::
RolloutStatusEntity
expose
:has_opened_alert?
,
if:
->
(
*
)
{
can_read_alert_management_alert?
},
expose_nil:
false
,
as: :has_opened_alert
end
private
...
...
@@ -14,5 +15,10 @@ module EE
def
can_read_deploy_board?
can?
(
current_user
,
:read_deploy_board
,
environment
.
project
)
end
def
can_read_alert_management_alert?
can?
(
current_user
,
:read_alert_management_alert
,
environment
.
project
)
&&
environment
.
project
.
feature_available?
(
:environment_alerts
)
end
end
end
ee/spec/features/projects/environments/environments_spec.rb
View file @
f7e24cbf
...
...
@@ -182,4 +182,53 @@ RSpec.describe 'Environments page', :js do
end
end
end
context
'when environment has an open alert'
do
let!
(
:alert
)
do
create
(
:alert_management_alert
,
:triggered
,
:prometheus
,
title:
'HTTP Error Rate'
,
project:
project
,
environment:
environment
,
prometheus_alert:
prometheus_alert
)
end
let!
(
:prometheus_alert
)
do
create
(
:prometheus_alert
,
project:
project
,
environment:
environment
,
prometheus_metric:
prometheus_metric
)
end
let!
(
:prometheus_metric
)
do
create
(
:prometheus_metric
,
project:
project
,
unit:
'%'
)
end
before
do
stub_licensed_features
(
environment_alerts:
true
)
end
it
'shows the open alert for the environment row'
do
visit
project_environments_path
(
project
)
within
(
find
(
'div[data-testid="alert"]'
))
do
expect
(
page
).
to
have_content
(
'Critical'
)
expect
(
page
).
to
have_content
(
'HTTP Error Rate exceeded 1.0%'
)
expect
(
page
).
to
have_link
(
'View Details'
,
href:
alert
.
present
.
details_url
)
end
# and it's not shown when the alert is resolved.
alert
.
resolve!
visit
project_environments_path
(
project
)
expect
(
page
).
not_to
have_css
(
'div[data-testid="alert"]'
)
end
context
'when user does not have a license for the feature'
do
before
do
stub_licensed_features
(
environment_alerts:
false
)
end
it
'does not show the open alert for the environment row'
do
visit
project_environments_path
(
project
)
expect
(
page
).
not_to
have_css
(
'div[data-testid="alert"]'
)
end
end
end
end
ee/spec/serializers/environment_entity_spec.rb
View file @
f7e24cbf
...
...
@@ -16,6 +16,42 @@ RSpec.describe EnvironmentEntity do
describe
'#as_json'
do
subject
{
entity
.
as_json
}
context
'with alert'
do
let!
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
let!
(
:prometheus_alert
)
{
create
(
:prometheus_alert
,
project:
project
,
environment:
environment
)
}
let!
(
:alert
)
{
create
(
:alert_management_alert
,
:triggered
,
:prometheus
,
project:
project
,
environment:
environment
,
prometheus_alert:
prometheus_alert
)
}
before
do
stub_licensed_features
(
environment_alerts:
true
)
end
it
'exposes active alert flag'
do
project
.
add_maintainer
(
user
)
expect
(
subject
[
:has_opened_alert
]).
to
eq
(
true
)
end
context
'when user does not have permission to read alert'
do
it
'does not expose active alert flag'
do
project
.
add_reporter
(
user
)
expect
(
subject
[
:has_opened_alert
]).
to
be_nil
end
end
context
'when license is insufficient'
do
before
do
stub_licensed_features
(
environment_alerts:
false
)
end
it
'does not expose active alert flag'
do
project
.
add_maintainer
(
user
)
expect
(
subject
[
:has_opened_alert
]).
to
be_nil
end
end
end
context
'when deploy_boards are available'
do
before
do
stub_licensed_features
(
deploy_board:
true
)
...
...
spec/serializers/environment_entity_spec.rb
View file @
f7e24cbf
...
...
@@ -82,26 +82,6 @@ RSpec.describe EnvironmentEntity do
end
end
context
'with alert'
do
let!
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
let!
(
:prometheus_alert
)
{
create
(
:prometheus_alert
,
project:
project
,
environment:
environment
)
}
let!
(
:alert
)
{
create
(
:alert_management_alert
,
:triggered
,
:prometheus
,
project:
project
,
environment:
environment
,
prometheus_alert:
prometheus_alert
)
}
it
'exposes active alert flag'
do
project
.
add_maintainer
(
user
)
expect
(
subject
[
:has_opened_alert
]).
to
eq
(
true
)
end
context
'when user does not have permission to read alert'
do
it
'does not expose active alert flag'
do
project
.
add_reporter
(
user
)
expect
(
subject
[
:has_opened_alert
]).
to
be_nil
end
end
end
context
'pod_logs'
do
context
'with reporter access'
do
before
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