Commit 6ffb80fe authored by Mark Lapierre's avatar Mark Lapierre

Merge branch 'fix-pipeline-on-dashboard-spec' into 'master'

Improve pipeline_status_on_operation_dashboard_spec.rb flakiness

See merge request gitlab-org/gitlab!38007
parents a7169d4b ce44964b
...@@ -12,16 +12,16 @@ module QA ...@@ -12,16 +12,16 @@ module QA
end end
end end
let(:project_with_tag) do let(:project_with_success_run) do
Resource::Project.fabricate_via_api! do |project| Resource::Project.fabricate_via_api! do |project|
project.name = 'project-with-tag' project.name = 'project-with-success-run'
project.group = group project.group = group
end end
end end
let(:project_without_tag) do let(:project_with_pending_run) do
Resource::Project.fabricate_via_api! do |project| Resource::Project.fabricate_via_api! do |project|
project.name = 'project-without-tag' project.name = 'project-with-pending-run'
project.group = group project.group = group
end end
end end
...@@ -50,6 +50,7 @@ module QA ...@@ -50,6 +50,7 @@ module QA
after do after do
runner.remove_via_api! runner.remove_via_api!
remove_projects
end end
it 'has many pipelines with appropriate statuses' do it 'has many pipelines with appropriate statuses' do
...@@ -57,25 +58,28 @@ module QA ...@@ -57,25 +58,28 @@ module QA
EE::Page::OperationsDashboard.perform do |operation| EE::Page::OperationsDashboard.perform do |operation|
{ {
'project-with-tag' => 'passed', 'project-with-success-run' => 'passed',
'project-with-failed-run' => 'failed', 'project-with-failed-run' => 'failed',
'project-without-tag' => '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.')
next break
end end
# Since `Support::Waiter.wait_until` would raise a `WaitExceededError` exception if the pipeline status pipeline_status = operation.pipeline_status(project)
# isn't the one we expect after 60 seconds, we don't need an explicit expectation. pipeline_status != 'running'
Support::Waiter.wait_until { operation.pipeline_status(project) == status }
end
end end
remove_projects expect(pipeline_status).to eq(status)
end
end
end end
private private
...@@ -89,13 +93,13 @@ module QA ...@@ -89,13 +93,13 @@ module QA
end end
def setup_projects def setup_projects
commit_ci_file(project_with_tag, ci_file_with_tag) commit_ci_file(project_with_success_run, ci_file_with_tag)
commit_ci_file(project_without_tag, ci_file_without_tag) commit_ci_file(project_with_pending_run, ci_file_without_existing_tag)
commit_ci_file(project_with_failed_run, ci_file_failed_run) commit_ci_file(project_with_failed_run, ci_file_failed_run)
end end
def add_projects_to_board def add_projects_to_board
[project_with_tag, project_without_tag, 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)
...@@ -107,7 +111,6 @@ module QA ...@@ -107,7 +111,6 @@ module QA
def remove_projects def remove_projects
EE::Page::OperationsDashboard.perform do |operation| EE::Page::OperationsDashboard.perform do |operation|
operation.remove_all_projects operation.remove_all_projects
expect(operation).not_to have_project_card
end end
end end
...@@ -122,11 +125,12 @@ module QA ...@@ -122,11 +125,12 @@ module QA
} }
end end
def ci_file_without_tag def ci_file_without_existing_tag
{ {
file_path: '.gitlab-ci.yml', file_path: '.gitlab-ci.yml',
content: <<~YAML content: <<~YAML
test-pending: test-pending:
tags: ['does-not-exist']
script: echo 'OK' script: echo 'OK'
YAML YAML
} }
......
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