Commit 3e372137 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch 'pedropombeiro/333232-update-can-change-cost-factor' into 'master'

GraphQL: Allow updating runner cost factor in mutation [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!65047
parents 20276aaa 3ba921cc
......@@ -66,3 +66,5 @@ module Mutations
end
end
end
Mutations::Ci::Runner::Update.prepend_mod_with('Mutations::Ci::Runner::Update')
......@@ -3558,6 +3558,8 @@ Input type: `RunnerUpdateInput`
| <a id="mutationrunnerupdateid"></a>`id` | [`CiRunnerID!`](#cirunnerid) | ID of the runner to update. |
| <a id="mutationrunnerupdatelocked"></a>`locked` | [`Boolean`](#boolean) | Indicates the runner is locked. |
| <a id="mutationrunnerupdatemaximumtimeout"></a>`maximumTimeout` | [`Int`](#int) | Maximum timeout (in seconds) for jobs processed by the runner. |
| <a id="mutationrunnerupdateprivateprojectsminutescostfactor"></a>`privateProjectsMinutesCostFactor` | [`Float`](#float) | Private projects' "minutes cost factor" associated with the runner (GitLab.com only). |
| <a id="mutationrunnerupdatepublicprojectsminutescostfactor"></a>`publicProjectsMinutesCostFactor` | [`Float`](#float) | Public projects' "minutes cost factor" associated with the runner (GitLab.com only). |
| <a id="mutationrunnerupdaterununtagged"></a>`runUntagged` | [`Boolean`](#boolean) | Indicates the runner is able to run untagged jobs. |
| <a id="mutationrunnerupdatetaglist"></a>`tagList` | [`[String!]`](#string) | Tags associated with the runner. |
......
# frozen_string_literal: true
module EE
module Mutations
module Ci
module Runner
module Update
extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
prepended do
argument :public_projects_minutes_cost_factor, GraphQL::FLOAT_TYPE,
required: false,
description: 'Public projects\' "minutes cost factor" associated with the runner (GitLab.com only).'
argument :private_projects_minutes_cost_factor, GraphQL::FLOAT_TYPE,
required: false,
description: 'Private projects\' "minutes cost factor" associated with the runner (GitLab.com only).'
end
end
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Mutations::Ci::Runner::Update do
include GraphqlHelpers
describe '#resolve' do
let(:runner) do
create(:ci_runner, active: true, locked: false, run_untagged: true, public_projects_minutes_cost_factor: 0.0,
private_projects_minutes_cost_factor: 0.0)
end
let(:mutation) { described_class.new(object: nil, context: current_ctx, field: nil) }
subject(:mutation_result) { mutation.resolve(id: runner.to_global_id, **mutation_params) }
def resolve
mutation_result
runner.reload
end
context 'when user can update runner', :enable_admin_mode do
let(:admin_user) { create(:user, :admin) }
let(:current_ctx) { { current_user: admin_user } }
context 'when mutation includes cost factor arguments' do
let(:mutation_params) do
{
public_projects_minutes_cost_factor: 2.5,
private_projects_minutes_cost_factor: 0.5
}
end
it 'updates cost factors to specified values', :aggregate_failures do
expect { resolve }
.to change { runner.public_projects_minutes_cost_factor }.from(0).to(2.5)
.and change { runner.private_projects_minutes_cost_factor }.from(0).to(0.5)
end
end
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