Commit fdc50f26 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch 'cicd-plan-limits-ui' into 'master'

Allow administrators to change plan limits via the UI

See merge request gitlab-org/gitlab!82521
parents 2c1bad6b 8ed789d5
......@@ -38,6 +38,13 @@ class Admin::PlanLimitsController < Admin::ApplicationController
pypi_max_file_size
terraform_module_max_file_size
generic_packages_max_file_size
ci_pipeline_size
ci_active_jobs
ci_project_subscriptions
ci_pipeline_schedules
ci_needs_size_limit
ci_registered_group_runners
ci_registered_project_runners
])
end
end
......@@ -20,8 +20,7 @@
= expanded_by_default? ? _('Collapse') : _('Expand')
%p
= _('Customize CI/CD settings, including Auto DevOps, shared runners, and job artifacts.')
.settings-content
= render 'ci_cd'
= render 'ci_cd'
= render_if_exists 'admin/application_settings/required_instance_ci_setting', expanded: expanded_by_default?
......
......@@ -2609,6 +2609,9 @@ msgstr ""
msgid "AdminSettings|Auto DevOps domain"
msgstr ""
msgid "AdminSettings|CI/CD limits"
msgstr ""
msgid "AdminSettings|Configure Let's Encrypt"
msgstr ""
......@@ -2648,6 +2651,24 @@ msgstr ""
msgid "AdminSettings|Maximum duration of a session for Git operations when 2FA is enabled."
msgstr ""
msgid "AdminSettings|Maximum number of DAG dependencies that a job can have"
msgstr ""
msgid "AdminSettings|Maximum number of jobs in a single pipeline"
msgstr ""
msgid "AdminSettings|Maximum number of pipeline schedules"
msgstr ""
msgid "AdminSettings|Maximum number of pipeline subscriptions to and from a project"
msgstr ""
msgid "AdminSettings|Maximum number of runners registered per group"
msgstr ""
msgid "AdminSettings|Maximum number of runners registered per project"
msgstr ""
msgid "AdminSettings|New CI/CD variables in projects and groups default to protected."
msgstr ""
......@@ -2663,6 +2684,9 @@ msgstr ""
msgid "AdminSettings|Required pipeline configuration"
msgstr ""
msgid "AdminSettings|Save %{name} limits"
msgstr ""
msgid "AdminSettings|Select a CI/CD template"
msgstr ""
......@@ -2678,6 +2702,9 @@ msgstr ""
msgid "AdminSettings|Set a CI/CD template as the required pipeline configuration for all projects in the instance. Project CI/CD configuration merges into the required pipeline configuration when the pipeline runs. %{link_start}What is a required pipeline configuration?%{link_end}"
msgstr ""
msgid "AdminSettings|Set limit to 0 to disable it."
msgstr ""
msgid "AdminSettings|Set the initial name and protections for the default branch of new repositories created in the instance."
msgstr ""
......@@ -2699,6 +2726,9 @@ msgstr ""
msgid "AdminSettings|The template for the required pipeline configuration can be one of the GitLab-provided templates, or a custom template added to an instance template repository. %{link_start}How do I create an instance template repository?%{link_end}"
msgstr ""
msgid "AdminSettings|Total number of jobs in currently active pipelines"
msgstr ""
msgid "AdminStatistics|Active Users"
msgstr ""
......
......@@ -311,7 +311,9 @@ RSpec.describe 'Admin updates settings' do
end
context 'CI/CD page' do
it 'change CI/CD settings' do
let_it_be(:default_plan) { create(:default_plan) }
it 'changes CI/CD settings' do
visit ci_cd_admin_application_settings_path
page.within('.as-ci-cd') do
......@@ -329,6 +331,31 @@ RSpec.describe 'Admin updates settings' do
expect(page).to have_content "Application settings saved successfully"
end
it 'changes CI/CD limits', :aggregate_failures do
visit ci_cd_admin_application_settings_path
page.within('.as-ci-cd') do
fill_in 'plan_limits_ci_pipeline_size', with: 10
fill_in 'plan_limits_ci_active_jobs', with: 20
fill_in 'plan_limits_ci_project_subscriptions', with: 30
fill_in 'plan_limits_ci_pipeline_schedules', with: 40
fill_in 'plan_limits_ci_needs_size_limit', with: 50
fill_in 'plan_limits_ci_registered_group_runners', with: 60
fill_in 'plan_limits_ci_registered_project_runners', with: 70
click_button 'Save Default limits'
end
limits = default_plan.reload.limits
expect(limits.ci_pipeline_size).to eq(10)
expect(limits.ci_active_jobs).to eq(20)
expect(limits.ci_project_subscriptions).to eq(30)
expect(limits.ci_pipeline_schedules).to eq(40)
expect(limits.ci_needs_size_limit).to eq(50)
expect(limits.ci_registered_group_runners).to eq(60)
expect(limits.ci_registered_project_runners).to eq(70)
expect(page).to have_content 'Application limits saved successfully'
end
context 'Runner Registration' do
context 'when feature is enabled' do
before do
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'admin/application_settings/_ci_cd' do
let_it_be(:admin) { create(:admin) }
let_it_be(:application_setting) { build(:application_setting) }
let_it_be(:limits_attributes) do
{
ci_pipeline_size: 10,
ci_active_jobs: 20,
ci_project_subscriptions: 30,
ci_pipeline_schedules: 40,
ci_needs_size_limit: 50,
ci_registered_group_runners: 60,
ci_registered_project_runners: 70
}
end
let_it_be(:default_plan_limits) { create(:plan_limits, :default_plan, **limits_attributes) }
let(:page) { Capybara::Node::Simple.new(rendered) }
before do
assign(:application_setting, application_setting)
allow(view).to receive(:current_user) { admin }
allow(view).to receive(:expanded) { true }
end
subject { render partial: 'admin/application_settings/ci_cd' }
context 'limits' do
before do
assign(:plans, [default_plan_limits.plan])
end
it 'has fields for CI/CD limits', :aggregate_failures do
subject
expect(rendered).to have_field('Maximum number of jobs in a single pipeline', type: 'number')
expect(page.find_field('Maximum number of jobs in a single pipeline').value).to eq('10')
expect(rendered).to have_field('Total number of jobs in currently active pipelines', type: 'number')
expect(page.find_field('Total number of jobs in currently active pipelines').value).to eq('20')
expect(rendered).to have_field('Maximum number of pipeline subscriptions to and from a project', type: 'number')
expect(page.find_field('Maximum number of pipeline subscriptions to and from a project').value).to eq('30')
expect(rendered).to have_field('Maximum number of pipeline schedules', type: 'number')
expect(page.find_field('Maximum number of pipeline schedules').value).to eq('40')
expect(rendered).to have_field('Maximum number of DAG dependencies that a job can have', type: 'number')
expect(page.find_field('Maximum number of DAG dependencies that a job can have').value).to eq('50')
expect(rendered).to have_field('Maximum number of runners registered per group', type: 'number')
expect(page.find_field('Maximum number of runners registered per group').value).to eq('60')
expect(rendered).to have_field('Maximum number of runners registered per project', type: 'number')
expect(page.find_field('Maximum number of runners registered per project').value).to eq('70')
end
it 'does not display the plan name when there is only one plan' do
subject
expect(page).not_to have_selector('a[data-action="plan0"]')
end
end
context 'with multiple plans' do
let_it_be(:plan) { create(:plan, name: 'Ultimate') }
let_it_be(:ultimate_plan_limits) { create(:plan_limits, plan: plan, **limits_attributes) }
before do
assign(:plans, [default_plan_limits.plan, ultimate_plan_limits.plan])
end
it 'displays the plan name when there is more than one plan' do
subject
expect(page).to have_content('Default')
expect(page).to have_content('Ultimate')
expect(page).to have_selector('a[data-action="plan0"]')
expect(page).to have_selector('a[data-action="plan1"]')
end
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