Skip to content
代码片段 群组 项目
提交 03a7fcdd 编辑于 作者: Dan Davison's avatar Dan Davison
浏览文件

Merge branch 'andrey-dora-metrics-api-e2e-spec' into 'master'

E2E: staging only spec for dora metrics api endpoint validation

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/127348



Merged-by: default avatarDan Davison <ddavison@gitlab.com>
Approved-by: default avatarDan Davison <ddavison@gitlab.com>
Approved-by: default avatarWill Meek <wmeek@gitlab.com>
Reviewed-by: default avatarDan Davison <ddavison@gitlab.com>
Co-authored-by: default avatarAndrejs Cunskis <acunskis@gitlab.com>
No related branches found
No related tags found
无相关合并请求
# frozen_string_literal: true
module QA
module EE
module Resource
# Common implementation for fetching group/project dora metrics
#
module DoraMetrics
def api_dora_metrics_path
"#{api_get_path}/dora/metrics"
end
# Fetch dora metrics, see: https://docs.gitlab.com/ee/api/dora/metrics.html
#
# @param [String] metric
# @param [String] start_date
# @param [String] end_date
# @param [String] interval
# @return [Array]
def dora_metrics(metric:, start_date: nil, end_date: nil, interval: "all")
response = get(
request_url(
api_dora_metrics_path,
metric: metric,
start_date: start_date,
end_date: end_date,
interval: interval
)
)
parse_body(response).map { |entry| { date: entry[:date], value: entry[:value].round(2) } }
end
end
end
end
end
...@@ -4,6 +4,8 @@ module QA ...@@ -4,6 +4,8 @@ module QA
module EE module EE
module Resource module Resource
module GroupBase module GroupBase
include DoraMetrics
# Get group epics # Get group epics
# #
# @return [Array<QA::EE::Resource::Epic>] # @return [Array<QA::EE::Resource::Epic>]
......
...@@ -4,6 +4,8 @@ module QA ...@@ -4,6 +4,8 @@ module QA
module EE module EE
module Resource module Resource
module Project module Project
include DoraMetrics
# Get project push rules # Get project push rules
# #
# @return [Hash] # @return [Hash]
......
# frozen_string_literal: true
module QA
RSpec.describe 'Plan', :requires_admin, product_group: :optimize, only: { subdomain: :staging } do
shared_examples "dora metrics api endpoint" do |expectation|
def metric(metric)
resource.dora_metrics(metric: metric, interval: "monthly", start_date: "2023-07-01", end_date: "2023-07-24")
end
it "returns correct metrics", :aggregate_failures do
lead_time = metric("lead_time_for_changes")
deployment_frequency = metric("deployment_frequency")
expect(lead_time).to match_array(expectation[:lead_time])
expect(deployment_frequency).to match_array(expectation[:deployment_frequency])
end
end
describe 'Dora Metrics' do
let(:admin_api_client) { Runtime::API::Client.as_admin }
let(:group) do
Resource::Sandbox.init do |resource|
resource.api_client = admin_api_client
resource.path = "optimize-vsa-test"
end.reload!
end
context "with group metrics", testcase: "https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/419615" do
let(:resource) { group }
it_behaves_like "dora metrics api endpoint", {
lead_time: [{ date: "2023-07-01", value: 509930.5 }],
deployment_frequency: [{ date: "2023-07-01", value: 0.17 }]
}
end
context "with project metrics", testcase: "https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/419616" do
let(:resource) { project }
let(:project) do
Resource::Project.init do |resource|
resource.add_name_uuid = false
resource.api_client = admin_api_client
resource.group = group
resource.path = "optimize-sandbox"
resource.name = "optimize-sandbox"
end.reload!
end
it_behaves_like "dora metrics api endpoint", {
lead_time: [{ date: "2023-07-01", value: 509930.5 }],
deployment_frequency: [{ date: "2023-07-01", value: 0.17 }]
}
end
end
end
end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册