2015-09-28 09:01:45 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
describe 'Runners' do
|
|
|
|
let(:user) { create(:user) }
|
2017-06-14 18:18:56 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
before do
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(user)
|
2017-06-14 18:18:56 +00:00
|
|
|
end
|
2015-09-28 09:01:45 +00:00
|
|
|
|
2018-02-21 16:09:06 +00:00
|
|
|
context 'when user opens runners page' do
|
2018-07-05 06:32:05 +00:00
|
|
|
let(:project) { create(:project) }
|
2018-02-21 16:09:06 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(user)
|
2018-02-21 16:09:06 +00:00
|
|
|
end
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'user can see a button to install runners on kubernetes clusters' do
|
2018-04-10 01:28:21 +00:00
|
|
|
visit project_runners_path(project)
|
2018-02-21 16:09:06 +00:00
|
|
|
|
|
|
|
expect(page).to have_link('Install Runner on Kubernetes', href: project_clusters_path(project))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-21 14:22:17 +00:00
|
|
|
context 'when a project has enabled shared_runners' do
|
2018-07-05 06:32:05 +00:00
|
|
|
let(:project) { create(:project) }
|
2015-09-28 09:01:45 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(user)
|
2017-08-23 12:58:45 +00:00
|
|
|
end
|
|
|
|
|
2018-05-11 10:03:40 +00:00
|
|
|
context 'when a project_type runner is activated on the project' do
|
2018-07-05 06:32:05 +00:00
|
|
|
let!(:specific_runner) { create(:ci_runner, :project, projects: [project]) }
|
2015-11-16 12:24:36 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'user sees the specific runner' do
|
2018-04-10 01:28:21 +00:00
|
|
|
visit project_runners_path(project)
|
2015-09-28 09:01:45 +00:00
|
|
|
|
2017-08-21 14:22:17 +00:00
|
|
|
within '.activated-specific-runners' do
|
|
|
|
expect(page).to have_content(specific_runner.display_name)
|
|
|
|
end
|
2015-09-28 09:01:45 +00:00
|
|
|
|
2017-08-21 14:22:17 +00:00
|
|
|
click_on specific_runner.short_sha
|
2015-11-16 12:24:36 +00:00
|
|
|
|
2017-08-21 14:22:17 +00:00
|
|
|
expect(page).to have_content(specific_runner.platform)
|
2015-09-28 09:01:45 +00:00
|
|
|
end
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'user can pause and resume the specific runner' do
|
2018-04-10 01:28:21 +00:00
|
|
|
visit project_runners_path(project)
|
2017-12-19 21:24:36 +00:00
|
|
|
|
|
|
|
within '.activated-specific-runners' do
|
|
|
|
expect(page).to have_content('Pause')
|
|
|
|
end
|
|
|
|
|
|
|
|
click_on 'Pause'
|
|
|
|
|
|
|
|
within '.activated-specific-runners' do
|
|
|
|
expect(page).to have_content('Resume')
|
|
|
|
end
|
|
|
|
|
|
|
|
click_on 'Resume'
|
|
|
|
|
|
|
|
within '.activated-specific-runners' do
|
|
|
|
expect(page).to have_content('Pause')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'user removes an activated specific runner if this is last project for that runners' do
|
2018-04-10 01:28:21 +00:00
|
|
|
visit project_runners_path(project)
|
2015-09-28 09:01:45 +00:00
|
|
|
|
2017-08-21 14:22:17 +00:00
|
|
|
within '.activated-specific-runners' do
|
|
|
|
click_on 'Remove Runner'
|
|
|
|
end
|
2015-09-28 09:01:45 +00:00
|
|
|
|
2017-08-23 12:58:45 +00:00
|
|
|
expect(page).not_to have_content(specific_runner.display_name)
|
2015-09-28 09:01:45 +00:00
|
|
|
end
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'user edits the runner to be protected' do
|
2018-04-10 01:28:21 +00:00
|
|
|
visit project_runners_path(project)
|
2017-08-25 08:46:38 +00:00
|
|
|
|
|
|
|
within '.activated-specific-runners' do
|
|
|
|
first('.edit-runner > a').click
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page.find_field('runner[access_level]')).not_to be_checked
|
|
|
|
|
|
|
|
check 'runner_access_level'
|
|
|
|
click_button 'Save changes'
|
|
|
|
|
|
|
|
expect(page).to have_content 'Protected Yes'
|
|
|
|
end
|
|
|
|
|
2017-08-21 14:22:17 +00:00
|
|
|
context 'when a runner has a tag' do
|
2018-07-05 06:32:05 +00:00
|
|
|
before do
|
2017-08-23 12:58:45 +00:00
|
|
|
specific_runner.update(tag_list: ['tag'])
|
2017-08-21 14:22:17 +00:00
|
|
|
end
|
2015-09-28 09:01:45 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'user edits runner not to run untagged jobs' do
|
2018-04-10 01:28:21 +00:00
|
|
|
visit project_runners_path(project)
|
2015-09-28 09:01:45 +00:00
|
|
|
|
2017-08-21 14:22:17 +00:00
|
|
|
within '.activated-specific-runners' do
|
|
|
|
first('.edit-runner > a').click
|
|
|
|
end
|
2015-09-28 09:01:45 +00:00
|
|
|
|
2017-08-21 14:22:17 +00:00
|
|
|
expect(page.find_field('runner[run_untagged]')).to be_checked
|
2015-09-28 09:01:45 +00:00
|
|
|
|
2017-08-21 14:22:17 +00:00
|
|
|
uncheck 'runner_run_untagged'
|
|
|
|
click_button 'Save changes'
|
2015-09-28 09:01:45 +00:00
|
|
|
|
2017-08-21 14:22:17 +00:00
|
|
|
expect(page).to have_content 'Can run untagged jobs No'
|
|
|
|
end
|
|
|
|
end
|
2016-04-15 13:51:41 +00:00
|
|
|
|
2017-08-23 12:58:45 +00:00
|
|
|
context 'when a shared runner is activated on the project' do
|
2018-07-05 06:32:05 +00:00
|
|
|
let!(:shared_runner) { create(:ci_runner, :instance) }
|
2016-04-15 13:51:41 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'user sees CI/CD setting page' do
|
2018-04-10 01:28:21 +00:00
|
|
|
visit project_runners_path(project)
|
2015-09-28 09:01:45 +00:00
|
|
|
|
2017-08-23 12:58:45 +00:00
|
|
|
expect(page.find('.available-shared-runners')).to have_content(shared_runner.display_name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-05-05 10:20:33 +00:00
|
|
|
|
2017-08-23 12:58:45 +00:00
|
|
|
context 'when a specific runner exists in another project' do
|
2018-07-05 06:32:05 +00:00
|
|
|
let(:another_project) { create(:project) }
|
|
|
|
let!(:specific_runner) { create(:ci_runner, :project, projects: [another_project]) }
|
2016-05-05 10:20:33 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
another_project.add_maintainer(user)
|
2017-08-21 14:22:17 +00:00
|
|
|
end
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'user enables and disables a specific runner' do
|
2018-04-10 01:28:21 +00:00
|
|
|
visit project_runners_path(project)
|
2016-05-05 10:20:33 +00:00
|
|
|
|
2017-08-23 12:58:45 +00:00
|
|
|
within '.available-specific-runners' do
|
|
|
|
click_on 'Enable for this project'
|
|
|
|
end
|
2017-08-21 14:22:17 +00:00
|
|
|
|
2017-08-23 12:58:45 +00:00
|
|
|
expect(page.find('.activated-specific-runners')).to have_content(specific_runner.display_name)
|
|
|
|
|
|
|
|
within '.activated-specific-runners' do
|
|
|
|
click_on 'Disable for this project'
|
2017-08-21 14:22:17 +00:00
|
|
|
end
|
2017-08-23 12:58:45 +00:00
|
|
|
|
|
|
|
expect(page.find('.available-specific-runners')).to have_content(specific_runner.display_name)
|
2017-08-21 14:22:17 +00:00
|
|
|
end
|
2016-05-05 10:20:33 +00:00
|
|
|
end
|
|
|
|
|
2017-08-21 14:22:17 +00:00
|
|
|
context 'when application settings have shared_runners_text' do
|
2018-07-05 06:32:05 +00:00
|
|
|
let(:shared_runners_text) { 'custom **shared** runners description' }
|
|
|
|
let(:shared_runners_html) { 'custom shared runners description' }
|
2017-08-21 14:22:17 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
before do
|
2017-08-21 14:22:17 +00:00
|
|
|
stub_application_setting(shared_runners_text: shared_runners_text)
|
2017-06-14 18:18:56 +00:00
|
|
|
end
|
2016-05-05 10:20:33 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'user sees shared runners description' do
|
2018-04-10 01:28:21 +00:00
|
|
|
visit project_runners_path(project)
|
2016-05-06 06:41:51 +00:00
|
|
|
|
2017-08-21 14:22:17 +00:00
|
|
|
expect(page.find('.shared-runners-description')).to have_content(shared_runners_html)
|
2016-05-06 06:41:51 +00:00
|
|
|
end
|
2016-05-05 10:20:33 +00:00
|
|
|
end
|
|
|
|
end
|
2017-08-21 14:22:17 +00:00
|
|
|
|
|
|
|
context 'when a project has disabled shared_runners' do
|
2018-07-05 06:32:05 +00:00
|
|
|
let(:project) { create(:project, shared_runners_enabled: false) }
|
2017-08-21 14:22:17 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(user)
|
2017-08-21 14:22:17 +00:00
|
|
|
end
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'user enables shared runners' do
|
2018-04-10 01:28:21 +00:00
|
|
|
visit project_runners_path(project)
|
2017-08-21 14:22:17 +00:00
|
|
|
|
|
|
|
click_on 'Enable shared Runners'
|
2017-08-23 12:58:45 +00:00
|
|
|
|
2017-08-21 14:22:17 +00:00
|
|
|
expect(page.find('.shared-runners-description')).to have_content('Disable shared Runners')
|
|
|
|
end
|
|
|
|
end
|
2017-10-04 11:59:51 +00:00
|
|
|
|
2018-04-10 04:29:06 +00:00
|
|
|
context 'group runners in project settings' do
|
2018-07-05 06:32:05 +00:00
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(user)
|
2017-10-04 11:59:51 +00:00
|
|
|
end
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
let(:group) { create :group }
|
2017-10-04 11:59:51 +00:00
|
|
|
|
2018-06-04 01:32:57 +00:00
|
|
|
context 'as project and group maintainer' do
|
2018-07-05 06:32:05 +00:00
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
group.add_maintainer(user)
|
2017-12-19 17:04:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'project with a group but no group runner' do
|
2018-07-05 06:32:05 +00:00
|
|
|
let(:project) { create :project, group: group }
|
2017-12-19 17:04:33 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'group runners are not available' do
|
2018-04-10 01:28:21 +00:00
|
|
|
visit project_runners_path(project)
|
2017-10-04 11:59:51 +00:00
|
|
|
|
2018-04-10 04:29:06 +00:00
|
|
|
expect(page).to have_content 'This group does not provide any group Runners yet'
|
2017-12-19 17:04:33 +00:00
|
|
|
|
2018-06-04 01:32:57 +00:00
|
|
|
expect(page).to have_content 'Group maintainers can register group runners in the Group CI/CD settings'
|
|
|
|
expect(page).not_to have_content 'Ask your group maintainer to setup a group Runner'
|
2017-12-19 17:04:33 +00:00
|
|
|
end
|
2017-10-04 11:59:51 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-06-04 01:32:57 +00:00
|
|
|
context 'as project maintainer' do
|
2017-12-19 17:04:33 +00:00
|
|
|
context 'project without a group' do
|
2018-07-05 06:32:05 +00:00
|
|
|
let(:project) { create :project }
|
2017-10-04 11:59:51 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'group runners are not available' do
|
2018-04-10 01:28:21 +00:00
|
|
|
visit project_runners_path(project)
|
2017-10-04 11:59:51 +00:00
|
|
|
|
2017-12-19 17:04:33 +00:00
|
|
|
expect(page).to have_content 'This project does not belong to a group and can therefore not make use of group Runners.'
|
|
|
|
end
|
2017-10-04 11:59:51 +00:00
|
|
|
end
|
|
|
|
|
2017-12-19 17:04:33 +00:00
|
|
|
context 'project with a group but no group runner' do
|
2018-07-05 06:32:05 +00:00
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:project) { create(:project, group: group) }
|
2017-10-04 11:59:51 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'group runners are not available' do
|
2018-04-10 01:28:21 +00:00
|
|
|
visit project_runners_path(project)
|
2017-12-19 17:04:33 +00:00
|
|
|
|
|
|
|
expect(page).to have_content 'This group does not provide any group Runners yet.'
|
2017-10-04 11:59:51 +00:00
|
|
|
|
2018-06-04 01:32:57 +00:00
|
|
|
expect(page).not_to have_content 'Group maintainers can register group runners in the Group CI/CD settings'
|
|
|
|
expect(page).to have_content 'Ask your group maintainer to setup a group Runner.'
|
2017-12-19 17:04:33 +00:00
|
|
|
end
|
2017-10-04 11:59:51 +00:00
|
|
|
end
|
2017-10-05 07:55:01 +00:00
|
|
|
|
2017-12-19 17:04:33 +00:00
|
|
|
context 'project with a group and a group runner' do
|
2018-07-05 06:32:05 +00:00
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:project) { create(:project, group: group) }
|
|
|
|
let!(:ci_runner) { create(:ci_runner, :group, groups: [group], description: 'group-runner') }
|
2017-12-19 17:04:33 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'group runners are available' do
|
2018-04-10 01:28:21 +00:00
|
|
|
visit project_runners_path(project)
|
2017-12-19 17:04:33 +00:00
|
|
|
|
|
|
|
expect(page).to have_content 'Available group Runners : 1'
|
|
|
|
expect(page).to have_content 'group-runner'
|
|
|
|
end
|
2017-10-05 07:55:01 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'group runners may be disabled for a project' do
|
2018-04-10 01:28:21 +00:00
|
|
|
visit project_runners_path(project)
|
2017-12-19 17:04:33 +00:00
|
|
|
|
|
|
|
click_on 'Disable group Runners'
|
2017-10-05 07:55:01 +00:00
|
|
|
|
2017-12-19 17:04:33 +00:00
|
|
|
expect(page).to have_content 'Enable group Runners'
|
|
|
|
expect(project.reload.group_runners_enabled).to be false
|
2017-10-05 07:55:01 +00:00
|
|
|
|
2017-12-19 17:04:33 +00:00
|
|
|
click_on 'Enable group Runners'
|
2017-10-05 07:55:01 +00:00
|
|
|
|
2017-12-19 17:04:33 +00:00
|
|
|
expect(page).to have_content 'Disable group Runners'
|
|
|
|
expect(project.reload.group_runners_enabled).to be true
|
|
|
|
end
|
2017-10-05 07:55:01 +00:00
|
|
|
end
|
2017-10-04 11:59:51 +00:00
|
|
|
end
|
|
|
|
end
|
2018-04-10 04:29:06 +00:00
|
|
|
|
|
|
|
context 'group runners in group settings' do
|
2018-07-05 06:32:05 +00:00
|
|
|
let(:group) { create(:group) }
|
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
group.add_maintainer(user)
|
2018-04-10 04:29:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'group with no runners' do
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'there are no runners displayed' do
|
2018-04-10 04:29:06 +00:00
|
|
|
visit group_settings_ci_cd_path(group)
|
|
|
|
|
|
|
|
expect(page).to have_content 'This group does not provide any group Runners yet'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'group with a runner' do
|
2018-05-11 10:03:40 +00:00
|
|
|
let!(:runner) { create(:ci_runner, :group, groups: [group], description: 'group-runner') }
|
2018-04-10 04:29:06 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'the runner is visible' do
|
2018-04-10 04:29:06 +00:00
|
|
|
visit group_settings_ci_cd_path(group)
|
|
|
|
|
|
|
|
expect(page).not_to have_content 'This group does not provide any group Runners yet'
|
|
|
|
expect(page).to have_content 'Available group Runners : 1'
|
|
|
|
expect(page).to have_content 'group-runner'
|
|
|
|
end
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'user can pause and resume the group runner' do
|
2018-04-10 04:29:06 +00:00
|
|
|
visit group_settings_ci_cd_path(group)
|
|
|
|
|
|
|
|
expect(page).to have_content('Pause')
|
|
|
|
expect(page).not_to have_content('Resume')
|
|
|
|
|
|
|
|
click_on 'Pause'
|
|
|
|
|
|
|
|
expect(page).not_to have_content('Pause')
|
|
|
|
expect(page).to have_content('Resume')
|
|
|
|
|
|
|
|
click_on 'Resume'
|
|
|
|
|
|
|
|
expect(page).to have_content('Pause')
|
|
|
|
expect(page).not_to have_content('Resume')
|
|
|
|
end
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'user can view runner details' do
|
2018-04-10 04:29:06 +00:00
|
|
|
visit group_settings_ci_cd_path(group)
|
|
|
|
|
|
|
|
expect(page).to have_content(runner.display_name)
|
|
|
|
|
|
|
|
click_on runner.short_sha
|
|
|
|
|
|
|
|
expect(page).to have_content(runner.platform)
|
|
|
|
end
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'user can remove a group runner' do
|
2018-04-10 04:29:06 +00:00
|
|
|
visit group_settings_ci_cd_path(group)
|
|
|
|
|
|
|
|
click_on 'Remove Runner'
|
|
|
|
|
|
|
|
expect(page).not_to have_content(runner.display_name)
|
|
|
|
end
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'user edits the runner to be protected' do
|
2018-04-10 04:29:06 +00:00
|
|
|
visit group_settings_ci_cd_path(group)
|
|
|
|
|
|
|
|
first('.edit-runner > a').click
|
|
|
|
|
|
|
|
expect(page.find_field('runner[access_level]')).not_to be_checked
|
|
|
|
|
|
|
|
check 'runner_access_level'
|
|
|
|
click_button 'Save changes'
|
|
|
|
|
|
|
|
expect(page).to have_content 'Protected Yes'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a runner has a tag' do
|
2018-07-05 06:32:05 +00:00
|
|
|
before do
|
2018-04-10 04:29:06 +00:00
|
|
|
runner.update(tag_list: ['tag'])
|
|
|
|
end
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'user edits runner not to run untagged jobs' do
|
2018-04-10 04:29:06 +00:00
|
|
|
visit group_settings_ci_cd_path(group)
|
|
|
|
|
|
|
|
first('.edit-runner > a').click
|
|
|
|
|
|
|
|
expect(page.find_field('runner[run_untagged]')).to be_checked
|
|
|
|
|
|
|
|
uncheck 'runner_run_untagged'
|
|
|
|
click_button 'Save changes'
|
|
|
|
|
|
|
|
expect(page).to have_content 'Can run untagged jobs No'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-09-28 09:01:45 +00:00
|
|
|
end
|