diff options
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa/runtime/browser.rb | 42 | ||||
-rw-r--r-- | qa/qa/runtime/release.rb | 10 | ||||
-rw-r--r-- | qa/qa/scenario/template.rb | 5 | ||||
-rw-r--r-- | qa/qa/scenario/test/instance.rb | 5 | ||||
-rw-r--r-- | qa/spec/support/shared_examples/scenario_shared_examples.rb | 6 |
5 files changed, 24 insertions, 44 deletions
diff --git a/qa/qa/runtime/browser.rb b/qa/qa/runtime/browser.rb index ec78759f6c8..69ba90702be 100644 --- a/qa/qa/runtime/browser.rb +++ b/qa/qa/runtime/browser.rb @@ -15,10 +15,6 @@ module QA CAPYBARA_MAX_WAIT_TIME = 10 - class << self - attr_accessor :rspec_configured, :capybara_configured - end - def initialize self.class.configure! end @@ -49,49 +45,11 @@ module QA end def self.configure! - configure_rspec! - configure_capybara! - end - - def self.configure_rspec! - # We don't want to enter this infinite loop: - # Runtime::Release.perform_before_hooks -> `QA::Runtime::Browser.visit` -> configure! -> configure_rspec! -> Runtime::Release.perform_before_hooks - # So we make sure this method is called only once. - return if self.rspec_configured - - browser = self - RSpec.configure do |config| config.define_derived_metadata(file_path: %r{/qa/specs/features/}) do |metadata| metadata[:type] = :feature end - - config.before(:suite) do - unless browser.rspec_configured - browser.rspec_configured = true - - ## - # Perform before hooks, which are different for CE and EE - # - begin - Runtime::Release.perform_before_hooks - rescue - saved = Capybara::Screenshot.screenshot_and_save_page - - QA::Runtime::Logger.error("Screenshot: #{saved[:image]}") if saved&.key?(:image) - QA::Runtime::Logger.error("HTML capture: #{saved[:html]}") if saved&.key?(:html) - - raise - end - end - end end - end - - def self.configure_capybara! - return if self.capybara_configured - - self.capybara_configured = true Capybara.server_port = 9887 + ENV['TEST_ENV_NUMBER'].to_i diff --git a/qa/qa/runtime/release.rb b/qa/qa/runtime/release.rb index 18a6736afcf..1cd0c62563b 100644 --- a/qa/qa/runtime/release.rb +++ b/qa/qa/runtime/release.rb @@ -1,5 +1,8 @@ # frozen_string_literal: true +require 'capybara/rspec' +require 'capybara-screenshot/rspec' + module QA module Runtime ## @@ -24,6 +27,13 @@ module QA def self.method_missing(name, *args) self.new.strategy.public_send(name, *args) + rescue + saved = Capybara::Screenshot.screenshot_and_save_page + + QA::Runtime::Logger.error("Screenshot: #{saved[:image]}") if saved&.key?(:image) + QA::Runtime::Logger.error("HTML capture: #{saved[:html]}") if saved&.key?(:html) + + raise end end end diff --git a/qa/qa/scenario/template.rb b/qa/qa/scenario/template.rb index 9c599ec2d4d..74d4c8f8757 100644 --- a/qa/qa/scenario/template.rb +++ b/qa/qa/scenario/template.rb @@ -23,7 +23,10 @@ module QA def perform(options, *args) extract_address(:gitlab_address, options, args) - QA::Runtime::Browser.configure! + ## + # Perform before hooks, which are different for CE and EE + # + Runtime::Release.perform_before_hooks Runtime::Feature.enable(options[:enable_feature]) if options.key?(:enable_feature) diff --git a/qa/qa/scenario/test/instance.rb b/qa/qa/scenario/test/instance.rb index 11b6a7f7dfa..b4098619e4e 100644 --- a/qa/qa/scenario/test/instance.rb +++ b/qa/qa/scenario/test/instance.rb @@ -20,7 +20,10 @@ module QA def self.do_perform(address, *rspec_options) Runtime::Scenario.define(:gitlab_address, address) - QA::Runtime::Browser.configure! + ## + # Perform before hooks, which are different for CE and EE + # + Runtime::Release.perform_before_hooks Specs::Runner.perform do |specs| specs.tty = true diff --git a/qa/spec/support/shared_examples/scenario_shared_examples.rb b/qa/spec/support/shared_examples/scenario_shared_examples.rb index 17469ea470c..6e20adbd4ad 100644 --- a/qa/spec/support/shared_examples/scenario_shared_examples.rb +++ b/qa/spec/support/shared_examples/scenario_shared_examples.rb @@ -31,6 +31,12 @@ shared_examples 'a QA scenario class' do expect(attributes).to have_received(:define).with(:gitlab_address, 'http://gitlab_address').at_least(:once) end + it 'performs before hooks only once' do + subject.perform(args) + + expect(release).to have_received(:perform_before_hooks).once + end + it 'sets tags on runner' do subject.perform(args) |