summaryrefslogtreecommitdiff
path: root/qa/qa/scenario/template.rb
diff options
context:
space:
mode:
Diffstat (limited to 'qa/qa/scenario/template.rb')
-rw-r--r--qa/qa/scenario/template.rb53
1 files changed, 35 insertions, 18 deletions
diff --git a/qa/qa/scenario/template.rb b/qa/qa/scenario/template.rb
index 8cf1fa0705f..9cd9a6f438c 100644
--- a/qa/qa/scenario/template.rb
+++ b/qa/qa/scenario/template.rb
@@ -21,16 +21,14 @@ module QA
end
def perform(options, *args)
- extract_address(:gitlab_address, options, args)
-
- gitlab_address = URI(Runtime::Scenario.gitlab_address)
+ gitlab_address = extract_gitlab_address(options, args)
# Define the "About" page as an `about` subdomain.
# @example
# Given *gitlab_address* = 'https://gitlab.com/' #=> https://about.gitlab.com/
# Given *gitlab_address* = 'https://staging.gitlab.com/' #=> https://about.staging.gitlab.com/
# Given *gitlab_address* = 'http://gitlab-abc123.test/' #=> http://about.gitlab-abc123.test/
- Runtime::Scenario.define(:about_address, URI(-> { gitlab_address.host = "about.#{gitlab_address.host}"; gitlab_address }.call).to_s) # rubocop:disable Style/Semicolon
+ Runtime::Scenario.define(:about_address, gitlab_address.tap { |add| add.host = "about.#{add.host}" }.to_s)
# Save the scenario class name
Runtime::Scenario.define(:klass, self.class.name)
@@ -43,11 +41,14 @@ module QA
##
# Perform before hooks, which are different for CE and EE
#
-
Runtime::Release.perform_before_hooks unless Runtime::Env.dry_run
Runtime::Feature.enable(options[:enable_feature]) if options.key?(:enable_feature)
- Runtime::Feature.disable(options[:disable_feature]) if options.key?(:disable_feature) && (@feature_enabled = Runtime::Feature.enabled?(options[:disable_feature]))
+
+ if options.key?(:disable_feature) && (@feature_enabled = Runtime::Feature.enabled?(options[:disable_feature]))
+ Runtime::Feature.disable(options[:disable_feature])
+ end
+
Runtime::Feature.set(options[:set_feature_flags]) if options.key?(:set_feature_flags)
Specs::Runner.perform do |specs|
@@ -60,25 +61,41 @@ module QA
Runtime::Feature.enable(options[:disable_feature]) if options.key?(:disable_feature) && @feature_enabled
end
- def extract_option(name, options, args)
- option = if options.key?(name)
- options[name]
- else
- args.shift
- end
-
- Runtime::Scenario.define(name, option)
+ def extract_address(name, options)
+ address = options[name]
+ validate_address(name, address)
- option
+ Runtime::Scenario.define(name, address)
end
+ private
+
# For backwards-compatibility, if the gitlab instance address is not
# specified as an option parsed by OptionParser, it can be specified as
# the first argument
- def extract_address(name, options, args)
- address = extract_option(name, options, args)
+ def extract_gitlab_address(options, args)
+ opt_name = :gitlab_address
+ address_from_opt = Runtime::Scenario.attributes[opt_name]
+ # return gitlab address if it was set via named option already
+ return validate_address(opt_name, address_from_opt) && URI(address_from_opt) if address_from_opt
+
+ address = if args.first.nil? || File.exist?(args.first)
+ # if first arg is a valid path and not address, it's a spec file, default to environment variable
+ Runtime::Env.gitlab_url
+ else
+ args.shift
+ end
+
+ validate_address(opt_name, address)
+ Runtime::Scenario.define(opt_name, address)
+
+ URI(address)
+ end
- raise ::ArgumentError, "The address provided for `#{name}` is not valid: #{address}" unless Runtime::Address.valid?(address)
+ def validate_address(name, address)
+ Runtime::Address.valid?(address) || raise(
+ ::ArgumentError, "Configured address parameter '#{name}' is not a valid url: #{address}"
+ )
end
end
end