diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-17 18:08:41 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-17 18:08:41 +0000 |
commit | 22a0d312ae82e7dda3073d5d1a5a766d7641738d (patch) | |
tree | 41a677a7212f24e2f29c2fbd5623430f92fb2b45 /qa | |
parent | 37eff29d5ce44899e34c7c2ac319b314f2f26d15 (diff) | |
download | gitlab-ce-22a0d312ae82e7dda3073d5d1a5a766d7641738d.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa/runtime/browser.rb | 33 | ||||
-rw-r--r-- | qa/qa/runtime/logger.rb | 8 | ||||
-rw-r--r-- | qa/qa/scenario/template.rb | 5 | ||||
-rw-r--r-- | qa/qa/scenario/test/instance.rb | 5 | ||||
-rw-r--r-- | qa/qa/support/page/logging.rb | 2 | ||||
-rw-r--r-- | qa/spec/page/base_spec.rb | 2 | ||||
-rw-r--r-- | qa/spec/spec_helper.rb | 6 | ||||
-rw-r--r-- | qa/spec/support/helpers/stub_env.rb (renamed from qa/spec/helpers/stub_env.rb) | 0 | ||||
-rw-r--r-- | qa/spec/support/shared_examples/scenario_shared_examples.rb (renamed from qa/spec/shared_examples/scenario_shared_examples.rb) | 6 |
9 files changed, 41 insertions, 26 deletions
diff --git a/qa/qa/runtime/browser.rb b/qa/qa/runtime/browser.rb index 69ba90702be..340f6dc0356 100644 --- a/qa/qa/runtime/browser.rb +++ b/qa/qa/runtime/browser.rb @@ -15,6 +15,10 @@ module QA CAPYBARA_MAX_WAIT_TIME = 10 + class << self + attr_accessor :rspec_configured, :capybara_configured + end + def initialize self.class.configure! end @@ -45,11 +49,40 @@ 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 do + unless browser.rspec_configured + browser.rspec_configured = true + + ## + # Perform before hooks, which are different for CE and EE + # + Runtime::Release.perform_before_hooks + 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/logger.rb b/qa/qa/runtime/logger.rb index 7f73f1bd01b..a70c8faf7d2 100644 --- a/qa/qa/runtime/logger.rb +++ b/qa/qa/runtime/logger.rb @@ -14,11 +14,9 @@ module QA attr_writer :logger def logger - return @logger if @logger - - @logger = ::Logger.new Runtime::Env.log_destination - @logger.level = Runtime::Env.debug? ? ::Logger::DEBUG : ::Logger::ERROR - @logger + @logger ||= ::Logger.new(Runtime::Env.log_destination).tap do |logger| + logger.level = Runtime::Env.debug? ? ::Logger::DEBUG : ::Logger::ERROR + end end end end diff --git a/qa/qa/scenario/template.rb b/qa/qa/scenario/template.rb index 74d4c8f8757..97373f7a059 100644 --- a/qa/qa/scenario/template.rb +++ b/qa/qa/scenario/template.rb @@ -23,11 +23,6 @@ module QA def perform(options, *args) extract_address(:gitlab_address, options, args) - ## - # 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) Specs::Runner.perform do |specs| diff --git a/qa/qa/scenario/test/instance.rb b/qa/qa/scenario/test/instance.rb index b4098619e4e..79dad7f4619 100644 --- a/qa/qa/scenario/test/instance.rb +++ b/qa/qa/scenario/test/instance.rb @@ -20,11 +20,6 @@ module QA def self.do_perform(address, *rspec_options) Runtime::Scenario.define(:gitlab_address, address) - ## - # Perform before hooks, which are different for CE and EE - # - Runtime::Release.perform_before_hooks - Specs::Runner.perform do |specs| specs.tty = true specs.options = rspec_options if rspec_options.any? diff --git a/qa/qa/support/page/logging.rb b/qa/qa/support/page/logging.rb index 82a679b6d15..f59795e17c3 100644 --- a/qa/qa/support/page/logging.rb +++ b/qa/qa/support/page/logging.rb @@ -16,7 +16,7 @@ module QA super end - def wait_until(max_duration: 60, sleep_interval: 0.1, reload: true) + def wait_until(max_duration: 60, sleep_interval: 0.1, reload: true, raise_on_failure: false) log("next wait uses reload: #{reload}") # Logging of wait start/end/duration is handled by QA::Support::Waiter diff --git a/qa/spec/page/base_spec.rb b/qa/spec/page/base_spec.rb index 717112b12ce..2d13889d26d 100644 --- a/qa/spec/page/base_spec.rb +++ b/qa/spec/page/base_spec.rb @@ -62,7 +62,7 @@ describe QA::Page::Base do end end - describe '#wait' do + describe '#wait_until' do subject { Class.new(described_class).new } context 'when the condition is true' do diff --git a/qa/spec/spec_helper.rb b/qa/spec/spec_helper.rb index 3a26ed89e9c..1336bea16bc 100644 --- a/qa/spec/spec_helper.rb +++ b/qa/spec/spec_helper.rb @@ -12,9 +12,9 @@ QA::Runtime::Browser.configure! QA::Runtime::Scenario.from_env(QA::Runtime::Env.runtime_scenario_attributes) if QA::Runtime::Env.runtime_scenario_attributes -%w[helpers shared_examples].each do |d| - Dir[::File.join(__dir__, d, '**', '*.rb')].each { |f| require f } -end +Dir[::File.join(__dir__, "support/helpers/*.rb")].each { |f| require f } +Dir[::File.join(__dir__, "support/shared_contexts/*.rb")].each { |f| require f } +Dir[::File.join(__dir__, "support/shared_examples/*.rb")].each { |f| require f } RSpec.configure do |config| QA::Specs::Helpers::Quarantine.configure_rspec diff --git a/qa/spec/helpers/stub_env.rb b/qa/spec/support/helpers/stub_env.rb index 8ad864dbec8..8ad864dbec8 100644 --- a/qa/spec/helpers/stub_env.rb +++ b/qa/spec/support/helpers/stub_env.rb diff --git a/qa/spec/shared_examples/scenario_shared_examples.rb b/qa/spec/support/shared_examples/scenario_shared_examples.rb index 697e6cb39c8..17469ea470c 100644 --- a/qa/spec/shared_examples/scenario_shared_examples.rb +++ b/qa/spec/support/shared_examples/scenario_shared_examples.rb @@ -31,12 +31,6 @@ 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' do - subject.perform(args) - - expect(release).to have_received(:perform_before_hooks) - end - it 'sets tags on runner' do subject.perform(args) |