diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-14 03:06:12 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-14 03:06:12 +0000 |
commit | 934c2d5cf060d5f9881b18a2ddfbc32acea98995 (patch) | |
tree | 0171c75a2bcab42bd94dd105383750779dcf0e86 /qa | |
parent | 7ea2b8726c5c587e32d53efd5d9c84cd72ba4356 (diff) | |
download | gitlab-ce-934c2d5cf060d5f9881b18a2ddfbc32acea98995.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa.rb | 8 | ||||
-rw-r--r-- | qa/qa/resource/runner.rb | 4 | ||||
-rw-r--r-- | qa/qa/service/docker_run/base.rb | 43 | ||||
-rw-r--r-- | qa/qa/service/docker_run/gitlab_runner.rb | 58 | ||||
-rw-r--r-- | qa/qa/service/docker_run/ldap.rb | 41 | ||||
-rw-r--r-- | qa/qa/service/ldap.rb | 64 | ||||
-rw-r--r-- | qa/qa/service/runner.rb | 73 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/4_verify/pipeline/create_and_process_pipeline_spec.rb | 2 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/4_verify/runner/register_runner_spec.rb | 2 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/6_release/deploy_key/clone_using_deploy_key_spec.rb | 2 |
10 files changed, 153 insertions, 144 deletions
@@ -396,8 +396,6 @@ module QA autoload :Shellout, 'qa/service/shellout' autoload :KubernetesCluster, 'qa/service/kubernetes_cluster' autoload :Omnibus, 'qa/service/omnibus' - autoload :Runner, 'qa/service/runner' - autoload :LDAP, 'qa/service/ldap' module ClusterProvider autoload :Base, 'qa/service/cluster_provider/base' @@ -405,6 +403,12 @@ module QA autoload :Minikube, 'qa/service/cluster_provider/minikube' autoload :K3d, 'qa/service/cluster_provider/k3d' end + + module DockerRun + autoload :Base, 'qa/service/docker_run/base' + autoload :LDAP, 'qa/service/docker_run/ldap' + autoload :GitlabRunner, 'qa/service/docker_run/gitlab_runner' + end end ## diff --git a/qa/qa/resource/runner.rb b/qa/qa/resource/runner.rb index 3f0eed7458a..1be2429bc04 100644 --- a/qa/qa/resource/runner.rb +++ b/qa/qa/resource/runner.rb @@ -29,7 +29,7 @@ module QA end def fabricate_via_api! - Service::Runner.new(name).tap do |runner| + Service::DockerRun::GitlabRunner.new(name).tap do |runner| runner.pull runner.token = @token ||= project.runners_token runner.address = Runtime::Scenario.gitlab_address @@ -46,7 +46,7 @@ module QA super - Service::Runner.new(name).remove! + Service::DockerRun::GitlabRunner.new(name).remove! end def api_delete_path diff --git a/qa/qa/service/docker_run/base.rb b/qa/qa/service/docker_run/base.rb new file mode 100644 index 00000000000..3f42c09ad2c --- /dev/null +++ b/qa/qa/service/docker_run/base.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module QA + module Service + module DockerRun + class Base + include Service::Shellout + + def initialize + @network = Runtime::Scenario.attributes[:network] || 'test' + end + + def network + shell "docker network inspect #{@network}" + rescue CommandError + 'bridge' + else + @network + end + + def pull + shell "docker pull #{@image}" + end + + def host_name + "#{@name}.#{network}" + end + + def register! + raise NotImplementedError + end + + def remove! + shell "docker rm -f #{@name}" if running? + end + + def running? + `docker ps -f name=#{@name}`.include?(@name) + end + end + end + end +end diff --git a/qa/qa/service/docker_run/gitlab_runner.rb b/qa/qa/service/docker_run/gitlab_runner.rb new file mode 100644 index 00000000000..6856a5a8399 --- /dev/null +++ b/qa/qa/service/docker_run/gitlab_runner.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +require 'securerandom' + +module QA + module Service + module DockerRun + class GitlabRunner < Base + attr_accessor :token, :address, :tags, :image, :run_untagged + attr_writer :config + + def initialize(name) + @image = 'gitlab/gitlab-runner:alpine' + @name = name || "qa-runner-#{SecureRandom.hex(4)}" + @tags = %w[qa test] + @run_untagged = false + + super() + end + + def config + @config ||= <<~END + concurrent = 1 + check_interval = 0 + + [session_server] + session_timeout = 1800 + END + end + + def register! + shell <<~CMD.tr("\n", ' ') + docker run -d --rm --entrypoint=/bin/sh + --network #{network} --name #{@name} + -p 8093:8093 + -e CI_SERVER_URL=#{@address} + -e REGISTER_NON_INTERACTIVE=true + -e REGISTRATION_TOKEN=#{@token} + -e RUNNER_EXECUTOR=shell + -e RUNNER_TAG_LIST=#{@tags.join(',')} + -e RUNNER_NAME=#{@name} + #{@image} -c "#{register_command}" + CMD + end + + private + + def register_command + <<~CMD + printf '#{config.chomp.gsub(/\n/, "\\n").gsub('"', '\"')}' > /etc/gitlab-runner/config.toml && + gitlab-runner register --run-untagged=#{@run_untagged} && + gitlab-runner run + CMD + end + end + end + end +end diff --git a/qa/qa/service/docker_run/ldap.rb b/qa/qa/service/docker_run/ldap.rb new file mode 100644 index 00000000000..c33d75ff640 --- /dev/null +++ b/qa/qa/service/docker_run/ldap.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +module QA + module Service + module DockerRun + class LDAP < Base + def initialize(volume) + @image = 'osixia/openldap:latest' + @name = 'ldap-server' + @volume = volume + + super() + end + + def register! + shell <<~CMD.tr("\n", ' ') + docker run -d --rm + --network #{network} + --hostname #{host_name} + --name #{@name} + -p 389:389 + --volume #{volume_or_fixture(@volume)}:/container/service/slapd/assets/config/bootstrap/ldif/custom + #{@image} --copy-service + CMD + end + + def volume_or_fixture(volume_name) + if volume_exists?(volume_name) + volume_name + else + File.expand_path("../fixtures/ldap/#{volume_name}", __dir__) + end + end + + def volume_exists?(volume_name) + `docker volume ls -q -f name=#{volume_name}`.include?(volume_name) + end + end + end + end +end diff --git a/qa/qa/service/ldap.rb b/qa/qa/service/ldap.rb deleted file mode 100644 index 7a02cebeb8f..00000000000 --- a/qa/qa/service/ldap.rb +++ /dev/null @@ -1,64 +0,0 @@ -# frozen_string_literal: true - -module QA - module Service - class LDAP - include Service::Shellout - - def initialize(volume) - @image = 'osixia/openldap:latest' - @name = 'ldap-server' - @network = Runtime::Scenario.attributes[:network] || 'test' - @volume = volume - end - - def network - shell "docker network inspect #{@network}" - rescue CommandError - 'bridge' - else - @network - end - - def pull - shell "docker pull #{@image}" - end - - def host_name - "#{@name}.#{network}" - end - - def register! - shell <<~CMD.tr("\n", ' ') - docker run -d --rm - --network #{network} - --hostname #{host_name} - --name #{@name} - -p 389:389 - --volume #{volume_or_fixture(@volume)}:/container/service/slapd/assets/config/bootstrap/ldif/custom - #{@image} --copy-service - CMD - end - - def remove! - shell "docker rm -f #{@name}" if running? - end - - def running? - `docker ps -f name=#{@name}`.include?(@name) - end - - def volume_or_fixture(volume_name) - if volume_exists?(volume_name) - volume_name - else - File.expand_path("../fixtures/ldap/#{volume_name}", __dir__) - end - end - - def volume_exists?(volume_name) - `docker volume ls -q -f name=#{volume_name}`.include?(volume_name) - end - end - end -end diff --git a/qa/qa/service/runner.rb b/qa/qa/service/runner.rb deleted file mode 100644 index 6fc5984b12a..00000000000 --- a/qa/qa/service/runner.rb +++ /dev/null @@ -1,73 +0,0 @@ -# frozen_string_literal: true - -require 'securerandom' - -module QA - module Service - class Runner - include Service::Shellout - - attr_accessor :token, :address, :tags, :image, :run_untagged - attr_writer :config - - def initialize(name) - @image = 'gitlab/gitlab-runner:alpine' - @name = name || "qa-runner-#{SecureRandom.hex(4)}" - @network = Runtime::Scenario.attributes[:network] || 'test' - @tags = %w[qa test] - @run_untagged = false - end - - def config - @config ||= <<~END - concurrent = 1 - check_interval = 0 - - [session_server] - session_timeout = 1800 - END - end - - def network - shell "docker network inspect #{@network}" - rescue CommandError - 'bridge' - else - @network - end - - def pull - shell "docker pull #{@image}" - end - - def register! - shell <<~CMD.tr("\n", ' ') - docker run -d --rm --entrypoint=/bin/sh - --network #{network} --name #{@name} - -p 8093:8093 - -e CI_SERVER_URL=#{@address} - -e REGISTER_NON_INTERACTIVE=true - -e REGISTRATION_TOKEN=#{@token} - -e RUNNER_EXECUTOR=shell - -e RUNNER_TAG_LIST=#{@tags.join(',')} - -e RUNNER_NAME=#{@name} - #{@image} -c "#{register_command}" - CMD - end - - def remove! - shell "docker rm -f #{@name}" - end - - private - - def register_command - <<~CMD - printf '#{config.chomp.gsub(/\n/, "\\n").gsub('"', '\"')}' > /etc/gitlab-runner/config.toml && - gitlab-runner register --run-untagged=#{@run_untagged} && - gitlab-runner run - CMD - end - end - end -end diff --git a/qa/qa/specs/features/browser_ui/4_verify/pipeline/create_and_process_pipeline_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/pipeline/create_and_process_pipeline_spec.rb index 2952a54ff5d..5d91b70082c 100644 --- a/qa/qa/specs/features/browser_ui/4_verify/pipeline/create_and_process_pipeline_spec.rb +++ b/qa/qa/specs/features/browser_ui/4_verify/pipeline/create_and_process_pipeline_spec.rb @@ -6,7 +6,7 @@ module QA let(:executor) { "qa-runner-#{Time.now.to_i}" } after do - Service::Runner.new(executor).remove! + Service::DockerRun::GitlabRunner.new(executor).remove! end it 'users creates a pipeline which gets processed' do diff --git a/qa/qa/specs/features/browser_ui/4_verify/runner/register_runner_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/runner/register_runner_spec.rb index 900ddcb7f59..58f129b846d 100644 --- a/qa/qa/specs/features/browser_ui/4_verify/runner/register_runner_spec.rb +++ b/qa/qa/specs/features/browser_ui/4_verify/runner/register_runner_spec.rb @@ -6,7 +6,7 @@ module QA let(:executor) { "qa-runner-#{Time.now.to_i}" } after do - Service::Runner.new(executor).remove! + Service::DockerRun::GitlabRunner.new(executor).remove! end it 'user registers a new specific runner' do diff --git a/qa/qa/specs/features/browser_ui/6_release/deploy_key/clone_using_deploy_key_spec.rb b/qa/qa/specs/features/browser_ui/6_release/deploy_key/clone_using_deploy_key_spec.rb index 141166f6971..e45ce438fc2 100644 --- a/qa/qa/specs/features/browser_ui/6_release/deploy_key/clone_using_deploy_key_spec.rb +++ b/qa/qa/specs/features/browser_ui/6_release/deploy_key/clone_using_deploy_key_spec.rb @@ -26,7 +26,7 @@ module QA end after do - Service::Runner.new(@runner_name).remove! + Service::DockerRun::GitlabRunner.new(@runner_name).remove! end keys = [ |