Commit 2b570f04 authored by Max Woolf's avatar Max Woolf

Merge branch '329178-remove-vsa-deployment-frequency-ff' into 'master'

Remove the DORA DF feature flag in VSA

See merge request gitlab-org/gitlab!73719
parents 2ea6c056 8d83b744
---
name: dora_deployment_frequency_in_vsa
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60367
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/329178
milestone: '13.12'
type: development
group: group::optimize
default_enabled: true
...@@ -19,24 +19,9 @@ module Gitlab ...@@ -19,24 +19,9 @@ module Gitlab
private private
def deployments_count def deployments_count
@deployments_count ||= if Feature.enabled?(:dora_deployment_frequency_in_vsa, default_enabled: :yaml) @deployments_count ||= deployment_count_via_dora_api
deployment_count_via_dora_api
else
deployment_count_via_finder
end
end end
# rubocop: disable CodeReuse/ActiveRecord
def deployment_count_via_finder
deployments = DeploymentsFinder
.new(group: group, finished_after: options[:from], finished_before: options[:to], status: :success, order_by: :finished_at)
.execute
deployments = deployments.where(project_id: options[:projects]) if options[:projects].present?
deployments.count
end
# rubocop: enable CodeReuse/ActiveRecord
def deployment_count_via_dora_api def deployment_count_via_dora_api
result = Dora::AggregateMetricsService.new( result = Dora::AggregateMetricsService.new(
container: group, container: group,
......
...@@ -132,155 +132,133 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::Summary::Group::StageSummary d ...@@ -132,155 +132,133 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::Summary::Group::StageSummary d
environment = project.environments.production.first || create(:environment, :production, project: project) environment = project.environments.production.first || create(:environment, :production, project: project)
create(:deployment, :success, args.merge(environment: environment)) create(:deployment, :success, args.merge(environment: environment))
# this is needed for the dora_deployment_frequency_in_vsa feature flag so we have aggregated data # this is needed for the DORA API so we have aggregated data
::Dora::DailyMetrics::RefreshWorker.new.perform(environment.id, Time.current.to_date.to_s) ::Dora::DailyMetrics::RefreshWorker.new.perform(environment.id, Time.current.to_date.to_s)
end end
shared_examples 'VSA deployment related metrics' do describe "#deploys" do
describe "#deploys" do let(:current_time) { Time.current }
let(:current_time) { Time.current } let(:one_day_ago) { current_time - 1.day }
let(:one_day_ago) { current_time - 1.day } let(:two_days_ago) { current_time - 2.days }
let(:two_days_ago) { current_time - 2.days } let(:five_days_ago) { current_time - 5.days }
let(:five_days_ago) { current_time - 5.days } let(:ten_days_ago) { current_time - 10.days }
let(:ten_days_ago) { current_time - 10.days }
context 'with from date' do context 'with from date' do
subject { described_class.new(group, options: { from: two_days_ago, current_user: user }).data } subject { described_class.new(group, options: { from: two_days_ago, current_user: user }).data }
before do before do
travel_to(five_days_ago) do travel_to(five_days_ago) do
create_deployment(project: project, finished_at: Time.current) create_deployment(project: project, finished_at: Time.current)
create_deployment(project: project_2, finished_at: Time.current) create_deployment(project: project_2, finished_at: Time.current)
end end
travel_to(current_time) do
create_deployment(project: project, finished_at: Time.current)
create_deployment(project: project_2, finished_at: Time.current)
end
end
it "finds the number of deploys made created after it" do
expect(subject.second[:value]).to eq('2')
end
it 'returns the localized title' do
Gitlab::I18n.with_locale(:ru) do
expect(subject.second[:title]).to eq(n_('Deploy', 'Deploys', 2))
end
end
context 'with subgroups' do
before do
travel_to(current_time) do travel_to(current_time) do
create_deployment(project: project, finished_at: Time.current) create_deployment(project: project, finished_at: Time.current)
create_deployment(project: project_2, finished_at: Time.current)
end end
end end
it "finds the number of deploys made created after it" do it "finds deploys from them" do
expect(subject.second[:value]).to eq('2') expect(subject.second[:value]).to eq('3')
end end
end
it 'returns the localized title' do context 'with projects specified in options' do
Gitlab::I18n.with_locale(:ru) do before do
expect(subject.second[:title]).to eq(n_('Deploy', 'Deploys', 2)) travel_to(Date.today) do
create_deployment(finished_at: current_time, project: create(:project, :repository, namespace: group, name: 'not_applicable'))
end end
end end
context 'with subgroups' do subject { described_class.new(group, options: { from: one_day_ago, current_user: user, projects: [project.id, project_2.id] }).data }
before do
travel_to(current_time) do
create_deployment(project: project, finished_at: Time.current)
end
end
it "finds deploys from them" do it 'shows deploys from those projects' do
expect(subject.second[:value]).to eq('3') expect(subject.second[:value]).to eq('2')
end
end end
end
context 'with projects specified in options' do context 'when `from` and `to` parameters are provided' do
before do subject { described_class.new(group, options: { from: ten_days_ago, to: one_day_ago, current_user: user }).data }
travel_to(Date.today) do
create_deployment(finished_at: current_time, project: create(:project, :repository, namespace: group, name: 'not_applicable'))
end
end
subject { described_class.new(group, options: { from: one_day_ago, current_user: user, projects: [project.id, project_2.id] }).data } it 'finds deployments from 5 days ago' do
expect(subject.second[:value]).to eq('2')
end
end
end
it 'shows deploys from those projects' do context 'with other projects' do
expect(subject.second[:value]).to eq('2') before do
end travel_to(one_day_ago) do
create_deployment(finished_at: Time.current, project: create(:project, :repository, namespace: create(:group)))
end end
end
context 'when `from` and `to` parameters are provided' do it "doesn't find deploys from them" do
subject { described_class.new(group, options: { from: ten_days_ago, to: one_day_ago, current_user: user }).data } expect(subject.second[:value]).to eq('-')
end
end
it 'finds deployments from 5 days ago' do describe '#deployment_frequency' do
expect(subject.second[:value]).to eq('2') let(:from) { ten_days_ago }
end let(:to) { nil }
end
subject do
described_class.new(group, options: {
from: from,
to: to,
current_user: user
}).data.third
end end
context 'with other projects' do it 'includes the unit: `per day`' do
before do expect(subject[:unit]).to eq(_('per day'))
travel_to(one_day_ago) do end
create_deployment(finished_at: Time.current, project: create(:project, :repository, namespace: create(:group)))
end
end
it "doesn't find deploys from them" do before do
expect(subject.second[:value]).to eq('-') travel_to(five_days_ago) do
create_deployment(finished_at: Time.current, project: project)
end end
end end
describe '#deployment_frequency' do context 'when `to` is nil' do
let(:from) { ten_days_ago } it 'includes range until now' do
let(:to) { nil } # 1 deployment over 7 days
expect(subject[:value]).to eq('0.1')
subject do
described_class.new(group, options: {
from: from,
to: to,
current_user: user
}).data.third
end end
end
it 'includes the unit: `per day`' do context 'when `to` is given' do
expect(subject[:unit]).to eq(_('per day')) let(:from) { ten_days_ago }
end let(:to) { 10.days.from_now }
before do before do
travel_to(five_days_ago) do travel_to(Date.yesterday) do
create_deployment(finished_at: Time.current, project: project) create_deployment(finished_at: Time.current, project: project)
end end
end end
context 'when `to` is nil' do it 'returns deployment frequency within `from` and `to` range' do
it 'includes range until now' do # 2 deployments over 20 days
# 1 deployment over 7 days expect(subject[:value]).to eq('0.1')
expect(subject[:value]).to eq('0.1')
end
end
context 'when `to` is given' do
let(:from) { ten_days_ago }
let(:to) { 10.days.from_now }
before do
travel_to(Date.yesterday) do
create_deployment(finished_at: Time.current, project: project)
end
end
it 'returns deployment frequency within `from` and `to` range' do
# 2 deployments over 20 days
expect(subject[:value]).to eq('0.1')
end
end end
end end
end end
end end
context 'when dora_deployment_frequency_in_vsa feature flag is enabled' do
before do
stub_feature_flags(dora_deployment_frequency_in_vsa: true)
expect(Dora::AggregateMetricsService).to receive(:new).and_call_original
end
it_behaves_like 'VSA deployment related metrics'
end
context 'when dora_deployment_frequency_in_vsa feature flag is disabled' do
before do
stub_feature_flags(dora_deployment_frequency_in_vsa: false)
expect(Dora::AggregateMetricsService).not_to receive(:new)
end
it_behaves_like 'VSA deployment related metrics'
end
end end
...@@ -6,7 +6,7 @@ shared_examples 'deployment metrics examples' do ...@@ -6,7 +6,7 @@ shared_examples 'deployment metrics examples' do
environment = project.environments.production.first || create(:environment, :production, project: project) environment = project.environments.production.first || create(:environment, :production, project: project)
create(:deployment, :success, args.merge(environment: environment)) create(:deployment, :success, args.merge(environment: environment))
# this is needed for the dora_deployment_frequency_in_vsa feature flag so we have aggregated data # this is needed for the DORA API so we have aggregated data
::Dora::DailyMetrics::RefreshWorker.new.perform(environment.id, Time.current.to_date.to_s) if Gitlab.ee? ::Dora::DailyMetrics::RefreshWorker.new.perform(environment.id, Time.current.to_date.to_s) if Gitlab.ee?
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment