Class: Gitlab::QA::Component::Specs
- Inherits:
-
Scenario::Template
- Object
- Scenario::Template
- Gitlab::QA::Component::Specs
- Defined in:
- lib/gitlab/qa/component/specs.rb
Overview
This class represents GitLab QA specs image that is implemented in the ‘qa/` directory located in GitLab CE / EE repositories.
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#env ⇒ Object
Returns the value of attribute env.
-
#network ⇒ Object
Returns the value of attribute network.
-
#release ⇒ Object
Returns the value of attribute release.
-
#runner_network ⇒ Object
Returns the value of attribute runner_network.
-
#suite ⇒ Object
Returns the value of attribute suite.
-
#volumes ⇒ Object
Returns the value of attribute volumes.
Instance Method Summary collapse
-
#initialize ⇒ Specs
constructor
A new instance of Specs.
- #perform ⇒ Object
Methods inherited from Scenario::Template
Constructor Details
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
11 12 13 |
# File 'lib/gitlab/qa/component/specs.rb', line 11 def args @args end |
#env ⇒ Object
Returns the value of attribute env.
11 12 13 |
# File 'lib/gitlab/qa/component/specs.rb', line 11 def env @env end |
#network ⇒ Object
Returns the value of attribute network.
11 12 13 |
# File 'lib/gitlab/qa/component/specs.rb', line 11 def network @network end |
#release ⇒ Object
Returns the value of attribute release.
11 12 13 |
# File 'lib/gitlab/qa/component/specs.rb', line 11 def release @release end |
#runner_network ⇒ Object
Returns the value of attribute runner_network.
11 12 13 |
# File 'lib/gitlab/qa/component/specs.rb', line 11 def runner_network @runner_network end |
#suite ⇒ Object
Returns the value of attribute suite.
11 12 13 |
# File 'lib/gitlab/qa/component/specs.rb', line 11 def suite @suite end |
#volumes ⇒ Object
Returns the value of attribute volumes.
11 12 13 |
# File 'lib/gitlab/qa/component/specs.rb', line 11 def volumes @volumes end |
Instance Method Details
#perform ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/gitlab/qa/component/specs.rb', line 19 def perform return puts "Skipping tests." if skip_tests? raise ArgumentError unless [suite, release].all? @docker.login(**release.login_params) if release.login_params @docker.pull(image: qa_image) unless Runtime::Env.skip_pull? puts "Running test suite `#{suite}` for #{release.project_name}" name = "#{release.project_name}-qa-#{SecureRandom.hex(4)}" feature_flag_sets = [] # When `args` includes `[..., "--disable-feature", "a", "--enable-feature", "b", "--set-feature-flags", "c=enable", ...]` # `feature_flag_sets` will be set to `[["--disable-feature", "a"], ["--enable-feature", "b"], ["--set-feature-flags", "c=enable"]]` # This will result in tests running three times, once with each feature flag option. while (index = args&.index { |x| x =~ /--.*-feature/ }) feature_flag_sets << args.slice!(index, 2) end # When `args` do not have any feature flag options, we add [] so that test is run exactly once. feature_flag_sets << [] unless feature_flag_sets.any? feature_flag_sets.each do |feature_flag_set| @docker.run(image: qa_image, args: [suite, *args_with_flags(args, feature_flag_set)]) do |command| command << "-t --rm --net=#{network || 'bridge'}" env.merge(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 |