Merge branch '50963-qa-orchestrated-tests-don-t-run-due-to-wrong-tag-filters-qa' into 'master'

Resolve "[QA] Orchestrated tests don't run due to wrong tag filters"

Closes #49654 and #50963

See merge request gitlab-org/gitlab-ce!21468
This commit is contained in:
Grzegorz Bizon 2018-09-05 06:51:19 +00:00
commit c2eff16eca
14 changed files with 174 additions and 101 deletions

View file

@ -28,12 +28,8 @@ module QA
Specs::Runner.perform do |specs|
specs.tty = true
specs.options =
if rspec_options.any?
rspec_options
else
['--tag', self.class.focus.join(','), '--', ::File.expand_path('../specs/features', __dir__)]
end
specs.tags = self.class.focus
specs.options = rspec_options if rspec_options.any?
end
end
end

View file

@ -27,12 +27,7 @@ module QA
Specs::Runner.perform do |specs|
specs.tty = true
specs.options =
if rspec_options.any?
rspec_options
else
['--', ::File.expand_path('../../specs/features', __dir__)]
end
specs.options = rspec_options if rspec_options.any?
end
end
end

View file

@ -30,7 +30,7 @@ module QA
push.project = project
push.directory = Pathname
.new(__dir__)
.join('../../../fixtures/auto_devops_rack')
.join('../../../../../fixtures/auto_devops_rack')
push.commit_message = 'Create Auto DevOps compatible rack application'
end

View file

@ -16,9 +16,9 @@ module QA
args.push('--tty') if tty
if tags.any?
tags.each { |tag| args.push(['-t', tag.to_s]) }
tags.each { |tag| args.push(['--tag', tag.to_s]) }
else
args.push(%w[-t ~orchestrated])
args.push(%w[--tag ~orchestrated])
end
args.push(options)

View file

@ -29,7 +29,7 @@ describe QA::Git::Repository do
def cd_empty_temp_directory
tmp_dir = 'tmp/git-repository-spec/'
FileUtils.rm_r(tmp_dir) if ::File.exist?(tmp_dir)
FileUtils.rm_rf(tmp_dir) if ::File.exist?(tmp_dir)
FileUtils.mkdir_p tmp_dir
FileUtils.cd tmp_dir
end

View file

@ -1,45 +1,3 @@
describe QA::Scenario::Test::Instance::All do
subject do
Class.new(described_class) do
tags :rspec, :foo
end
end
context '#perform' do
let(:arguments) { spy('Runtime::Scenario') }
let(:release) { spy('Runtime::Release') }
let(:runner) { spy('Specs::Runner') }
before do
stub_const('QA::Runtime::Release', release)
stub_const('QA::Runtime::Scenario', arguments)
stub_const('QA::Specs::Runner', runner)
allow(runner).to receive(:perform).and_yield(runner)
end
it 'sets an address of the subject' do
subject.perform("hello")
expect(arguments).to have_received(:define)
.with(:gitlab_address, "hello")
end
context 'no paths' do
it 'calls runner with default arguments' do
subject.perform("test")
expect(runner).to have_received(:options=)
.with(['--tag', 'rspec,foo', '--', ::File.expand_path('../../../../qa/specs/features', __dir__)])
end
end
context 'specifying paths' do
it 'calls runner with paths' do
subject.perform('test', 'path1', 'path2')
expect(runner).to have_received(:options=).with(%w[path1 path2])
end
end
end
it_behaves_like 'a QA scenario class'
end

View file

@ -1,45 +1,5 @@
describe QA::Scenario::Test::Instance::Smoke do
subject { Class.new(described_class) { tags :smoke } }
context '#perform' do
let(:arguments) { spy('Runtime::Scenario') }
let(:release) { spy('Runtime::Release') }
let(:runner) { spy('Specs::Runner') }
before do
stub_const('QA::Runtime::Release', release)
stub_const('QA::Runtime::Scenario', arguments)
stub_const('QA::Specs::Runner', runner)
allow(runner).to receive(:perform).and_yield(runner)
end
it 'sets an address of the subject' do
subject.perform("hello")
expect(arguments).to have_received(:define)
.with(:gitlab_address, "hello")
end
it 'has a smoke tag' do
expect(subject.focus).to eq([:smoke]) # rubocop:disable Focus
end
context 'no paths' do
it 'calls runner with default arguments' do
subject.perform("test")
expect(runner).to have_received(:options=)
.with(['--tag', 'smoke', '--', ::File.expand_path('../../../../qa/specs/features', __dir__)])
end
end
context 'specifying paths' do
it 'calls runner with paths' do
subject.perform('test', 'path1', 'path2')
expect(runner).to have_received(:options=).with(%w[path1 path2])
end
end
it_behaves_like 'a QA scenario class' do
let(:tags) { [:smoke] }
end
end

View file

@ -0,0 +1,21 @@
# frozen_string_literal: true
describe QA::Scenario::Test::Integration::Github do
context '#perform' do
let(:env) { spy('Runtime::Env') }
before do
stub_const('QA::Runtime::Env', env)
end
it_behaves_like 'a QA scenario class' do
let(:tags) { [:github] }
it 'requires a GitHub access token' do
subject.perform('gitlab_address')
expect(env).to have_received(:require_github_access_token!)
end
end
end
end

View file

@ -0,0 +1,9 @@
# frozen_string_literal: true
describe QA::Scenario::Test::Integration::Kubernetes do
context '#perform' do
it_behaves_like 'a QA scenario class' do
let(:tags) { [:kubernetes] }
end
end
end

View file

@ -0,0 +1,9 @@
# frozen_string_literal: true
describe QA::Scenario::Test::Integration::LDAP do
context '#perform' do
it_behaves_like 'a QA scenario class' do
let(:tags) { [:ldap] }
end
end
end

View file

@ -0,0 +1,18 @@
# frozen_string_literal: true
describe QA::Scenario::Test::Integration::Mattermost do
context '#perform' do
it_behaves_like 'a QA scenario class' do
let(:args) { %w[gitlab_address mattermost_address] }
let(:tags) { [:mattermost] }
let(:options) { ['path1']}
it 'requires a GitHub access token' do
subject.perform(*args)
expect(attributes).to have_received(:define)
.with(:mattermost_address, 'mattermost_address')
end
end
end
end

View file

@ -0,0 +1,9 @@
# frozen_string_literal: true
describe QA::Scenario::Test::Integration::ObjectStorage do
context '#perform' do
it_behaves_like 'a QA scenario class' do
let(:tags) { [:object_storage] }
end
end
end

View file

@ -0,0 +1,49 @@
# frozen_string_literal: true
describe QA::Specs::Runner do
context '#perform' do
before do
allow(QA::Runtime::Browser).to receive(:configure!)
end
it 'excludes the orchestrated tag by default' do
expect(RSpec::Core::Runner).to receive(:run)
.with(['--tag', '~orchestrated', File.expand_path('../../qa/specs/features', __dir__)], $stderr, $stdout)
.and_return(0)
subject.perform
end
context 'when tty is set' do
subject do
described_class.new.tap do |runner|
runner.tty = true
end
end
it 'sets the `--tty` flag' do
expect(RSpec::Core::Runner).to receive(:run)
.with(['--tty', '--tag', '~orchestrated', File.expand_path('../../qa/specs/features', __dir__)], $stderr, $stdout)
.and_return(0)
subject.perform
end
end
context 'when tags are set' do
subject do
described_class.new.tap do |runner|
runner.tags = %i[orchestrated github]
end
end
it 'focuses on the given tags' do
expect(RSpec::Core::Runner).to receive(:run)
.with(['--tag', 'orchestrated', '--tag', 'github', File.expand_path('../../qa/specs/features', __dir__)], $stderr, $stdout)
.and_return(0)
subject.perform
end
end
end
end

View file

@ -0,0 +1,49 @@
# frozen_string_literal: true
shared_examples 'a QA scenario class' do
let(:attributes) { spy('Runtime::Scenario') }
let(:release) { spy('Runtime::Release') }
let(:runner) { spy('Specs::Runner') }
let(:args) { ['gitlab_address'] }
let(:tags) { [] }
let(:options) { %w[path1 path2] }
before do
stub_const('QA::Runtime::Release', release)
stub_const('QA::Runtime::Scenario', attributes)
stub_const('QA::Specs::Runner', runner)
allow(runner).to receive(:perform).and_yield(runner)
end
it 'responds to perform' do
expect(subject).to respond_to(:perform)
end
it 'sets an address of the subject' do
subject.perform(*args)
expect(attributes).to have_received(:define).with(:gitlab_address, 'gitlab_address')
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)
expect(runner).to have_received(:tags=).with(tags)
end
context 'specifying RSpec options' do
it 'sets options on runner' do
subject.perform(*args, *options)
expect(runner).to have_received(:options=).with(options)
end
end
end