summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Lapierre <mlapierre@gitlab.com>2019-06-18 03:37:06 +0000
committerMark Lapierre <mlapierre@gitlab.com>2019-06-18 03:37:06 +0000
commita35195f4b84aa060f8e1e22bf85b6f798df38364 (patch)
tree5a21ab85ebd54497555183c4887684c6af18e6f6
parent8ac1ac2b9f1d070eb70bb21e0aa18b421836a48f (diff)
parentcfe0043d5476ebc45c477e96f85042877fab7edf (diff)
downloadgitlab-ce-a35195f4b84aa060f8e1e22bf85b6f798df38364.tar.gz
Merge branch 'qa-ml-push-test-requires-admin' into 'master'
[QA] Test push limit with admin user Closes gitlab-org/quality/staging#37 See merge request gitlab-org/gitlab-ce!29036
-rw-r--r--qa/qa/runtime/env.rb23
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_file_size_spec.rb59
-rw-r--r--qa/spec/runtime/env_spec.rb6
-rw-r--r--qa/spec/specs/runner_spec.rb68
4 files changed, 95 insertions, 61 deletions
diff --git a/qa/qa/runtime/env.rb b/qa/qa/runtime/env.rb
index 82510dfa03c..96f337dc081 100644
--- a/qa/qa/runtime/env.rb
+++ b/qa/qa/runtime/env.rb
@@ -10,13 +10,26 @@ module QA
# The environment variables used to indicate if the environment under test
# supports the given feature
SUPPORTED_FEATURES = {
- git_protocol_v2: 'QA_CAN_TEST_GIT_PROTOCOL_V2'
+ git_protocol_v2: 'QA_CAN_TEST_GIT_PROTOCOL_V2',
+ admin: 'QA_CAN_TEST_ADMIN_FEATURES'
}.freeze
def supported_features
SUPPORTED_FEATURES
end
+ def admin_password
+ ENV['GITLAB_ADMIN_PASSWORD']
+ end
+
+ def admin_username
+ ENV['GITLAB_ADMIN_USERNAME']
+ end
+
+ def admin_personal_access_token
+ ENV['GITLAB_QA_ADMIN_ACCESS_TOKEN']
+ end
+
def debug?
enabled?(ENV['QA_DEBUG'], default: false)
end
@@ -92,14 +105,6 @@ module QA
ENV['GITLAB_PASSWORD']
end
- def admin_username
- ENV['GITLAB_ADMIN_USERNAME']
- end
-
- def admin_password
- ENV['GITLAB_ADMIN_PASSWORD']
- end
-
def github_username
ENV['GITHUB_USERNAME']
end
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_file_size_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_file_size_spec.rb
index 5bfafdfa041..247cde38e52 100644
--- a/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_file_size_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_file_size_spec.rb
@@ -1,74 +1,57 @@
# frozen_string_literal: true
module QA
- # Failure issue: https://gitlab.com/gitlab-org/quality/staging/issues/37
- context 'Create', :quarantine do
+ context 'Create', :requires_admin do
describe 'push after setting the file size limit via admin/application_settings' do
- before(:all) do
- push = Resource::Repository::ProjectPush.fabricate! do |p|
- p.file_name = 'README.md'
- p.file_content = '# This is a test project'
- p.commit_message = 'Add README.md'
+ before(:context) do
+ @project = Resource::Project.fabricate_via_api! do |p|
+ p.name = 'project-test-push-limit'
+ p.initialize_with_readme = true
end
- @project = push.project
+ @api_client = Runtime::API::Client.new(:gitlab, personal_access_token: Runtime::Env.admin_personal_access_token)
end
- before do
- Runtime::Browser.visit(:gitlab, Page::Main::Login)
- Page::Main::Login.perform(&:sign_in_using_credentials)
- end
-
- after(:all) do
+ after(:context) do
# need to set the default value after test
# default value for file size limit is empty
- Runtime::Browser.visit(:gitlab, Page::Main::Login)
- Page::Main::Login.perform(&:sign_in_using_credentials)
-
- set_file_size_limit('')
-
- Page::Main::Menu.perform(&:sign_out)
+ set_file_size_limit(nil)
end
it 'push successful when the file size is under the limit' do
set_file_size_limit(5)
- expect(page).to have_content("Application settings saved successfully")
-
push = push_new_file('oversize_file_1.bin', wait_for_push: true)
expect(push.output).not_to have_content 'remote: fatal: pack exceeds maximum allowed size'
end
it 'push fails when the file size is above the limit' do
set_file_size_limit(1)
- expect(page).to have_content("Application settings saved successfully")
-
expect { push_new_file('oversize_file_2.bin', wait_for_push: false) }
.to raise_error(QA::Git::Repository::RepositoryCommandError, /remote: fatal: pack exceeds maximum allowed size/)
end
def set_file_size_limit(limit)
- Page::Main::Menu.perform(&:click_admin_area)
- Page::Admin::Menu.perform(&:go_to_general_settings)
+ request = Runtime::API::Request.new(@api_client, '/application/settings')
+ put request.url, receive_max_input_size: limit
- Page::Admin::Settings::General.perform do |setting|
- setting.expand_account_and_limit do |page|
- page.set_max_file_size(limit)
- page.save_settings
- end
- end
+ expect_status(200)
+ expect(json_body).to match(
+ a_hash_including(receive_max_input_size: limit)
+ )
end
def push_new_file(file_name, wait_for_push: true)
- @project.visit!
-
- Resource::Repository::ProjectPush.fabricate! do |p|
- p.project = @project
+ commit_message = 'Adding a new file'
+ output = Resource::Repository::Push.fabricate! do |p|
+ p.repository_http_uri = @project.repository_http_location.uri
p.file_name = file_name
p.file_content = SecureRandom.random_bytes(2000000)
- p.commit_message = 'Adding a new file'
- p.wait_for_push = wait_for_push
+ p.commit_message = commit_message
p.new_branch = false
end
+ @project.wait_for_push commit_message
+
+ output
end
end
end
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)