Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/qa/spec
diff options
context:
space:
mode:
authorMark Lapierre <mlapierre@gitlab.com>2019-06-18 06:37:05 +0300
committerMark Lapierre <mlapierre@gitlab.com>2019-06-18 06:37:05 +0300
commitcfe0043d5476ebc45c477e96f85042877fab7edf (patch)
tree5a21ab85ebd54497555183c4887684c6af18e6f6 /qa/spec
parent8ac1ac2b9f1d070eb70bb21e0aa18b421836a48f (diff)
Test push limit with admin user
Uses `:requires_admin` metadata to specify that a test needs an admin user. Sets the push file size limit test to require an admin user. With an admin access token set as the env var GITLAB_QA_ADMIN_ACCESS_TOKEN, the push size limit test now only uses the API and CLI
Diffstat (limited to 'qa/spec')
-rw-r--r--qa/spec/runtime/env_spec.rb6
-rw-r--r--qa/spec/specs/runner_spec.rb68
2 files changed, 60 insertions, 14 deletions
diff --git a/qa/spec/runtime/env_spec.rb b/qa/spec/runtime/env_spec.rb
index 2560695ef2e..caf96a213e1 100644
--- a/qa/spec/runtime/env_spec.rb
+++ b/qa/spec/runtime/env_spec.rb
@@ -227,6 +227,12 @@ describe QA::Runtime::Env do
env_key: 'QA_CAN_TEST_GIT_PROTOCOL_V2',
default: true
+ it_behaves_like 'boolean method with parameter',
+ method: :can_test?,
+ param: :admin,
+ env_key: 'QA_CAN_TEST_ADMIN_FEATURES',
+ default: true
+
it 'raises ArgumentError if feature is unknown' do
expect { described_class.can_test? :foo }.to raise_error(ArgumentError, 'Unknown feature "foo"')
end
diff --git a/qa/spec/specs/runner_spec.rb b/qa/spec/specs/runner_spec.rb
index 5c86c102105..f94145d148e 100644
--- a/qa/spec/specs/runner_spec.rb
+++ b/qa/spec/specs/runner_spec.rb
@@ -1,16 +1,22 @@
# frozen_string_literal: true
+require 'active_support/core_ext/hash'
+
describe QA::Specs::Runner do
+ shared_examples 'excludes orchestrated' do
+ it 'excludes the orchestrated tag and includes default args' do
+ expect_rspec_runner_arguments(['--tag', '~orchestrated', *described_class::DEFAULT_TEST_PATH_ARGS])
+
+ subject.perform
+ end
+ end
+
context '#perform' do
before do
allow(QA::Runtime::Browser).to receive(:configure!)
end
- it 'excludes the orchestrated tag by default' do
- expect_rspec_runner_arguments(['--tag', '~orchestrated', *described_class::DEFAULT_TEST_PATH_ARGS])
-
- subject.perform
- end
+ it_behaves_like 'excludes orchestrated'
context 'when tty is set' do
subject { described_class.new.tap { |runner| runner.tty = true } }
@@ -67,8 +73,6 @@ describe QA::Specs::Runner do
allow(QA::Runtime::Env).to receive(:signup_disabled?).and_return(true)
end
- subject { described_class.new }
-
it 'includes default args and excludes the skip_signup_disabled tag' do
expect_rspec_runner_arguments(['--tag', '~orchestrated', '--tag', '~skip_signup_disabled', *described_class::DEFAULT_TEST_PATH_ARGS])
@@ -76,18 +80,54 @@ describe QA::Specs::Runner do
end
end
- context 'when git protocol v2 is not supported' do
- before do
- allow(QA::Runtime::Env).to receive(:can_test?).with(:git_protocol_v2).and_return(false)
+ context 'testable features' do
+ shared_examples 'one supported feature' do |feature|
+ before do
+ QA::Runtime::Env.supported_features.each do |tag, _|
+ allow(QA::Runtime::Env).to receive(:can_test?).with(tag).and_return(false)
+ end
+
+ allow(QA::Runtime::Env).to receive(:can_test?).with(feature).and_return(true) unless feature.nil?
+ end
+
+ it 'includes default args and excludes all unsupported tags' do
+ expect_rspec_runner_arguments(['--tag', '~orchestrated', *excluded_feature_tags_except(feature), *described_class::DEFAULT_TEST_PATH_ARGS])
+
+ subject.perform
+ end
end
- subject { described_class.new }
+ context 'when only git protocol 2 is supported' do
+ it_behaves_like 'one supported feature', :git_protocol_v2
+ end
- it 'includes default args and excludes the requires_git_protocol_v2 tag' do
- expect_rspec_runner_arguments(['--tag', '~orchestrated', '--tag', '~requires_git_protocol_v2', *described_class::DEFAULT_TEST_PATH_ARGS])
+ context 'when only admin features are supported' do
+ it_behaves_like 'one supported feature', :admin
+ end
- subject.perform
+ context 'when no features are supported' do
+ it_behaves_like 'one supported feature', nil
end
+
+ context 'when all features are supported' do
+ before do
+ QA::Runtime::Env.supported_features.each do |tag, _|
+ allow(QA::Runtime::Env).to receive(:can_test?).with(tag).and_return(true)
+ end
+ end
+
+ it_behaves_like 'excludes orchestrated'
+ end
+
+ context 'when features are not specified' do
+ it_behaves_like 'excludes orchestrated'
+ end
+ end
+
+ def excluded_feature_tags_except(tag)
+ QA::Runtime::Env.supported_features.except(tag).map do |tag, _|
+ ['--tag', "~requires_#{tag}"]
+ end.flatten
end
def expect_rspec_runner_arguments(arguments)