summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-01-22 15:18:19 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-01-22 15:18:19 +0100
commit5520e3ebc329cdfec4bf61aa29dd25de563c3e43 (patch)
treeb47d338fc3c79416ec9867329e27d84fbc2bec9d
parentca4db9d25f797a07bed3750ca9d8f0833487f55c (diff)
downloadgitlab-ce-5520e3ebc329cdfec4bf61aa29dd25de563c3e43.tar.gz
Reduce nesting and simplify CI/CD end-to-end tests
-rw-r--r--qa/qa/factory/resource/runner.rb21
-rw-r--r--qa/qa/service/runner.rb6
-rw-r--r--qa/qa/specs/features/project/pipelines_spec.rb52
-rw-r--r--qa/spec/factory/base_spec.rb1
4 files changed, 56 insertions, 24 deletions
diff --git a/qa/qa/factory/resource/runner.rb b/qa/qa/factory/resource/runner.rb
index 9d11f3c572f..299a9d0716d 100644
--- a/qa/qa/factory/resource/runner.rb
+++ b/qa/qa/factory/resource/runner.rb
@@ -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
diff --git a/qa/qa/service/runner.rb b/qa/qa/service/runner.rb
index 2745bf00ded..2e313b59d28 100644
--- a/qa/qa/service/runner.rb
+++ b/qa/qa/service/runner.rb
@@ -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
diff --git a/qa/qa/specs/features/project/pipelines_spec.rb b/qa/qa/specs/features/project/pipelines_spec.rb
index 84e5a0e93cf..56a6acee6a4 100644
--- a/qa/qa/specs/features/project/pipelines_spec.rb
+++ b/qa/qa/specs/features/project/pipelines_spec.rb
@@ -1,15 +1,63 @@
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
diff --git a/qa/spec/factory/base_spec.rb b/qa/spec/factory/base_spec.rb
index 90dd58e20fd..c5663049be8 100644
--- a/qa/spec/factory/base_spec.rb
+++ b/qa/spec/factory/base_spec.rb
@@ -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')