2015-08-25 21:42:46 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe "Admin Runners" do
|
2017-01-21 19:11:19 -05:00
|
|
|
include StubENV
|
|
|
|
|
2015-08-25 21:42:46 -04:00
|
|
|
before do
|
2017-01-21 19:11:19 -05:00
|
|
|
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(create(:admin))
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "Runners page" do
|
2017-06-26 13:29:17 -04:00
|
|
|
let(:pipeline) { create(:ci_pipeline) }
|
|
|
|
|
|
|
|
context "when there are runners" do
|
|
|
|
before do
|
2017-12-13 19:13:44 -05:00
|
|
|
runner = FactoryBot.create(:ci_runner, contacted_at: Time.now)
|
|
|
|
FactoryBot.create(:ci_build, pipeline: pipeline, runner_id: runner.id)
|
2017-06-26 13:29:17 -04:00
|
|
|
visit admin_runners_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has all necessary texts' do
|
2018-02-21 11:09:06 -05:00
|
|
|
expect(page).to have_text "Setup a shared Runner manually"
|
2017-06-26 13:29:17 -04:00
|
|
|
expect(page).to have_text "Runners with last contact more than a minute ago: 1"
|
|
|
|
end
|
2015-08-25 21:42:46 -04:00
|
|
|
|
2017-06-26 13:29:17 -04:00
|
|
|
describe 'search' do
|
|
|
|
before do
|
2017-12-13 19:13:44 -05:00
|
|
|
FactoryBot.create :ci_runner, description: 'runner-foo'
|
|
|
|
FactoryBot.create :ci_runner, description: 'runner-bar'
|
2017-06-26 13:29:17 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows correct runner when description matches' do
|
|
|
|
search_form = find('#runners-search')
|
|
|
|
search_form.fill_in 'search', with: 'runner-foo'
|
|
|
|
search_form.click_button 'Search'
|
|
|
|
|
|
|
|
expect(page).to have_content("runner-foo")
|
|
|
|
expect(page).not_to have_content("runner-bar")
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows no runner when description does not match' do
|
|
|
|
search_form = find('#runners-search')
|
|
|
|
search_form.fill_in 'search', with: 'runner-baz'
|
|
|
|
search_form.click_button 'Search'
|
|
|
|
|
|
|
|
expect(page).to have_text 'No runners found'
|
|
|
|
end
|
|
|
|
end
|
2016-10-19 08:25:37 -04:00
|
|
|
end
|
2015-08-25 21:42:46 -04:00
|
|
|
|
2017-06-26 13:29:17 -04:00
|
|
|
context "when there are no runners" do
|
2015-08-25 21:42:46 -04:00
|
|
|
before do
|
2017-06-26 13:29:17 -04:00
|
|
|
visit admin_runners_path
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
|
2017-06-26 13:29:17 -04:00
|
|
|
it 'has all necessary texts including no runner message' do
|
2018-02-21 11:09:06 -05:00
|
|
|
expect(page).to have_text "Setup a shared Runner manually"
|
2017-06-26 13:29:17 -04:00
|
|
|
expect(page).to have_text "Runners with last contact more than a minute ago: 0"
|
|
|
|
expect(page).to have_text 'No runners found'
|
2016-10-19 08:25:37 -04:00
|
|
|
end
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
2017-10-05 08:25:31 -04:00
|
|
|
|
|
|
|
context 'group runner' do
|
2018-05-01 05:44:35 -04:00
|
|
|
let(:group) { create(:group) }
|
2018-05-11 06:03:40 -04:00
|
|
|
let!(:runner) { create(:ci_runner, :group, groups: [group]) }
|
2017-10-05 08:25:31 -04:00
|
|
|
|
2018-05-01 05:44:35 -04:00
|
|
|
it 'shows the label and does not show the project count' do
|
2017-10-05 08:25:31 -04:00
|
|
|
visit admin_runners_path
|
|
|
|
|
|
|
|
within "#runner_#{runner.id}" do
|
2018-05-08 14:05:56 -04:00
|
|
|
expect(page).to have_selector '.badge', text: 'group'
|
2017-10-05 08:25:31 -04:00
|
|
|
expect(page).to have_text 'n/a'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'shared runner' do
|
|
|
|
it 'shows the label and does not show the project count' do
|
2018-05-23 07:23:49 -04:00
|
|
|
runner = create :ci_runner, :instance
|
2017-10-05 08:25:31 -04:00
|
|
|
|
|
|
|
visit admin_runners_path
|
|
|
|
|
|
|
|
within "#runner_#{runner.id}" do
|
2018-05-08 14:05:56 -04:00
|
|
|
expect(page).to have_selector '.badge', text: 'shared'
|
2017-10-05 08:25:31 -04:00
|
|
|
expect(page).to have_text 'n/a'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'specific runner' do
|
|
|
|
it 'shows the label and the project count' do
|
|
|
|
project = create :project
|
2018-05-23 07:23:49 -04:00
|
|
|
runner = create :ci_runner, :project, projects: [project]
|
2017-10-05 08:25:31 -04:00
|
|
|
|
|
|
|
visit admin_runners_path
|
|
|
|
|
|
|
|
within "#runner_#{runner.id}" do
|
2018-05-08 14:05:56 -04:00
|
|
|
expect(page).to have_selector '.badge', text: 'specific'
|
2017-10-05 08:25:31 -04:00
|
|
|
expect(page).to have_text '1'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "Runner show page" do
|
2017-12-13 19:13:44 -05:00
|
|
|
let(:runner) { FactoryBot.create :ci_runner }
|
2015-08-25 21:42:46 -04:00
|
|
|
|
|
|
|
before do
|
2017-12-13 19:13:44 -05:00
|
|
|
@project1 = FactoryBot.create(:project)
|
|
|
|
@project2 = FactoryBot.create(:project)
|
2015-12-04 06:55:23 -05:00
|
|
|
visit admin_runner_path(runner)
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'runner info' do
|
2015-09-10 10:55:09 -04:00
|
|
|
it { expect(find_field('runner_token').value).to eq runner.token }
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'projects' do
|
2016-10-19 08:25:37 -04:00
|
|
|
it 'contains project names' do
|
2018-03-05 09:15:26 -05:00
|
|
|
expect(page).to have_content(@project1.full_name)
|
|
|
|
expect(page).to have_content(@project2.full_name)
|
2016-10-19 08:25:37 -04:00
|
|
|
end
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'search' do
|
|
|
|
before do
|
2015-09-15 16:13:01 -04:00
|
|
|
search_form = find('#runner-projects-search')
|
2015-12-04 06:55:23 -05:00
|
|
|
search_form.fill_in 'search', with: @project1.name
|
2015-09-15 16:13:01 -04:00
|
|
|
search_form.click_button 'Search'
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
|
2016-10-19 08:25:37 -04:00
|
|
|
it 'contains name of correct project' do
|
2018-03-05 09:15:26 -05:00
|
|
|
expect(page).to have_content(@project1.full_name)
|
|
|
|
expect(page).not_to have_content(@project2.full_name)
|
2016-10-19 08:25:37 -04:00
|
|
|
end
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
2016-06-17 10:17:20 -04:00
|
|
|
|
|
|
|
describe 'enable/create' do
|
2016-06-28 06:33:25 -04:00
|
|
|
shared_examples 'assignable runner' do
|
2016-06-28 01:46:47 -04:00
|
|
|
it 'enables a runner for a project' do
|
|
|
|
within '.unassigned-projects' do
|
|
|
|
click_on 'Enable'
|
|
|
|
end
|
|
|
|
|
|
|
|
assigned_project = page.find('.assigned-projects')
|
|
|
|
|
|
|
|
expect(assigned_project).to have_content(@project2.path)
|
|
|
|
end
|
2016-06-17 10:17:20 -04:00
|
|
|
end
|
|
|
|
|
2016-06-28 01:46:47 -04:00
|
|
|
context 'with specific runner' do
|
2018-05-23 07:23:49 -04:00
|
|
|
let(:runner) { create(:ci_runner, :project, projects: [@project1]) }
|
|
|
|
|
2016-06-28 01:46:47 -04:00
|
|
|
before do
|
|
|
|
visit admin_runner_path(runner)
|
2016-06-17 10:17:20 -04:00
|
|
|
end
|
|
|
|
|
2016-06-28 06:33:25 -04:00
|
|
|
it_behaves_like 'assignable runner'
|
2016-06-28 01:46:47 -04:00
|
|
|
end
|
|
|
|
|
2016-06-28 08:15:50 -04:00
|
|
|
context 'with locked runner' do
|
2018-05-23 07:23:49 -04:00
|
|
|
let(:runner) { create(:ci_runner, :project, projects: [@project1], locked: true) }
|
|
|
|
|
2016-06-28 08:15:50 -04:00
|
|
|
before do
|
|
|
|
visit admin_runner_path(runner)
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'assignable runner'
|
|
|
|
end
|
|
|
|
|
2016-06-28 01:46:47 -04:00
|
|
|
context 'with shared runner' do
|
2018-05-23 07:23:49 -04:00
|
|
|
let(:runner) { create(:ci_runner, :instance) }
|
|
|
|
|
2016-06-28 01:46:47 -04:00
|
|
|
before do
|
|
|
|
@project1.destroy
|
|
|
|
visit admin_runner_path(runner)
|
|
|
|
end
|
2016-06-17 10:17:20 -04:00
|
|
|
|
2016-06-28 06:33:25 -04:00
|
|
|
it_behaves_like 'assignable runner'
|
2016-06-17 10:17:20 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'disable/destroy' do
|
2018-05-23 07:23:49 -04:00
|
|
|
let(:runner) { create(:ci_runner, :project, projects: [@project1]) }
|
|
|
|
|
2016-06-17 10:17:20 -04:00
|
|
|
before do
|
|
|
|
visit admin_runner_path(runner)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'enables specific runner for project' do
|
|
|
|
within '.assigned-projects' do
|
|
|
|
click_on 'Disable'
|
|
|
|
end
|
|
|
|
|
|
|
|
new_runner_project = page.find('.unassigned-projects')
|
|
|
|
|
|
|
|
expect(new_runner_project).to have_content(@project1.path)
|
|
|
|
end
|
|
|
|
end
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
2015-12-11 05:14:55 -05:00
|
|
|
|
|
|
|
describe 'runners registration token' do
|
2018-02-02 13:39:55 -05:00
|
|
|
let!(:token) { Gitlab::CurrentSettings.runners_registration_token }
|
2017-06-14 14:18:56 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
visit admin_runners_path
|
|
|
|
end
|
2015-12-11 05:14:55 -05:00
|
|
|
|
|
|
|
it 'has a registration token' do
|
2017-07-20 02:14:22 -04:00
|
|
|
expect(page.find('#registration_token')).to have_content(token)
|
2015-12-11 05:14:55 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'reload registration token' do
|
2017-07-20 04:42:45 -04:00
|
|
|
let(:page_token) { find('#registration_token').text }
|
2015-12-11 05:14:55 -05:00
|
|
|
|
|
|
|
before do
|
|
|
|
click_button 'Reset runners registration token'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'changes registration token' do
|
2016-05-23 19:37:59 -04:00
|
|
|
expect(page_token).not_to eq token
|
2015-12-11 05:14:55 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|