Wait for Runner to register in QA and DRY page objects

This commit is contained in:
Grzegorz Bizon 2018-01-22 14:12:36 +01:00
parent 50a82f64e5
commit ca4db9d25f
4 changed files with 19 additions and 10 deletions

View file

@ -35,12 +35,15 @@ module QA
runner.register!
end
sleep 5 # TODO, non-blocking waiting for Runner to register.
##
# 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)
perform&.call(runners, runner)
runner.remove!
end
end

View file

@ -12,6 +12,10 @@ module QA
#
all('code').first.text
end
def has_online_runner?
page.has_css?('.runner-status-online')
end
end
end
end

View file

@ -6,11 +6,11 @@ module QA
include Scenario::Actable
include Service::Shellout
attr_writer :token, :address, :tags, :image, :name
attr_accessor :token, :address, :tags, :image, :name
def initialize
@image = 'gitlab/gitlab-runner:alpine'
@name = "gitlab-runner-qa-#{SecureRandom.hex(4)}"
@name = "qa-runner-#{SecureRandom.hex(4)}"
end
def pull
@ -18,6 +18,10 @@ module QA
end
def register!
##
# TODO, this assumes that `test` network exists, because we know that
# gitlab-qa environment orchestration tool creates it.
#
shell <<~CMD.tr("\n", ' ')
docker run -d --rm --entrypoint=/bin/sh
--network test --name #{@name}

View file

@ -5,11 +5,9 @@ module QA
Page::Main::Login.act { sign_in_using_credentials }
Factory::Resource::Runner.fabricate! do |runner|
runner.name = 'my-qa-runner'
runner.perform do |page|
expect(page).to have_content('my-qa-runner')
expect(page).to have_css('.runner-status-online')
runner.perform do |page, runner|
expect(page).to have_content(runner.name)
expect(page).to have_online_runner
end
end
end