Commit 5520e3eb authored by Grzegorz Bizon's avatar Grzegorz Bizon

Reduce nesting and simplify CI/CD end-to-end tests

parent ca4db9d2
......@@ -15,36 +15,21 @@ module QA
@name || "qa-runner-#{SecureRandom.hex(4)}"
end
def perform(&block)
@block ||= block
end
def fabricate!
project.visit!
Page::Menu::Side.act { click_ci_cd_settings }
Service::Runner.perform do |runner|
Service::Runner.new(name).tap do |runner|
Page::Project::Settings::CICD.perform do |settings|
settings.expand_runners_settings do |runners|
runner.pull
runner.name = name
runner.token = runners.registration_token
runner.address = runners.coordinator_address
runner.tags = %w[qa test]
runner.register!
end
##
# TODO, refactor to support non-blocking wait time until
# GitLab Runner sucessfully registers itself.
#
sleep 5
settings.refresh
settings.expand_runners_settings do |runners|
perform&.call(runners, runner)
runner.remove!
# TODO, wait for runner to register using non-blocking method.
sleep 5
end
end
end
......
......@@ -6,11 +6,11 @@ module QA
include Scenario::Actable
include Service::Shellout
attr_accessor :token, :address, :tags, :image, :name
attr_accessor :token, :address, :tags, :image
def initialize
def initialize(name)
@image = 'gitlab/gitlab-runner:alpine'
@name = "qa-runner-#{SecureRandom.hex(4)}"
@name = name || "qa-runner-#{SecureRandom.hex(4)}"
end
def pull
......
module QA
feature 'CI/CD Pipelines', :core, :docker do
let(:executor) { "qa-runner-#{Time.now.to_i}" }
after do
Service::Runner.new(executor).remove!
end
scenario 'user registers a new specific runner' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
Factory::Resource::Runner.fabricate! do |runner|
runner.perform do |page, runner|
expect(page).to have_content(runner.name)
runner.name = executor
end
Page::Project::Settings::CICD.perform do |settings|
settings.expand_runners_settings do |page|
expect(page).to have_content(runner)
expect(page).to have_online_runner
end
end
end
scenario 'users creates a new pipeline' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
project = Factory::Resource::Project.fabricate! do |project|
project.name = 'project-with-pipelines'
project.description = 'Project with CI/CD Pipelines.'
end
Factory::Resource::Runner.fabricate! do |runner|
runner.project = project
runner.name = executor
end
Factory::Repository::Push.fabricate! do |push|
push.project = project
push.file_name = '.gitlab-ci.yml'
push.commit_message = 'Add .gitlab-ci.yml'
push.file_content = <<~EOF
echo-success-test:
script: echo 'OK'
echo-failure-test:
script:
- echo 'FAILURE'
- exit 1
echo-artifacts-test:
script: echo "CONTENTS" > my-artifacts/artifact.txt
artifacts:
paths:
- my-artifacts/
EOF
end
Page::Project::Show.act { wait_for_push }
end
end
end
......@@ -19,7 +19,6 @@ describe QA::Factory::Base do
it 'returns fabrication product' do
allow(subject).to receive(:new).and_return(factory)
allow(factory).to receive(:fabricate!).and_return('something')
result = subject.fabricate!('something')
......
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