Sha256: 87a0da5cd144f06da0019226d2ead3363de108f4a65993f748d066d3bb272cdf

Contents?: true

Size: 1.63 KB

Versions: 21

Compression:

Stored size: 1.63 KB

Contents

require 'securerandom'

module Gitlab
  module QA
    module Component
      ##
      # This class represents GitLab QA specs image that is implemented in
      # the `qa/` directory located in GitLab CE / EE repositories.
      #
      class Specs < Scenario::Template
        attr_accessor :suite, :release, :network, :args, :volumes

        def initialize
          @docker = Docker::Engine.new
          @volumes = {}
        end

        def perform # rubocop:disable Metrics/AbcSize
          raise ArgumentError unless [suite, release].all?

          if release.dev_gitlab_org?
            Docker::Command.execute(
              [
                'login',
                '--username gitlab-qa-bot',
                %(--password "#{Runtime::Env.dev_access_token_variable}"),
                Release::DEV_REGISTRY
              ]
            )
          end

          puts "Running test suite `#{suite}` for #{release.project_name}"

          name = "#{release.project_name}-qa-#{SecureRandom.hex(4)}"

          @docker.run(release.qa_image, release.qa_tag, suite, *args) do |command|
            command << "-t --rm --net=#{network || 'bridge'}"

            Runtime::Env.variables.each do |key, value|
              command.env(key, value)
            end

            command.volume('/var/run/docker.sock', '/var/run/docker.sock')
            command.volume(File.join(Runtime::Env.host_artifacts_dir, name), File.join(Docker::Volumes::QA_CONTAINER_WORKDIR, 'tmp'))

            @volumes.to_h.each do |to, from|
              command.volume(to, from)
            end

            command.name(name)
          end
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
gitlab-qa-4.19.3 lib/gitlab/qa/component/specs.rb
gitlab-qa-4.19.2 lib/gitlab/qa/component/specs.rb
gitlab-qa-4.19.1 lib/gitlab/qa/component/specs.rb
gitlab-qa-4.19.0 lib/gitlab/qa/component/specs.rb
gitlab-qa-4.18.0 lib/gitlab/qa/component/specs.rb
gitlab-qa-4.17.0 lib/gitlab/qa/component/specs.rb
gitlab-qa-4.16.0 lib/gitlab/qa/component/specs.rb
gitlab-qa-4.15.0 lib/gitlab/qa/component/specs.rb
gitlab-qa-4.14.0 lib/gitlab/qa/component/specs.rb
gitlab-qa-4.13.0 lib/gitlab/qa/component/specs.rb
gitlab-qa-4.12.0 lib/gitlab/qa/component/specs.rb
gitlab-qa-4.11.0 lib/gitlab/qa/component/specs.rb
gitlab-qa-4.10.0 lib/gitlab/qa/component/specs.rb
gitlab-qa-4.9.0 lib/gitlab/qa/component/specs.rb
gitlab-qa-4.8.1 lib/gitlab/qa/component/specs.rb
gitlab-qa-4.8.0 lib/gitlab/qa/component/specs.rb
gitlab-qa-4.7.1 lib/gitlab/qa/component/specs.rb
gitlab-qa-4.7.0 lib/gitlab/qa/component/specs.rb
gitlab-qa-4.6.0 lib/gitlab/qa/component/specs.rb
gitlab-qa-4.5.0 lib/gitlab/qa/component/specs.rb