debian-mirror-gitlab/spec/services/ci/runners/update_runner_service_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

67 lines
1.7 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe Ci::Runners::UpdateRunnerService, '#execute', feature_category: :runner_fleet do
2022-10-11 01:57:18 +05:30
subject(:execute) { described_class.new(runner).execute(params) }
2017-08-17 22:00:37 +05:30
let(:runner) { create(:ci_runner) }
2022-10-11 01:57:18 +05:30
before do
allow(runner).to receive(:tick_runner_queue)
end
2017-08-17 22:00:37 +05:30
2022-10-11 01:57:18 +05:30
context 'with description params' do
let(:params) { { description: 'new runner' } }
2017-08-17 22:00:37 +05:30
2022-10-11 01:57:18 +05:30
it 'updates the runner and ticking the queue' do
expect(execute).to be_success
2017-08-17 22:00:37 +05:30
2022-10-11 01:57:18 +05:30
runner.reload
2017-08-17 22:00:37 +05:30
2022-10-11 01:57:18 +05:30
expect(runner).to have_received(:tick_runner_queue)
expect(runner.description).to eq('new runner')
2017-08-17 22:00:37 +05:30
end
2022-10-11 01:57:18 +05:30
end
2017-08-17 22:00:37 +05:30
2022-10-11 01:57:18 +05:30
context 'with paused param' do
let(:params) { { paused: true } }
2022-04-04 11:22:00 +05:30
2022-10-11 01:57:18 +05:30
it 'updates the runner and ticking the queue' do
expect(runner.active).to be_truthy
expect(execute).to be_success
2022-04-04 11:22:00 +05:30
2022-10-11 01:57:18 +05:30
runner.reload
2022-04-04 11:22:00 +05:30
2022-10-11 01:57:18 +05:30
expect(runner).to have_received(:tick_runner_queue)
expect(runner.active).to be_falsey
2022-04-04 11:22:00 +05:30
end
2022-10-11 01:57:18 +05:30
end
2022-04-04 11:22:00 +05:30
2022-10-11 01:57:18 +05:30
context 'with cost factor params' do
let(:params) { { public_projects_minutes_cost_factor: 1.1, private_projects_minutes_cost_factor: 2.2 } }
2020-04-22 19:07:51 +05:30
2022-10-11 01:57:18 +05:30
it 'updates the runner cost factors' do
expect(execute).to be_success
2020-04-22 19:07:51 +05:30
2022-10-11 01:57:18 +05:30
runner.reload
2020-04-22 19:07:51 +05:30
2022-10-11 01:57:18 +05:30
expect(runner.public_projects_minutes_cost_factor).to eq(1.1)
expect(runner.private_projects_minutes_cost_factor).to eq(2.2)
2020-04-22 19:07:51 +05:30
end
2022-10-11 01:57:18 +05:30
end
2020-04-22 19:07:51 +05:30
2022-10-11 01:57:18 +05:30
context 'when params are not valid' do
let(:params) { { run_untagged: false } }
2017-08-17 22:00:37 +05:30
2022-10-11 01:57:18 +05:30
it 'does not update and returns error because it is not valid' do
expect(execute).to be_error
2017-08-17 22:00:37 +05:30
2022-10-11 01:57:18 +05:30
runner.reload
2017-08-17 22:00:37 +05:30
2022-10-11 01:57:18 +05:30
expect(runner).not_to have_received(:tick_runner_queue)
expect(runner.run_untagged).to be_truthy
2017-08-17 22:00:37 +05:30
end
end
end