2021-06-07 11:09:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe 'Runner (JavaScript fixtures)' do
|
|
|
|
include AdminModeHelper
|
|
|
|
include ApiHelpers
|
|
|
|
include JavaScriptFixturesHelpers
|
|
|
|
include GraphqlHelpers
|
|
|
|
|
|
|
|
let_it_be(:admin) { create(:admin) }
|
|
|
|
let_it_be(:group) { create(:group) }
|
|
|
|
let_it_be(:project) { create(:project, :repository, :public) }
|
2022-02-12 07:15:45 -05:00
|
|
|
let_it_be(:project_2) { create(:project, :repository, :public) }
|
2021-06-07 11:09:56 -04:00
|
|
|
|
|
|
|
let_it_be(:instance_runner) { create(:ci_runner, :instance, version: '1.0.0', revision: '123', description: 'Instance runner', ip_address: '127.0.0.1') }
|
|
|
|
let_it_be(:group_runner) { create(:ci_runner, :group, groups: [group], active: false, version: '2.0.0', revision: '456', description: 'Group runner', ip_address: '127.0.0.1') }
|
2021-08-23 11:10:43 -04:00
|
|
|
let_it_be(:group_runner_2) { create(:ci_runner, :group, groups: [group], active: false, version: '2.0.0', revision: '456', description: 'Group runner 2', ip_address: '127.0.0.1') }
|
2022-02-12 07:15:45 -05:00
|
|
|
let_it_be(:project_runner) { create(:ci_runner, :project, projects: [project, project_2], active: false, version: '2.0.0', revision: '456', description: 'Project runner', ip_address: '127.0.0.1') }
|
2022-02-15 13:14:39 -05:00
|
|
|
let_it_be(:build) { create(:ci_build, runner: instance_runner) }
|
2021-06-07 11:09:56 -04:00
|
|
|
|
|
|
|
query_path = 'runner/graphql/'
|
|
|
|
fixtures_path = 'graphql/runner/'
|
|
|
|
|
|
|
|
after(:all) do
|
|
|
|
remove_repository(project)
|
|
|
|
end
|
|
|
|
|
2022-06-10 11:09:22 -04:00
|
|
|
before do
|
|
|
|
allow(Gitlab::Ci::RunnerUpgradeCheck.instance)
|
|
|
|
.to receive(:check_runner_upgrade_status)
|
|
|
|
.and_return(:not_available)
|
|
|
|
end
|
|
|
|
|
2022-01-14 07:18:55 -05:00
|
|
|
describe do
|
2021-08-23 11:10:43 -04:00
|
|
|
before do
|
|
|
|
sign_in(admin)
|
|
|
|
enable_admin_mode!(admin)
|
|
|
|
end
|
|
|
|
|
2022-01-14 07:18:55 -05:00
|
|
|
describe GraphQL::Query, type: :request do
|
2022-03-01 10:22:06 -05:00
|
|
|
admin_runners_query = 'list/admin_runners.query.graphql'
|
2021-06-07 11:09:56 -04:00
|
|
|
|
2022-01-14 07:18:55 -05:00
|
|
|
let_it_be(:query) do
|
2022-03-01 10:22:06 -05:00
|
|
|
get_graphql_query_as_string("#{query_path}#{admin_runners_query}")
|
2022-01-14 07:18:55 -05:00
|
|
|
end
|
2021-06-07 11:09:56 -04:00
|
|
|
|
2022-03-01 10:22:06 -05:00
|
|
|
it "#{fixtures_path}#{admin_runners_query}.json" do
|
2022-01-14 07:18:55 -05:00
|
|
|
post_graphql(query, current_user: admin, variables: {})
|
2021-06-07 11:09:56 -04:00
|
|
|
|
2022-01-14 07:18:55 -05:00
|
|
|
expect_graphql_errors_to_be_empty
|
|
|
|
end
|
2021-06-07 11:09:56 -04:00
|
|
|
|
2022-03-01 10:22:06 -05:00
|
|
|
it "#{fixtures_path}#{admin_runners_query}.paginated.json" do
|
2022-01-14 07:18:55 -05:00
|
|
|
post_graphql(query, current_user: admin, variables: { first: 2 })
|
2022-01-12 13:13:20 -05:00
|
|
|
|
2022-01-14 07:18:55 -05:00
|
|
|
expect_graphql_errors_to_be_empty
|
|
|
|
end
|
2022-01-12 13:13:20 -05:00
|
|
|
end
|
|
|
|
|
2022-01-14 07:18:55 -05:00
|
|
|
describe GraphQL::Query, type: :request do
|
2022-03-01 10:22:06 -05:00
|
|
|
admin_runners_count_query = 'list/admin_runners_count.query.graphql'
|
2022-01-12 13:13:20 -05:00
|
|
|
|
2022-01-14 07:18:55 -05:00
|
|
|
let_it_be(:query) do
|
2022-03-01 10:22:06 -05:00
|
|
|
get_graphql_query_as_string("#{query_path}#{admin_runners_count_query}")
|
2022-01-14 07:18:55 -05:00
|
|
|
end
|
2022-01-12 13:13:20 -05:00
|
|
|
|
2022-03-01 10:22:06 -05:00
|
|
|
it "#{fixtures_path}#{admin_runners_count_query}.json" do
|
2022-01-14 07:18:55 -05:00
|
|
|
post_graphql(query, current_user: admin, variables: {})
|
2021-06-07 11:09:56 -04:00
|
|
|
|
2022-01-14 07:18:55 -05:00
|
|
|
expect_graphql_errors_to_be_empty
|
|
|
|
end
|
2021-08-23 11:10:43 -04:00
|
|
|
end
|
|
|
|
|
2022-01-14 07:18:55 -05:00
|
|
|
describe GraphQL::Query, type: :request do
|
2022-05-11 14:07:55 -04:00
|
|
|
runner_query = 'show/runner.query.graphql'
|
2022-01-14 07:18:55 -05:00
|
|
|
|
|
|
|
let_it_be(:query) do
|
2022-03-01 10:22:06 -05:00
|
|
|
get_graphql_query_as_string("#{query_path}#{runner_query}")
|
2022-01-14 07:18:55 -05:00
|
|
|
end
|
2021-06-07 11:09:56 -04:00
|
|
|
|
2022-03-01 10:22:06 -05:00
|
|
|
it "#{fixtures_path}#{runner_query}.json" do
|
2022-01-14 07:18:55 -05:00
|
|
|
post_graphql(query, current_user: admin, variables: {
|
|
|
|
id: instance_runner.to_global_id.to_s
|
|
|
|
})
|
2021-06-07 11:09:56 -04:00
|
|
|
|
2022-01-14 07:18:55 -05:00
|
|
|
expect_graphql_errors_to_be_empty
|
|
|
|
end
|
2022-01-27 04:14:40 -05:00
|
|
|
|
2022-03-01 10:22:06 -05:00
|
|
|
it "#{fixtures_path}#{runner_query}.with_group.json" do
|
2022-01-27 04:14:40 -05:00
|
|
|
post_graphql(query, current_user: admin, variables: {
|
|
|
|
id: group_runner.to_global_id.to_s
|
|
|
|
})
|
|
|
|
|
|
|
|
expect_graphql_errors_to_be_empty
|
|
|
|
end
|
2021-06-07 11:09:56 -04:00
|
|
|
end
|
2022-02-12 07:15:45 -05:00
|
|
|
|
|
|
|
describe GraphQL::Query, type: :request do
|
2022-05-11 14:07:55 -04:00
|
|
|
runner_projects_query = 'show/runner_projects.query.graphql'
|
2022-02-12 07:15:45 -05:00
|
|
|
|
|
|
|
let_it_be(:query) do
|
2022-03-01 10:22:06 -05:00
|
|
|
get_graphql_query_as_string("#{query_path}#{runner_projects_query}")
|
2022-02-12 07:15:45 -05:00
|
|
|
end
|
|
|
|
|
2022-03-01 10:22:06 -05:00
|
|
|
it "#{fixtures_path}#{runner_projects_query}.json" do
|
2022-02-12 07:15:45 -05:00
|
|
|
post_graphql(query, current_user: admin, variables: {
|
|
|
|
id: project_runner.to_global_id.to_s
|
|
|
|
})
|
|
|
|
|
|
|
|
expect_graphql_errors_to_be_empty
|
|
|
|
end
|
|
|
|
end
|
2022-02-15 13:14:39 -05:00
|
|
|
|
|
|
|
describe GraphQL::Query, type: :request do
|
2022-05-11 14:07:55 -04:00
|
|
|
runner_jobs_query = 'show/runner_jobs.query.graphql'
|
|
|
|
|
|
|
|
let_it_be(:query) do
|
|
|
|
get_graphql_query_as_string("#{query_path}#{runner_jobs_query}")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "#{fixtures_path}#{runner_jobs_query}.json" do
|
|
|
|
post_graphql(query, current_user: admin, variables: {
|
|
|
|
id: instance_runner.to_global_id.to_s
|
|
|
|
})
|
|
|
|
|
|
|
|
expect_graphql_errors_to_be_empty
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe GraphQL::Query, type: :request do
|
|
|
|
runner_jobs_query = 'edit/runner_form.query.graphql'
|
2022-02-15 13:14:39 -05:00
|
|
|
|
|
|
|
let_it_be(:query) do
|
2022-03-01 10:22:06 -05:00
|
|
|
get_graphql_query_as_string("#{query_path}#{runner_jobs_query}")
|
2022-02-15 13:14:39 -05:00
|
|
|
end
|
|
|
|
|
2022-03-01 10:22:06 -05:00
|
|
|
it "#{fixtures_path}#{runner_jobs_query}.json" do
|
2022-02-15 13:14:39 -05:00
|
|
|
post_graphql(query, current_user: admin, variables: {
|
|
|
|
id: instance_runner.to_global_id.to_s
|
|
|
|
})
|
|
|
|
|
|
|
|
expect_graphql_errors_to_be_empty
|
|
|
|
end
|
|
|
|
end
|
2021-06-07 11:09:56 -04:00
|
|
|
end
|
2021-08-23 11:10:43 -04:00
|
|
|
|
2022-01-14 07:18:55 -05:00
|
|
|
describe do
|
2021-08-23 11:10:43 -04:00
|
|
|
let_it_be(:group_owner) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
group.add_owner(group_owner)
|
|
|
|
end
|
|
|
|
|
2022-01-14 07:18:55 -05:00
|
|
|
describe GraphQL::Query, type: :request do
|
2022-03-01 10:22:06 -05:00
|
|
|
group_runners_query = 'list/group_runners.query.graphql'
|
2022-01-14 07:18:55 -05:00
|
|
|
|
|
|
|
let_it_be(:query) do
|
2022-03-01 10:22:06 -05:00
|
|
|
get_graphql_query_as_string("#{query_path}#{group_runners_query}")
|
2022-01-14 07:18:55 -05:00
|
|
|
end
|
|
|
|
|
2022-03-01 10:22:06 -05:00
|
|
|
it "#{fixtures_path}#{group_runners_query}.json" do
|
2022-01-14 07:18:55 -05:00
|
|
|
post_graphql(query, current_user: group_owner, variables: {
|
|
|
|
groupFullPath: group.full_path
|
|
|
|
})
|
2021-08-23 11:10:43 -04:00
|
|
|
|
2022-01-14 07:18:55 -05:00
|
|
|
expect_graphql_errors_to_be_empty
|
|
|
|
end
|
2021-08-23 11:10:43 -04:00
|
|
|
|
2022-03-01 10:22:06 -05:00
|
|
|
it "#{fixtures_path}#{group_runners_query}.paginated.json" do
|
2022-01-14 07:18:55 -05:00
|
|
|
post_graphql(query, current_user: group_owner, variables: {
|
|
|
|
groupFullPath: group.full_path,
|
|
|
|
first: 1
|
|
|
|
})
|
|
|
|
|
|
|
|
expect_graphql_errors_to_be_empty
|
|
|
|
end
|
2021-08-23 11:10:43 -04:00
|
|
|
end
|
|
|
|
|
2022-01-14 07:18:55 -05:00
|
|
|
describe GraphQL::Query, type: :request do
|
2022-03-01 10:22:06 -05:00
|
|
|
group_runners_count_query = 'list/group_runners_count.query.graphql'
|
2022-01-14 07:18:55 -05:00
|
|
|
|
|
|
|
let_it_be(:query) do
|
2022-03-01 10:22:06 -05:00
|
|
|
get_graphql_query_as_string("#{query_path}#{group_runners_count_query}")
|
2022-01-14 07:18:55 -05:00
|
|
|
end
|
|
|
|
|
2022-03-01 10:22:06 -05:00
|
|
|
it "#{fixtures_path}#{group_runners_count_query}.json" do
|
2022-01-14 07:18:55 -05:00
|
|
|
post_graphql(query, current_user: group_owner, variables: {
|
|
|
|
groupFullPath: group.full_path
|
|
|
|
})
|
2021-08-23 11:10:43 -04:00
|
|
|
|
2022-01-14 07:18:55 -05:00
|
|
|
expect_graphql_errors_to_be_empty
|
|
|
|
end
|
2021-08-23 11:10:43 -04:00
|
|
|
end
|
|
|
|
end
|
2021-06-07 11:09:56 -04:00
|
|
|
end
|