Commit da04a73c authored by Fabio Pitino's avatar Fabio Pitino

Merge branch 'extend-drop-running-builds-when-ci-minutes-exceeded-to-paid-plans' into 'master'

Enable live consumption for all paid plans

See merge request gitlab-org/gitlab!62178
parents cc5c3f4f acc18358
...@@ -77,8 +77,6 @@ module Ci ...@@ -77,8 +77,6 @@ module Ci
ServiceResponse.error(message: 'Feature not enabled') ServiceResponse.error(message: 'Feature not enabled')
elsif !build.running? elsif !build.running?
ServiceResponse.error(message: 'Build is not running') ServiceResponse.error(message: 'Build is not running')
elsif !free_or_trial_plan?
ServiceResponse.error(message: 'Project is not on Free or trial plan')
elsif !build.shared_runners_minutes_limit_enabled? elsif !build.shared_runners_minutes_limit_enabled?
ServiceResponse.error(message: 'CI minutes limit not enabled for build') ServiceResponse.error(message: 'CI minutes limit not enabled for build')
else else
...@@ -90,10 +88,6 @@ module Ci ...@@ -90,10 +88,6 @@ module Ci
Feature.enabled?(:ci_minutes_track_live_consumption, build.project, default_enabled: :yaml) Feature.enabled?(:ci_minutes_track_live_consumption, build.project, default_enabled: :yaml)
end end
def free_or_trial_plan?
Gitlab.com? && (root_namespace.free_plan? || root_namespace.trial?)
end
def consumption_since_last_update def consumption_since_last_update
last_tracking = time_last_tracked_consumption!(Time.current.utc) last_tracking = time_last_tracked_consumption!(Time.current.utc)
duration = Time.current.utc - last_tracking duration = Time.current.utc - last_tracking
......
...@@ -11,10 +11,6 @@ RSpec.describe Ci::Minutes::TrackLiveConsumptionService do ...@@ -11,10 +11,6 @@ RSpec.describe Ci::Minutes::TrackLiveConsumptionService do
let(:service) { described_class.new(build) } let(:service) { described_class.new(build) }
before do
allow(Gitlab).to receive(:com?).and_return(true)
end
describe '#execute', :clean_gitlab_redis_shared_state do describe '#execute', :clean_gitlab_redis_shared_state do
subject { service.execute } subject { service.execute }
...@@ -76,22 +72,6 @@ RSpec.describe Ci::Minutes::TrackLiveConsumptionService do ...@@ -76,22 +72,6 @@ RSpec.describe Ci::Minutes::TrackLiveConsumptionService do
it_behaves_like 'returns early', 'CI minutes limit not enabled for build' it_behaves_like 'returns early', 'CI minutes limit not enabled for build'
end end
context 'when project is not on Free plan' do
before do
create(:gitlab_subscription, :premium, namespace: namespace)
end
it_behaves_like 'returns early', 'Project is not on Free or trial plan'
end
context 'when running on self-hosted' do
before do
allow(Gitlab).to receive(:com?).and_return(false)
end
it_behaves_like 'returns early', 'Project is not on Free or trial plan'
end
context 'when shared runners limit is not enabled for build' do context 'when shared runners limit is not enabled for build' do
before do before do
allow(build).to receive(:shared_runners_minutes_limit_enabled?).and_return(false) allow(build).to receive(:shared_runners_minutes_limit_enabled?).and_return(false)
...@@ -143,6 +123,14 @@ RSpec.describe Ci::Minutes::TrackLiveConsumptionService do ...@@ -143,6 +123,14 @@ RSpec.describe Ci::Minutes::TrackLiveConsumptionService do
it_behaves_like 'limit exceeded' it_behaves_like 'limit exceeded'
end end
context 'when namespace is on a paid plan' do
before do
create(:gitlab_subscription, :premium, namespace: namespace)
end
it_behaves_like 'limit exceeded'
end
context 'when feature flag is disabled' do context 'when feature flag is disabled' do
before do before do
stub_feature_flags(ci_minutes_track_live_consumption: false) stub_feature_flags(ci_minutes_track_live_consumption: false)
......
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