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
ca9b067e
Commit
ca9b067e
authored
Jul 26, 2019
by
Tristan Read
Committed by
Thong Kuah
Jul 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feature test for gfm embedding metrics
parent
8b703075
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
0 deletions
+68
-0
spec/features/markdown/metrics_spec.rb
spec/features/markdown/metrics_spec.rb
+60
-0
spec/support/helpers/prometheus_helpers.rb
spec/support/helpers/prometheus_helpers.rb
+8
-0
No files found.
spec/features/markdown/metrics_spec.rb
0 → 100644
View file @
ca9b067e
# frozen_string_literal: true
require
'spec_helper'
describe
'Metrics rendering'
,
:js
,
:use_clean_rails_memory_store_caching
do
include
PrometheusHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:prometheus_project
)
}
let
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
description:
description
)
}
let
(
:description
)
{
"See [metrics dashboard](
#{
metrics_url
}
) for info."
}
let
(
:metrics_url
)
{
metrics_project_environment_url
(
project
,
environment
)
}
before
do
configure_host
import_common_metrics
stub_any_prometheus_request_with_response
project
.
add_developer
(
user
)
sign_in
(
user
)
end
after
do
restore_host
end
context
'with deployments and related deployable present'
do
it
'shows embedded metrics'
do
visit
project_issue_path
(
project
,
issue
)
expect
(
page
).
to
have_css
(
'div.prometheus-graph'
)
expect
(
page
).
to
have_text
(
'Memory Usage (Total)'
)
expect
(
page
).
to
have_text
(
'Core Usage (Total)'
)
end
end
def
import_common_metrics
::
Gitlab
::
DatabaseImporters
::
CommonMetrics
::
Importer
.
new
.
execute
end
def
configure_host
@original_default_host
=
default_url_options
[
:host
]
@original_gitlab_url
=
Gitlab
.
config
.
gitlab
[
:url
]
# Ensure we create a metrics url with the right host.
# Configure host for route helpers in specs (also updates root_url):
default_url_options
[
:host
]
=
Capybara
.
server_host
# Ensure we identify urls with the appropriate host.
# Configure host to include port in app:
Gitlab
.
config
.
gitlab
[
:url
]
=
root_url
.
chomp
(
'/'
)
end
def
restore_host
default_url_options
[
:host
]
=
@original_default_host
Gitlab
.
config
.
gitlab
[
:url
]
=
@original_gitlab_url
end
end
spec/support/helpers/prometheus_helpers.rb
View file @
ca9b067e
...
...
@@ -76,6 +76,14 @@ module PrometheusHelpers
WebMock
.
stub_request
(
:any
,
/prometheus.example.com/
)
end
def
stub_any_prometheus_request_with_response
(
status:
200
,
headers:
{},
body:
nil
)
stub_any_prometheus_request
.
to_return
({
status:
status
,
headers:
{
'Content-Type'
=>
'application/json'
}.
merge
(
headers
),
body:
body
||
prometheus_values_body
.
to_json
})
end
def
stub_all_prometheus_requests
(
environment_slug
,
body:
nil
,
status:
200
)
stub_prometheus_request
(
prometheus_query_with_time_url
(
prometheus_memory_query
(
environment_slug
),
Time
.
now
.
utc
),
...
...
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