diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-01-22 14:03:03 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-01-22 14:03:03 +0100 |
commit | 50a82f64e53d396ca91f52c4d25af60beb52a424 (patch) | |
tree | d56e2ea17f7d9cfbd2a07c220f8ec900a411853a /qa/qa/service | |
parent | d0b08f1c50b0b4106c0ae5f398912aab596a447a (diff) | |
download | gitlab-ce-50a82f64e53d396ca91f52c4d25af60beb52a424.tar.gz |
Add end-to-end test for registering GitLab Runner
Diffstat (limited to 'qa/qa/service')
-rw-r--r-- | qa/qa/service/runner.rb | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/qa/qa/service/runner.rb b/qa/qa/service/runner.rb index a6a60f53787..a9906b8627a 100644 --- a/qa/qa/service/runner.rb +++ b/qa/qa/service/runner.rb @@ -1,27 +1,38 @@ +require 'securerandom' + module QA module Service class Runner include Scenario::Actable include Service::Shellout - def initialize(image) - @image = image + attr_writer :token, :address, :tags, :image, :name + + def initialize + @image = 'gitlab/gitlab-runner:alpine' + @name = "gitlab-runner-qa-#{SecureRandom.hex(4)}" end def pull shell "docker pull #{@image}" end - def register(token) - raise NotImplementedError - end - - def run - raise NotImplementedError + def register! + shell <<~CMD.tr("\n", ' ') + docker run -d --rm --entrypoint=/bin/sh + --network test --name #{@name} + -e CI_SERVER_URL=#{@address} + -e REGISTER_NON_INTERACTIVE=true + -e REGISTRATION_TOKEN=#{@token} + -e RUNNER_EXECUTOR=shell + -e RUNNER_TAG_LIST=#{@tags.to_a.join(',')} + -e RUNNER_NAME=#{@name} + #{@image} -c 'gitlab-runner register && gitlab-runner run' + CMD end - def remove - raise NotImplementedError + def remove! + shell "docker rm -f #{@name}" end end end |