Commit 82304fbb authored by Walmyr Lima e Silva Filho's avatar Walmyr Lima e Silva Filho

Merge branch '198393-broken-foss-master-in-qa-internal' into 'master'

Resolve "Broken FOSS `master` in `qa:internal`"

Closes #198393

See merge request gitlab-org/gitlab!23528
parents 1c1b83ca b41d8157
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
.default-before_script: .default-before_script:
before_script: before_script:
- date - date
- '[ "$FOSS_ONLY" = "1" ] && rm -rf ee/' - '[ "$FOSS_ONLY" = "1" ] && rm -rf ee/ qa/spec/ee/ qa/qa/specs/features/ee/ qa/qa/ee/ qa/qa/ee.rb'
- export GOPATH=$CI_PROJECT_DIR/.go - export GOPATH=$CI_PROJECT_DIR/.go
- mkdir -p $GOPATH - mkdir -p $GOPATH
- source scripts/utils.sh - source scripts/utils.sh
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
paths: paths:
- vendor/ruby - vendor/ruby
before_script: before_script:
- '[ "$FOSS_ONLY" = "1" ] && rm -rf ee/' - '[ "$FOSS_ONLY" = "1" ] && rm -rf ee/ qa/spec/ee/ qa/qa/specs/features/ee/ qa/qa/ee/ qa/qa/ee.rb'
- cd qa/ - cd qa/
- bundle install --clean --jobs=$(nproc) --path=vendor --retry=3 --quiet - bundle install --clean --jobs=$(nproc) --path=vendor --retry=3 --quiet
- bundle check - bundle check
...@@ -50,6 +50,13 @@ qa:internal: ...@@ -50,6 +50,13 @@ qa:internal:
script: script:
- bundle exec rspec - bundle exec rspec
qa:internal-foss:
extends:
- .qa-job-base
- .only-ee-as-if-foss
script:
- bundle exec rspec
qa:selectors: qa:selectors:
extends: .qa-job-base extends: .qa-job-base
script: script:
......
...@@ -6,11 +6,16 @@ module QA ...@@ -6,11 +6,16 @@ module QA
extend self extend self
def extend_autoloads! def extend_autoloads!
require 'qa/ce/strategy'
require 'qa/ee' require 'qa/ee'
end end
def perform_before_hooks def perform_before_hooks
return unless ENV['EE_LICENSE'] # Without a license, perform the CE before hooks only.
unless ENV['EE_LICENSE']
QA::CE::Strategy.perform_before_hooks
return
end
QA::Support::Retrier.retry_on_exception do QA::Support::Retrier.retry_on_exception do
QA::Runtime::Browser.visit(:gitlab, QA::Page::Main::Login) do QA::Runtime::Browser.visit(:gitlab, QA::Page::Main::Login) do
......
...@@ -15,10 +15,6 @@ module QA ...@@ -15,10 +15,6 @@ module QA
CAPYBARA_MAX_WAIT_TIME = 10 CAPYBARA_MAX_WAIT_TIME = 10
class << self
attr_accessor :rspec_configured, :capybara_configured
end
def initialize def initialize
self.class.configure! self.class.configure!
end end
...@@ -49,49 +45,11 @@ module QA ...@@ -49,49 +45,11 @@ module QA
end end
def self.configure! 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| RSpec.configure do |config|
config.define_derived_metadata(file_path: %r{/qa/specs/features/}) do |metadata| config.define_derived_metadata(file_path: %r{/qa/specs/features/}) do |metadata|
metadata[:type] = :feature metadata[:type] = :feature
end 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
end
def self.configure_capybara!
return if self.capybara_configured
self.capybara_configured = true
Capybara.server_port = 9887 + ENV['TEST_ENV_NUMBER'].to_i Capybara.server_port = 9887 + ENV['TEST_ENV_NUMBER'].to_i
......
# frozen_string_literal: true # frozen_string_literal: true
require 'capybara/rspec'
require 'capybara-screenshot/rspec'
module QA module QA
module Runtime module Runtime
## ##
...@@ -24,6 +27,13 @@ module QA ...@@ -24,6 +27,13 @@ module QA
def self.method_missing(name, *args) def self.method_missing(name, *args)
self.new.strategy.public_send(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 end
end end
......
...@@ -23,7 +23,10 @@ module QA ...@@ -23,7 +23,10 @@ module QA
def perform(options, *args) def perform(options, *args)
extract_address(:gitlab_address, 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) Runtime::Feature.enable(options[:enable_feature]) if options.key?(:enable_feature)
......
...@@ -20,7 +20,10 @@ module QA ...@@ -20,7 +20,10 @@ module QA
def self.do_perform(address, *rspec_options) def self.do_perform(address, *rspec_options)
Runtime::Scenario.define(:gitlab_address, address) 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::Runner.perform do |specs|
specs.tty = true specs.tty = true
......
...@@ -31,6 +31,12 @@ shared_examples 'a QA scenario class' do ...@@ -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) expect(attributes).to have_received(:define).with(:gitlab_address, 'http://gitlab_address').at_least(:once)
end 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 it 'sets tags on runner' do
subject.perform(args) subject.perform(args)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment