Commit 06c04808 authored by Miguel Rincon's avatar Miguel Rincon

Merge branch 'pedropombeiro/356671/graphql-implement-runner-upgrade-status' into 'master'

GraphQL: Implement CiRunnerType.upgradeStatus

See merge request gitlab-org/gitlab!84490
parents a6272f54 55ccd81a
# frozen_string_literal: true
module Types
module Ci
class RunnerUpgradeStatusTypeEnum < BaseEnum
graphql_name 'CiRunnerUpgradeStatusType'
value 'NOT_AVAILABLE',
description: "An update is not available for the runner.",
value: :not_available
value 'AVAILABLE',
description: "An update is available for the runner.",
value: :available
value 'RECOMMENDED',
description: "An update is available and recommended for the runner.",
value: :recommended
end
end
end
......@@ -9450,6 +9450,7 @@ Represents the total number of issues and their weights for a particular day.
| <a id="cirunnershortsha"></a>`shortSha` | [`String`](#string) | First eight characters of the runner's token used to authenticate new job requests. Used as the runner's unique ID. |
| <a id="cirunnertaglist"></a>`tagList` | [`[String!]`](#string) | Tags associated with the runner. |
| <a id="cirunnertokenexpiresat"></a>`tokenExpiresAt` | [`Time`](#time) | Runner token expiration time. |
| <a id="cirunnerupgradestatus"></a>`upgradeStatus` **{warning-solid}** | [`CiRunnerUpgradeStatusType`](#cirunnerupgradestatustype) | **Deprecated** in 14.10. This feature is in Alpha, and can be removed or changed at any point. |
| <a id="cirunneruserpermissions"></a>`userPermissions` | [`RunnerPermissions!`](#runnerpermissions) | Permissions for the current user on the resource. |
| <a id="cirunnerversion"></a>`version` | [`String`](#string) | Version of the runner. |
......@@ -17841,6 +17842,14 @@ Values for sorting runners.
| <a id="cirunnertypeinstance_type"></a>`INSTANCE_TYPE` | A runner that is instance type. |
| <a id="cirunnertypeproject_type"></a>`PROJECT_TYPE` | A runner that is project type. |
### `CiRunnerUpgradeStatusType`
| Value | Description |
| ----- | ----------- |
| <a id="cirunnerupgradestatustypeavailable"></a>`AVAILABLE` | An update is available for the runner. |
| <a id="cirunnerupgradestatustypenot_available"></a>`NOT_AVAILABLE` | An update is not available for the runner. |
| <a id="cirunnerupgradestatustyperecommended"></a>`RECOMMENDED` | An update is available and recommended for the runner. |
### `CodeQualityDegradationSeverity`
| Value | Description |
......@@ -11,6 +11,14 @@ module EE
description: 'Public projects\' "minutes cost factor" associated with the runner (GitLab.com only).'
field :private_projects_minutes_cost_factor, GraphQL::Types::Float, null: true,
description: 'Private projects\' "minutes cost factor" associated with the runner (GitLab.com only).'
field :upgrade_status, ::Types::Ci::RunnerUpgradeStatusTypeEnum, null: true,
description: 'Availability of upgrades for the runner.',
deprecated: { milestone: '14.10', reason: :alpha }
def upgrade_status
::Gitlab::Ci::RunnerUpgradeCheck.instance.check_runner_upgrade_status(object.version)
end
end
end
end
......
......@@ -6,7 +6,7 @@ RSpec.describe GitlabSchema.types['CiRunner'] do
it { expect(described_class.graphql_name).to eq('CiRunner') }
it 'includes the ee specific fields' do
expected_fields = %w[public_projects_minutes_cost_factor private_projects_minutes_cost_factor]
expected_fields = %w[public_projects_minutes_cost_factor private_projects_minutes_cost_factor upgrade_status]
expect(described_class).to include_graphql_fields(*expected_fields)
end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Query.runner(id)' do
include GraphqlHelpers
let_it_be(:user) { create(:user, :admin) }
shared_examples 'runner details fetch operation returning expected upgradeStatus' do
let(:query) do
wrap_fields(query_graphql_path(query_path, all_graphql_fields_for('CiRunner')))
end
let(:query_path) do
[
[:runner, { id: runner.to_global_id.to_s }]
]
end
it 'retrieves expected fields' do
post_graphql(query, current_user: user)
runner_data = graphql_data_at(:runner)
expect(runner_data).not_to be_nil
expect(runner_data).to match a_hash_including(
'id' => runner.to_global_id.to_s,
'upgradeStatus' => expected_upgrade_status
)
end
end
describe 'upgradeStatus' do
let_it_be(:runner) { create(:ci_runner, description: 'Runner 1', version: 'adfe156', revision: 'a') }
before do
expect(::Gitlab::Ci::RunnerUpgradeCheck.instance).to receive(:check_runner_upgrade_status)
.and_return(upgrade_status)
.once
end
context 'with RunnerUpgradeCheck returning :not_available' do
let(:upgrade_status) { :not_available }
let(:expected_upgrade_status) { 'NOT_AVAILABLE' }
it_behaves_like('runner details fetch operation returning expected upgradeStatus')
end
context 'with RunnerUpgradeCheck returning :available' do
let(:upgrade_status) { :available }
let(:expected_upgrade_status) { 'AVAILABLE' }
it_behaves_like('runner details fetch operation returning expected upgradeStatus')
end
context 'with RunnerUpgradeCheck returning :recommended' do
let(:upgrade_status) { :recommended }
let(:expected_upgrade_status) { 'RECOMMENDED' }
it_behaves_like('runner details fetch operation returning expected upgradeStatus')
end
end
end
......@@ -27,6 +27,10 @@ RSpec.describe 'Query.runner(id)' do
let_it_be(:active_project_runner) { create(:ci_runner, :project) }
before do
allow(Gitlab::Ci::RunnerUpgradeCheck.instance).to receive(:check_runner_upgrade_status)
end
shared_examples 'runner details fetch' do
let(:query) do
wrap_fields(query_graphql_path(query_path, all_graphql_fields_for('CiRunner')))
......
......@@ -34,6 +34,8 @@ RSpec.describe 'Query.runners' do
end
before do
allow(Gitlab::Ci::RunnerUpgradeCheck.instance).to receive(:check_runner_upgrade_status)
post_graphql(query, current_user: current_user)
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