debian-mirror-gitlab/spec/features/admin/admin_runners_spec.rb

182 lines
4.8 KiB
Ruby
Raw Normal View History

2015-09-25 12:07:36 +05:30
require 'spec_helper'
describe "Admin Runners" do
2017-08-17 22:00:37 +05:30
include StubENV
2015-09-25 12:07:36 +05:30
before do
2017-08-17 22:00:37 +05:30
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
2017-09-10 17:25:29 +05:30
sign_in(create(:admin))
2015-09-25 12:07:36 +05:30
end
describe "Runners page" do
2017-09-10 17:25:29 +05:30
let(:pipeline) { create(:ci_pipeline) }
context "when there are runners" do
before do
2018-03-17 18:26:18 +05:30
runner = FactoryBot.create(:ci_runner, contacted_at: Time.now)
FactoryBot.create(:ci_build, pipeline: pipeline, runner_id: runner.id)
2017-09-10 17:25:29 +05:30
visit admin_runners_path
end
it 'has all necessary texts' do
2018-03-27 19:54:05 +05:30
expect(page).to have_text "Setup a shared Runner manually"
2017-09-10 17:25:29 +05:30
expect(page).to have_text "Runners with last contact more than a minute ago: 1"
end
describe 'search' do
before do
2018-03-17 18:26:18 +05:30
FactoryBot.create :ci_runner, description: 'runner-foo'
FactoryBot.create :ci_runner, description: 'runner-bar'
2017-09-10 17:25:29 +05:30
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'
2015-09-25 12:07:36 +05:30
2017-09-10 17:25:29 +05:30
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
2017-08-17 22:00:37 +05:30
end
2015-09-25 12:07:36 +05:30
2017-09-10 17:25:29 +05:30
context "when there are no runners" do
2015-09-25 12:07:36 +05:30
before do
2017-09-10 17:25:29 +05:30
visit admin_runners_path
2015-09-25 12:07:36 +05:30
end
2017-09-10 17:25:29 +05:30
it 'has all necessary texts including no runner message' do
2018-03-27 19:54:05 +05:30
expect(page).to have_text "Setup a shared Runner manually"
2017-09-10 17:25:29 +05:30
expect(page).to have_text "Runners with last contact more than a minute ago: 0"
expect(page).to have_text 'No runners found'
2017-08-17 22:00:37 +05:30
end
2015-09-25 12:07:36 +05:30
end
end
describe "Runner show page" do
2018-03-17 18:26:18 +05:30
let(:runner) { FactoryBot.create :ci_runner }
2015-09-25 12:07:36 +05:30
before do
2018-03-17 18:26:18 +05:30
@project1 = FactoryBot.create(:project)
@project2 = FactoryBot.create(:project)
2015-12-23 02:04:40 +05:30
visit admin_runner_path(runner)
2015-09-25 12:07:36 +05:30
end
describe 'runner info' do
it { expect(find_field('runner_token').value).to eq runner.token }
end
describe 'projects' do
2017-08-17 22:00:37 +05:30
it 'contains project names' do
2018-03-27 19:54:05 +05:30
expect(page).to have_content(@project1.full_name)
expect(page).to have_content(@project2.full_name)
2017-08-17 22:00:37 +05:30
end
2015-09-25 12:07:36 +05:30
end
describe 'search' do
before do
search_form = find('#runner-projects-search')
2015-12-23 02:04:40 +05:30
search_form.fill_in 'search', with: @project1.name
2015-09-25 12:07:36 +05:30
search_form.click_button 'Search'
end
2017-08-17 22:00:37 +05:30
it 'contains name of correct project' do
2018-03-27 19:54:05 +05:30
expect(page).to have_content(@project1.full_name)
expect(page).not_to have_content(@project2.full_name)
2017-08-17 22:00:37 +05:30
end
2015-09-25 12:07:36 +05:30
end
2016-06-22 15:30:34 +05:30
describe 'enable/create' do
2016-08-24 12:49:21 +05:30
shared_examples 'assignable runner' do
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-22 15:30:34 +05:30
end
2016-08-24 12:49:21 +05:30
context 'with specific runner' do
before do
@project1.runners << runner
visit admin_runner_path(runner)
2016-06-22 15:30:34 +05:30
end
2016-08-24 12:49:21 +05:30
it_behaves_like 'assignable runner'
end
context 'with locked runner' do
before do
runner.update(locked: true)
@project1.runners << runner
visit admin_runner_path(runner)
end
it_behaves_like 'assignable runner'
end
context 'with shared runner' do
before do
@project1.destroy
runner.update(is_shared: true)
visit admin_runner_path(runner)
end
2016-06-22 15:30:34 +05:30
2016-08-24 12:49:21 +05:30
it_behaves_like 'assignable runner'
2016-06-22 15:30:34 +05:30
end
end
describe 'disable/destroy' do
before do
@project1.runners << runner
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-09-25 12:07:36 +05:30
end
2015-12-23 02:04:40 +05:30
describe 'runners registration token' do
2018-03-17 18:26:18 +05:30
let!(:token) { Gitlab::CurrentSettings.runners_registration_token }
2017-09-10 17:25:29 +05:30
before do
visit admin_runners_path
end
2015-12-23 02:04:40 +05:30
it 'has a registration token' do
2017-09-10 17:25:29 +05:30
expect(page.find('#registration_token')).to have_content(token)
2015-12-23 02:04:40 +05:30
end
describe 'reload registration token' do
2017-09-10 17:25:29 +05:30
let(:page_token) { find('#registration_token').text }
2015-12-23 02:04:40 +05:30
before do
click_button 'Reset runners registration token'
end
it 'changes registration token' do
expect(page_token).not_to eq token
2015-12-23 02:04:40 +05:30
end
end
end
2015-09-25 12:07:36 +05:30
end