Commit 25cc2aeb authored by Tiffany Rea's avatar Tiffany Rea Committed by Mark Lapierre

Check for pipeline status via API

parent 475d4b9e
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
context 'Verify', :docker do RSpec.describe 'Verify', :docker do
describe 'Operations Dashboard' do describe 'Operations Dashboard' do
let(:group) { Resource::Group.fabricate_via_api! } let(:group) { Resource::Group.fabricate_via_api! }
let!(:runner) do let!(:runner) do
...@@ -63,46 +63,46 @@ module QA ...@@ -63,46 +63,46 @@ module QA
'project-with-pending-run' => 'pending', 'project-with-pending-run' => 'pending',
'project-without-ci' => nil 'project-without-ci' => nil
}.each do |project_name, status| }.each do |project_name, status|
pipeline_status = nil
Support::Waiter.wait_until(sleep_interval: 3, reload_page: operation) do
project = operation.find_project_card_by_name(project_name) project = operation.find_project_card_by_name(project_name)
if project_name == 'project-without-ci' if project_name == 'project-without-ci'
expect(project).to have_content('The branch for this project has no active pipeline configuration.') expect(project).to have_content('The branch for this project has no active pipeline configuration.')
break else
expect(operation.pipeline_status(project)).to eq(status)
end end
pipeline_status = operation.pipeline_status(project)
pipeline_status != 'running'
end
expect(pipeline_status).to eq(status)
end end
end end
end end
private private
def commit_ci_file(project, file) def commit_ci_file(project, file, status)
Resource::Repository::Commit.fabricate_via_api! do |commit| Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = project commit.project = project
commit.commit_message = 'Add .gitlab-ci.yml' commit.commit_message = 'Add .gitlab-ci.yml'
commit.add_files([file]) commit.add_files([file])
end end
wait_for_pipeline(project, status)
end end
def setup_projects def setup_projects
commit_ci_file(project_with_success_run, ci_file_with_tag) commit_ci_file(project_with_success_run, ci_file_with_tag, 'success')
commit_ci_file(project_with_pending_run, ci_file_without_existing_tag) commit_ci_file(project_with_pending_run, ci_file_without_existing_tag, 'pending')
commit_ci_file(project_with_failed_run, ci_file_failed_run) commit_ci_file(project_with_failed_run, ci_file_failed_run, 'failed')
end
def wait_for_pipeline(project, status)
Support::Waiter.wait_until do
pipelines = project.pipelines
!pipelines.empty? && pipelines.last[:status] == status
end
end end
def add_projects_to_board def add_projects_to_board
[project_with_success_run, project_with_pending_run, project_without_ci, project_with_failed_run].each do |project| [project_with_success_run, project_with_pending_run, project_without_ci, project_with_failed_run].each do |project|
EE::Page::OperationsDashboard.perform do |operation| EE::Page::OperationsDashboard.perform do |operation|
operation.add_project(project.name) operation.add_project(project.name)
expect(operation).to have_project_card expect(operation).to have_project_card
end end
end 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