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
e7f36851
Commit
e7f36851
authored
Jan 06, 2022
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent raising validation errors for SyncDashboardsWorker
Changelog: changed
parent
1afbeb49
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
7 deletions
+25
-7
app/workers/metrics/dashboard/sync_dashboards_worker.rb
app/workers/metrics/dashboard/sync_dashboards_worker.rb
+1
-1
spec/workers/metrics/dashboard/sync_dashboards_worker_spec.rb
.../workers/metrics/dashboard/sync_dashboards_worker_spec.rb
+24
-6
No files found.
app/workers/metrics/dashboard/sync_dashboards_worker.rb
View file @
e7f36851
...
...
@@ -18,7 +18,7 @@ module Metrics
dashboard_paths
=
::
Gitlab
::
Metrics
::
Dashboard
::
RepoDashboardFinder
.
list_dashboards
(
project
)
dashboard_paths
.
each
do
|
dashboard_path
|
::
Gitlab
::
Metrics
::
Dashboard
::
Importer
.
new
(
dashboard_path
,
project
).
execute
!
::
Gitlab
::
Metrics
::
Dashboard
::
Importer
.
new
(
dashboard_path
,
project
).
execute
end
end
end
...
...
spec/workers/metrics/dashboard/sync_dashboards_worker_spec.rb
View file @
e7f36851
...
...
@@ -10,16 +10,34 @@ RSpec.describe Metrics::Dashboard::SyncDashboardsWorker do
let
(
:dashboard_path
)
{
'.gitlab/dashboards/test.yml'
}
describe
".perform"
do
it
'imports metrics'
do
expect
{
worker
.
perform
(
project
.
id
)
}.
to
change
(
PrometheusMetric
,
:count
).
by
(
3
)
context
'with valid dashboard hash'
do
it
'imports metrics'
do
expect
{
worker
.
perform
(
project
.
id
)
}.
to
change
(
PrometheusMetric
,
:count
).
by
(
3
)
end
it
'is idempotent'
do
2
.
times
do
worker
.
perform
(
project
.
id
)
end
expect
(
PrometheusMetric
.
count
).
to
eq
(
3
)
end
end
it
'is idempotent'
do
2
.
times
do
worker
.
perform
(
project
.
id
)
context
'with invalid dashboard hash'
do
before
do
allow_next_instance_of
(
Gitlab
::
Metrics
::
Dashboard
::
Importer
)
do
|
instance
|
allow
(
instance
).
to
receive
(
:dashboard_hash
).
and_return
({})
end
end
expect
(
PrometheusMetric
.
count
).
to
eq
(
3
)
it
'does not import metrics'
do
expect
{
worker
.
perform
(
project
.
id
)
}.
not_to
change
(
PrometheusMetric
,
:count
)
end
it
'does not raise an error'
do
expect
{
worker
.
perform
(
project
.
id
)
}.
not_to
raise_error
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