debian-mirror-gitlab/spec/support/helpers/metrics_dashboard_helpers.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.7 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
module MetricsDashboardHelpers
2020-10-24 23:57:45 +05:30
# @param dashboards [Hash<string, string>] - Should contain a hash where
# each key is the path to a dashboard in the repository and each value is
# the dashboard content.
# Ex: { '.gitlab/dashboards/dashboard1.yml' => fixture_file('lib/gitlab/metrics/dashboard/sample_dashboard.yml') }
def project_with_dashboards(dashboards, project_params = {})
create(:project, :custom_repo, **project_params, files: dashboards)
2019-07-31 22:56:46 +05:30
end
2020-10-24 23:57:45 +05:30
def project_with_dashboard(dashboard_path, dashboard_yml = nil, project_params = {})
2020-07-28 23:09:34 +05:30
dashboard_yml ||= fixture_file('lib/gitlab/metrics/dashboard/sample_dashboard.yml')
2020-10-24 23:57:45 +05:30
project_with_dashboards({ dashboard_path => dashboard_yml }, project_params)
end
def project_with_dashboard_namespace(dashboard_path, dashboard_yml = nil, project_params = {})
project_with_dashboard(dashboard_path, dashboard_yml, project_params.reverse_merge(path: 'monitor-project'))
2020-07-28 23:09:34 +05:30
end
2019-07-31 22:56:46 +05:30
def delete_project_dashboard(project, user, dashboard_path)
project.repository.delete_file(
user,
dashboard_path,
branch_name: 'master',
message: 'Delete dashboard'
)
project.repository.refresh_method_caches([:metrics_dashboard])
end
2020-07-28 23:09:34 +05:30
def load_sample_dashboard
load_dashboard_yaml(fixture_file('lib/gitlab/metrics/dashboard/sample_dashboard.yml'))
end
def load_dashboard_yaml(data)
::Gitlab::Config::Loader::Yaml.new(data).load_raw!
end
2019-10-12 21:52:04 +05:30
def system_dashboard_path
2020-01-01 13:55:28 +05:30
Metrics::Dashboard::SystemDashboardService::DASHBOARD_PATH
end
def pod_dashboard_path
Metrics::Dashboard::PodDashboardService::DASHBOARD_PATH
2019-10-12 21:52:04 +05:30
end
def business_metric_title
2020-11-24 15:15:51 +05:30
Enums::PrometheusMetric.group_details[:business][:group_title]
2019-10-12 21:52:04 +05:30
end
2019-07-31 22:56:46 +05:30
end