Commit 4a40c6b1 authored by Dan Davison's avatar Dan Davison Committed by Walmyr Lima e Silva Filho

Promote pipeline spec to smoke test

Refactor test setup and fabrication

Add name to fabricated project

Remove :orchestrated and keep :docker

Add wait parameter to Pipeline show page

Remove superfluous expectations
Replace hard-sleep with wait: 30 within be_running
Register runner with executor name

Runner tags needs an array
parent b25b6a8f
......@@ -30,9 +30,9 @@ module QA::Page
element :pipeline_badges
end
def running?
def running?(wait: 0)
within('.ci-header-container') do
page.has_content?('running')
page.has_content?('running', wait: wait)
end
end
......
# frozen_string_literal: true
module QA
context 'Verify', :orchestrated, :docker do
context 'Verify', :docker do
describe 'Pipeline creation and processing' do
let(:executor) { "qa-runner-#{Time.now.to_i}" }
after do
Service::DockerRun::GitlabRunner.new(executor).remove!
end
it 'users creates a pipeline which gets processed' do
Flow::Login.sign_in
project = Resource::Project.fabricate! do |project|
project.name = 'project-with-pipelines'
project.description = 'Project with CI/CD Pipelines.'
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'project-with-pipeline'
end
end
before do
Resource::Runner.fabricate! do |runner|
runner.project = project
runner.name = executor
runner.tags = %w[qa test]
runner.tags = [executor]
end
end
Resource::Repository::ProjectPush.fabricate! do |push|
push.project = project
push.file_name = '.gitlab-ci.yml'
push.commit_message = 'Add .gitlab-ci.yml'
push.file_content = <<~EOF
test-success:
tags:
- qa
- test
script: echo 'OK'
test-failure:
tags:
- qa
- test
script:
- echo 'FAILURE'
- exit 1
test-tags:
tags:
- qa
- docker
script: echo 'NOOP'
after do
Service::DockerRun::GitlabRunner.new(executor).remove!
end
test-artifacts:
tags:
- qa
- test
script: mkdir my-artifacts; echo "CONTENTS" > my-artifacts/artifact.txt
artifacts:
paths:
- my-artifacts/
EOF
end.project.visit!
it 'users creates a pipeline which gets processed', :smoke do
Flow::Login.sign_in
expect(page).to have_content('Add .gitlab-ci.yml')
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = project
commit.commit_message = 'Add .gitlab-ci.yml'
commit.add_files(
[
{
file_path: '.gitlab-ci.yml',
content: <<~YAML
test-success:
tags:
- #{executor}
script: echo 'OK'
Page::Project::Menu.perform(&:click_ci_cd_pipelines)
test-failure:
tags:
- #{executor}
script:
- echo 'FAILURE'
- exit 1
expect(page).to have_content('All 1')
expect(page).to have_content('Add .gitlab-ci.yml')
test-tags:
tags:
- invalid
script: echo 'NOOP'
puts 'Waiting for the runner to process the pipeline'
sleep 15 # Runner should process all jobs within 15 seconds.
test-artifacts:
tags:
- #{executor}
script: mkdir my-artifacts; echo "CONTENTS" > my-artifacts/artifact.txt
artifacts:
paths:
- my-artifacts/
YAML
}
]
)
end.project.visit!
Page::Project::Menu.perform(&:click_ci_cd_pipelines)
Page::Project::Pipeline::Index.perform(&:click_on_latest_pipeline)
Page::Project::Pipeline::Show.perform do |pipeline|
expect(pipeline).to be_running
expect(pipeline).to be_running(wait: 30)
expect(pipeline).to have_build('test-success', status: :success)
expect(pipeline).to have_build('test-failure', status: :failed)
expect(pipeline).to have_build('test-tags', status: :pending)
......
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