summaryrefslogtreecommitdiff
path: root/qa/spec
diff options
context:
space:
mode:
Diffstat (limited to 'qa/spec')
-rw-r--r--qa/spec/README.md7
-rw-r--r--qa/spec/git/repository_spec.rb6
-rw-r--r--qa/spec/qa_deprecation_toolkit_env.rb22
-rw-r--r--qa/spec/scenario/template_spec.rb72
-rw-r--r--qa/spec/scenario/test/integration/mattermost_spec.rb18
-rw-r--r--qa/spec/scenario_shared_examples.rb (renamed from qa/spec/specs/scenario_shared_examples.rb)19
-rw-r--r--qa/spec/spec_helper.rb132
-rw-r--r--qa/spec/specs/spec_helper.rb5
-rw-r--r--qa/spec/support/shared_contexts/merge_train_spec_with_user_prep.rb88
-rw-r--r--qa/spec/support/shared_contexts/packages_registry_shared_context.rb68
-rw-r--r--qa/spec/support/shared_contexts/variable_inheritance_shared_context.rb150
-rw-r--r--qa/spec/support/shared_examples/merge_with_code_owner_shared_examples.rb72
12 files changed, 68 insertions, 591 deletions
diff --git a/qa/spec/README.md b/qa/spec/README.md
new file mode 100644
index 00000000000..b1fc38fb55d
--- /dev/null
+++ b/qa/spec/README.md
@@ -0,0 +1,7 @@
+# QA framework unit tests
+
+To run framework unit tests, following command can be used:
+
+```shell
+bundle exec rspec -O .rspec_internal
+```
diff --git a/qa/spec/git/repository_spec.rb b/qa/spec/git/repository_spec.rb
index 6b100f9dc16..a6a49f5907a 100644
--- a/qa/spec/git/repository_spec.rb
+++ b/qa/spec/git/repository_spec.rb
@@ -206,19 +206,19 @@ RSpec.describe QA::Git::Repository do
it_behaves_like 'command with retries' do
let(:command) { "git ls-remote #{repo_uri_with_credentials}" }
- let(:result_output) { +'packet: git< version 2' }
+ let(:result_output) { +'packet: ls-remote< version 2' }
let(:command_return) { '2' }
let(:extra_env_vars) { ["GIT_TRACE_PACKET=1"] }
end
it "reports the detected version" do
- expect(repository).to receive(:run).and_return(described_class::Result.new(any_args, 0, "packet: git< version 2"))
+ expect(repository).to receive(:run).and_return(described_class::Result.new(any_args, 0, "packet: ls-remote< version 2"))
expect(call_method).to eq('2')
end
it 'reports unknown if version is unknown' do
- expect(repository).to receive(:run).and_return(described_class::Result.new(any_args, 0, "packet: git< version -1"))
+ expect(repository).to receive(:run).and_return(described_class::Result.new(any_args, 0, "packet: ls-remote< version -1"))
expect(call_method).to eq('unknown')
end
diff --git a/qa/spec/qa_deprecation_toolkit_env.rb b/qa/spec/qa_deprecation_toolkit_env.rb
deleted file mode 100644
index 2a21961d89e..00000000000
--- a/qa/spec/qa_deprecation_toolkit_env.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# frozen_string_literal: true
-
-require 'deprecation_toolkit'
-require 'deprecation_toolkit/rspec'
-require 'concurrent/utility/monotonic_time'
-require 'active_support/gem_version'
-
-module QaDeprecationToolkitEnv
- # Taken from https://github.com/jeremyevans/ruby-warning/blob/1.1.0/lib/warning.rb#L18
- def self.kwargs_warning
- %r{warning: (?:Using the last argument (?:for `.+' )?as keyword parameters is deprecated; maybe \*\* should be added to the call|Passing the keyword argument (?:for `.+' )?as the last hash parameter is deprecated|Splitting the last argument (?:for `.+' )?into positional and keyword parameters is deprecated|The called method (?:`.+' )?is defined here)\n\z}
- end
-
- def self.configure!
- # Enable ruby deprecations for keywords, it's suppressed by default in Ruby 2.7
- Warning[:deprecated] = true
-
- DeprecationToolkit::Configuration.test_runner = :rspec
- DeprecationToolkit::Configuration.deprecation_path = 'deprecations'
- DeprecationToolkit::Configuration.warnings_treated_as_deprecation = [kwargs_warning]
- end
-end
diff --git a/qa/spec/scenario/template_spec.rb b/qa/spec/scenario/template_spec.rb
index 9800f92b306..56521cc13bc 100644
--- a/qa/spec/scenario/template_spec.rb
+++ b/qa/spec/scenario/template_spec.rb
@@ -1,35 +1,49 @@
# frozen_string_literal: true
RSpec.describe QA::Scenario::Template do
- let(:feature) { spy('Runtime::Feature') }
- let(:release) { spy('Runtime::Release') }
+ let(:release) { spy('QA::Runtime::Release') } # rubocop:disable RSpec/VerifiedDoubles
+ let(:feature) { class_spy('QA::Runtime::Feature') }
+ let(:scenario) { class_spy('QA::Runtime::Scenario') }
+ let(:runner) { class_spy('QA::Specs::Runner') }
+
let(:gitlab_address) { 'https://gitlab.com/' }
+ let(:gitlab_address_from_env) { 'https://staging.gitlab.com/' }
before do
stub_const('QA::Runtime::Release', release)
stub_const('QA::Runtime::Feature', feature)
- allow(QA::Specs::Runner).to receive(:perform)
- allow(QA::Runtime::Address).to receive(:valid?).and_return(true)
+ stub_const('QA::Runtime::Scenario', scenario)
+ stub_const('QA::Specs::Runner', runner)
+
+ allow(QA::Runtime::Env).to receive(:knapsack?).and_return(false)
+ allow(QA::Runtime::Env).to receive(:gitlab_url).and_return(gitlab_address_from_env)
+
+ allow(QA::Runtime::Browser).to receive(:configure!)
+
+ allow(scenario).to receive(:attributes).and_return({ gitlab_address: gitlab_address })
+ allow(scenario).to receive(:define)
+
+ QA::Support::GitlabAddress.instance_variable_set(:@initialized, false)
end
it 'allows a feature to be enabled' do
subject.perform({ gitlab_address: gitlab_address, enable_feature: 'a-feature' })
expect(feature).to have_received(:enable).with('a-feature')
+ expect(feature).to have_received(:disable).with('a-feature')
end
it 'allows a feature to be disabled' do
- allow(QA::Runtime::Feature).to receive(:enabled?)
- .with('another-feature').and_return(true)
+ allow(QA::Runtime::Feature).to receive(:enabled?).with('another-feature').and_return(true)
subject.perform({ gitlab_address: gitlab_address, disable_feature: 'another-feature' })
expect(feature).to have_received(:disable).with('another-feature')
+ expect(feature).to have_received(:enable).with('another-feature')
end
it 'does not disable a feature if already disabled' do
- allow(QA::Runtime::Feature).to receive(:enabled?)
- .with('another-feature').and_return(false)
+ allow(QA::Runtime::Feature).to receive(:enabled?).with('another-feature').and_return(false)
subject.perform({ gitlab_address: gitlab_address, disable_feature: 'another-feature' })
@@ -39,7 +53,8 @@ RSpec.describe QA::Scenario::Template do
it 'ensures an enabled feature is disabled afterwards' do
allow(QA::Specs::Runner).to receive(:perform).and_raise('failed test')
- expect { subject.perform({ gitlab_address: gitlab_address, enable_feature: 'a-feature' }) }.to raise_error('failed test')
+ expect { subject.perform({ gitlab_address: gitlab_address, enable_feature: 'a-feature' }) }
+ .to raise_error('failed test')
expect(feature).to have_received(:enable).with('a-feature')
expect(feature).to have_received(:disable).with('a-feature')
@@ -47,11 +62,10 @@ RSpec.describe QA::Scenario::Template do
it 'ensures a disabled feature is enabled afterwards' do
allow(QA::Specs::Runner).to receive(:perform).and_raise('failed test')
+ allow(QA::Runtime::Feature).to receive(:enabled?).with('another-feature').and_return(true)
- allow(QA::Runtime::Feature).to receive(:enabled?)
- .with('another-feature').and_return(true)
-
- expect { subject.perform({ gitlab_address: gitlab_address, disable_feature: 'another-feature' }) }.to raise_error('failed test')
+ expect { subject.perform({ gitlab_address: gitlab_address, disable_feature: 'another-feature' }) }
+ .to raise_error('failed test')
expect(feature).to have_received(:disable).with('another-feature')
expect(feature).to have_received(:enable).with('another-feature')
@@ -59,25 +73,35 @@ RSpec.describe QA::Scenario::Template do
it 'ensures a disabled feature is not enabled afterwards if it was disabled earlier' do
allow(QA::Specs::Runner).to receive(:perform).and_raise('failed test')
+ allow(QA::Runtime::Feature).to receive(:enabled?).with('another-feature').and_return(false)
- allow(QA::Runtime::Feature).to receive(:enabled?)
- .with('another-feature').and_return(false)
-
- expect { subject.perform({ gitlab_address: gitlab_address, disable_feature: 'another-feature' }) }.to raise_error('failed test')
+ expect { subject.perform({ gitlab_address: gitlab_address, disable_feature: 'another-feature' }) }
+ .to raise_error('failed test')
expect(feature).not_to have_received(:disable).with('another-feature')
expect(feature).not_to have_received(:enable).with('another-feature')
end
- it 'defines an about address by default' do
- subject.perform( { gitlab_address: gitlab_address })
+ it 'defines gitlab address from positional argument' do
+ allow(scenario).to receive(:attributes).and_return({})
+
+ subject.perform({}, gitlab_address)
+
+ expect(scenario).to have_received(:define).with(:gitlab_address, gitlab_address)
+ expect(scenario).to have_received(:define).with(:about_address, 'https://about.gitlab.com/')
+ end
- expect(QA::Runtime::Scenario.gitlab_address).to eq(gitlab_address)
- expect(QA::Runtime::Scenario.about_address).to eq('https://about.gitlab.com/')
+ it "defaults to gitlab address from env" do
+ allow(scenario).to receive(:attributes).and_return({})
+
+ subject.perform({})
+
+ expect(scenario).to have_received(:define).with(:gitlab_address, gitlab_address_from_env)
+ end
- subject.perform({ gitlab_address: 'http://gitlab-abc.test/' })
+ it 'defines klass attribute' do
+ subject.perform({ gitlab_address: gitlab_address })
- expect(QA::Runtime::Scenario.gitlab_address).to eq('http://gitlab-abc.test/')
- expect(QA::Runtime::Scenario.about_address).to eq('http://about.gitlab-abc.test/')
+ expect(scenario).to have_received(:define).with(:klass, 'QA::Scenario::Template')
end
end
diff --git a/qa/spec/scenario/test/integration/mattermost_spec.rb b/qa/spec/scenario/test/integration/mattermost_spec.rb
index 9532ec35b95..4cdd0c0cb0e 100644
--- a/qa/spec/scenario/test/integration/mattermost_spec.rb
+++ b/qa/spec/scenario/test/integration/mattermost_spec.rb
@@ -3,24 +3,10 @@
RSpec.describe QA::Scenario::Test::Integration::Mattermost do
describe '#perform' do
it_behaves_like 'a QA scenario class' do
- let(:args) { %w[gitlab_address mattermost_address] }
- let(:args) do
- {
- gitlab_address: 'http://gitlab_address',
- mattermost_address: 'http://mattermost_address'
- }
- end
-
+ let(:args) { { gitlab_address: 'http://gitlab_address' } }
let(:named_options) { %w[--address http://gitlab_address --mattermost-address http://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, 'http://mattermost_address')
- end
+ let(:options) { ['path1'] }
end
end
end
diff --git a/qa/spec/specs/scenario_shared_examples.rb b/qa/spec/scenario_shared_examples.rb
index 7d806d50d21..944e309c4cb 100644
--- a/qa/spec/specs/scenario_shared_examples.rb
+++ b/qa/spec/scenario_shared_examples.rb
@@ -2,7 +2,7 @@
module QA
RSpec.shared_examples 'a QA scenario class' do
- let(:attributes) { class_spy('Runtime::Scenario') }
+ let(:scenario) { class_spy('Runtime::Scenario') }
let(:runner) { class_spy('Specs::Runner') }
let(:release) { class_spy('Runtime::Release') }
let(:feature) { class_spy('Runtime::Feature') }
@@ -15,24 +15,19 @@ module QA
before do
stub_const('QA::Specs::Runner', runner)
stub_const('QA::Runtime::Release', release)
- stub_const('QA::Runtime::Scenario', attributes)
+ stub_const('QA::Runtime::Scenario', scenario)
stub_const('QA::Runtime::Feature', feature)
- allow(attributes).to receive(:gitlab_address).and_return(args[:gitlab_address])
+ allow(QA::Runtime::Browser).to receive(:configure!)
+
+ allow(scenario).to receive(:attributes).and_return(args)
allow(runner).to receive(:perform).and_yield(runner)
- allow(QA::Runtime::Address).to receive(:valid?).and_return(true)
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, 'http://gitlab_address').at_least(:once)
- end
-
it 'performs before hooks only once' do
subject.perform(args)
@@ -58,7 +53,7 @@ module QA
described_class.launch!(named_options)
args do |k, v|
- expect(attributes).to have_received(:define).with(k, v)
+ expect(scenario).to have_received(:define).with(k, v)
end
end
@@ -67,7 +62,7 @@ module QA
end
it 'passes on options after --' do
- expect(described_class).to receive(:perform).with(attributes, *%w[--tag quarantine])
+ expect(described_class).to receive(:perform).with(args, *%w[--tag quarantine])
described_class.launch!(named_options.push(*%w[-- --tag quarantine]))
end
diff --git a/qa/spec/spec_helper.rb b/qa/spec/spec_helper.rb
index b81c41bb79c..95970800a4e 100644
--- a/qa/spec/spec_helper.rb
+++ b/qa/spec/spec_helper.rb
@@ -2,134 +2,4 @@
require_relative '../qa'
-require_relative 'qa_deprecation_toolkit_env'
-QaDeprecationToolkitEnv.configure!
-
-Knapsack::Adapters::RSpecAdapter.bind if QA::Runtime::Env.knapsack?
-
-QA::Runtime::Browser.configure! unless QA::Runtime::Env.dry_run
-QA::Runtime::AllureReport.configure!
-QA::Runtime::Scenario.from_env(QA::Runtime::Env.runtime_scenario_attributes)
-
-Dir[::File.join(__dir__, "support/shared_examples/*.rb")].sort.each { |f| require f }
-Dir[::File.join(__dir__, "support/shared_contexts/*.rb")].sort.each { |f| require f }
-
-RSpec.configure do |config|
- config.include QA::Support::Matchers::EventuallyMatcher
- config.include QA::Support::Matchers::HaveMatcher
-
- config.add_formatter QA::Support::Formatters::ContextFormatter
- config.add_formatter QA::Support::Formatters::QuarantineFormatter
- config.add_formatter QA::Support::Formatters::FeatureFlagFormatter
- config.add_formatter QA::Support::Formatters::TestStatsFormatter if QA::Runtime::Env.export_metrics?
-
- config.before(:suite) do |suite|
- QA::Resource::ReusableCollection.register_resource_classes do |collection|
- QA::Resource::ReusableProject.register(collection)
- QA::Resource::ReusableGroup.register(collection)
- end
- end
-
- config.prepend_before do |example|
- QA::Runtime::Logger.info("Starting test: #{Rainbow(example.full_description).bright}")
- QA::Runtime::Example.current = example
-
- # Reset fabrication counters tracked in resource base
- Thread.current[:api_fabrication] = 0
- Thread.current[:browser_ui_fabrication] = 0
- end
-
- config.after do
- # If a .netrc file was created during the test, delete it so that subsequent tests don't try to use the same logins
- QA::Git::Repository.new.delete_netrc
- end
-
- # Add fabrication time to spec metadata
- config.append_after do |example|
- example.metadata[:api_fabrication] = Thread.current[:api_fabrication]
- example.metadata[:browser_ui_fabrication] = Thread.current[:browser_ui_fabrication]
- end
-
- config.after(:context) do
- if !QA::Runtime::Browser.blank_page? && QA::Page::Main::Menu.perform(&:signed_in?)
- QA::Page::Main::Menu.perform(&:sign_out)
- raise(
- <<~ERROR
- The test left the browser signed in.
-
- Usually, Capybara prevents this from happening but some things can
- interfere. For example, if it has an `after(:context)` block that logs
- in, the browser will stay logged in and this will cause the next test
- to fail.
-
- Please make sure the test does not leave the browser signed in.
- ERROR
- )
- end
- end
-
- config.after(:suite) do |suite|
- # Write all test created resources to JSON file
- QA::Tools::TestResourceDataProcessor.write_to_file(suite.reporter.failed_examples.any?)
-
- # If requested, confirm that resources were used appropriately (e.g., not left with changes that interfere with
- # further reuse)
- QA::Resource::ReusableCollection.validate_resource_reuse if QA::Runtime::Env.validate_resource_reuse?
-
- # If any tests failed, leave the resources behind to help troubleshoot, otherwise remove them.
- # Do not remove the shared resource on live environments
- begin
- next if suite.reporter.failed_examples.present?
- next unless QA::Runtime::Scenario.attributes.include?(:gitlab_address)
- next if QA::Runtime::Env.running_on_dot_com?
-
- QA::Resource::ReusableCollection.remove_all_via_api!
- rescue QA::Resource::Errors::InternalServerError => e
- # Temporarily prevent this error from failing jobs while the cause is investigated
- # See https://gitlab.com/gitlab-org/gitlab/-/issues/354387
- QA::Runtime::Logger.debug(e.message)
- end
- end
-
- config.append_after(:suite) do
- QA::Tools::KnapsackReport.move_regenerated_report if QA::Runtime::Env.knapsack?
- end
-
- config.expect_with :rspec do |expectations|
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
- end
-
- config.mock_with :rspec do |mocks|
- mocks.verify_partial_doubles = true
- end
-
- config.shared_context_metadata_behavior = :apply_to_host_groups
- config.disable_monkey_patching!
- config.expose_dsl_globally = true
- config.profile_examples = 10
- config.order = :random
- Kernel.srand config.seed
-
- # show retry status in spec process
- config.verbose_retry = true
-
- # show exception that triggers a retry if verbose_retry is set to true
- config.display_try_failure_messages = true
-
- # This option allows to use shorthand aliases for adding :focus metadata - fit, fdescribe and fcontext
- config.filter_run_when_matching :focus
-
- if ENV['CI'] && !QA::Runtime::Env.disable_rspec_retry?
- non_quarantine_retries = QA::Runtime::Env.ci_project_name =~ /staging|canary|production/ ? 3 : 2
- config.around do |example|
- quarantine = example.metadata[:quarantine]
- different_quarantine_context = QA::Specs::Helpers::Quarantine.quarantined_different_context?(quarantine)
- focused_quarantine = QA::Specs::Helpers::Quarantine.filters.key?(:quarantine)
-
- # Do not disable retry when spec is quarantined but on different environment
- next example.run_with_retry(retry: non_quarantine_retries) if different_quarantine_context && !focused_quarantine
-
- example.run_with_retry(retry: quarantine ? 1 : non_quarantine_retries)
- end
- end
-end
+require_relative 'scenario_shared_examples'
diff --git a/qa/spec/specs/spec_helper.rb b/qa/spec/specs/spec_helper.rb
deleted file mode 100644
index e4514c6c64f..00000000000
--- a/qa/spec/specs/spec_helper.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-
-require_relative '../../qa'
-
-require_relative 'scenario_shared_examples'
diff --git a/qa/spec/support/shared_contexts/merge_train_spec_with_user_prep.rb b/qa/spec/support/shared_contexts/merge_train_spec_with_user_prep.rb
deleted file mode 100644
index 9d1a37cb0b8..00000000000
--- a/qa/spec/support/shared_contexts/merge_train_spec_with_user_prep.rb
+++ /dev/null
@@ -1,88 +0,0 @@
-# frozen_string_literal: true
-
-module QA
- RSpec.shared_context 'merge train spec with user prep' do
- let(:executor) { "qa-runner-#{Faker::Alphanumeric.alphanumeric(number: 8)}" }
- let(:file_name) { Faker::Lorem.word }
- let(:mr_title) { Faker::Lorem.sentence }
- let(:admin_api_client) { Runtime::API::Client.as_admin }
-
- let(:user) do
- Resource::User.fabricate_via_api! do |user|
- user.api_client = admin_api_client
- end
- end
-
- let(:project) do
- Resource::Project.fabricate_via_api! do |project|
- project.name = 'pipeline-for-merge-trains'
- end
- end
-
- let!(:runner) do
- Resource::Runner.fabricate! do |runner|
- runner.project = project
- runner.name = executor
- runner.tags = [executor]
- end
- end
-
- let!(:project_files) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add .gitlab-ci.yml'
- commit.add_files(
- [
- {
- file_path: '.gitlab-ci.yml',
- content: <<~YAML
- test_merge_train:
- tags:
- - #{executor}
- script:
- - sleep 10
- - echo 'OK!'
- only:
- - merge_requests
- YAML
- },
- {
- file_path: file_name,
- content: Faker::Lorem.sentence
- }
- ]
- )
- end
- end
-
- before do
- project.add_member(user, Resource::Members::AccessLevel::MAINTAINER)
-
- Flow::Login.sign_in
- project.visit!
- Flow::MergeRequest.enable_merge_trains
-
- Flow::Login.sign_in(as: user)
-
- Resource::MergeRequest.fabricate_via_api! do |merge_request|
- merge_request.title = mr_title
- merge_request.project = project
- merge_request.description = Faker::Lorem.sentence
- merge_request.target_new_branch = false
- merge_request.update_existing_file = true
- merge_request.file_name = file_name
- merge_request.file_content = Faker::Lorem.sentence
- end.visit!
-
- Page::MergeRequest::Show.perform do |show|
- show.has_pipeline_status?('passed')
- show.try_to_merge!
- end
- end
-
- after do
- runner&.remove_via_api!
- user&.remove_via_api!
- end
- end
-end
diff --git a/qa/spec/support/shared_contexts/packages_registry_shared_context.rb b/qa/spec/support/shared_contexts/packages_registry_shared_context.rb
deleted file mode 100644
index 73a6c2bd99e..00000000000
--- a/qa/spec/support/shared_contexts/packages_registry_shared_context.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-# frozen_string_literal: true
-
-module QA
- RSpec.shared_context 'packages registry qa scenario' do
- let(:personal_access_token) { Runtime::Env.personal_access_token }
-
- let(:package_project) do
- Resource::Project.fabricate_via_api! do |project|
- project.name = "#{package_type}_package_project"
- project.initialize_with_readme = true
- project.visibility = :private
- end
- end
-
- let(:client_project) do
- Resource::Project.fabricate_via_api! do |client_project|
- client_project.name = "#{package_type}_client_project"
- client_project.initialize_with_readme = true
- client_project.group = package_project.group
- end
- end
-
- let(:package) do
- Resource::Package.init do |package|
- package.name = package_name
- package.project = package_project
- end
- end
-
- let(:runner) do
- Resource::Runner.fabricate! do |runner|
- runner.name = "qa-runner-#{Time.now.to_i}"
- runner.tags = ["runner-for-#{package_project.group.name}"]
- runner.executor = :docker
- runner.token = package_project.group.reload!.runners_token
- end
- end
-
- let(:gitlab_address_with_port) do
- uri = URI.parse(Runtime::Scenario.gitlab_address)
- "#{uri.scheme}://#{uri.host}:#{uri.port}"
- end
-
- let(:project_deploy_token) do
- Resource::ProjectDeployToken.fabricate_via_api! do |deploy_token|
- deploy_token.name = 'package-deploy-token'
- deploy_token.project = package_project
- deploy_token.scopes = %w[
- read_repository
- read_package_registry
- write_package_registry
- ]
- end
- end
-
- before do
- Flow::Login.sign_in_unless_signed_in
- runner
- end
-
- after do
- runner.remove_via_api!
- package.remove_via_api!
- package_project.remove_via_api!
- client_project.remove_via_api!
- end
- end
-end
diff --git a/qa/spec/support/shared_contexts/variable_inheritance_shared_context.rb b/qa/spec/support/shared_contexts/variable_inheritance_shared_context.rb
deleted file mode 100644
index 1dc8870d4d9..00000000000
--- a/qa/spec/support/shared_contexts/variable_inheritance_shared_context.rb
+++ /dev/null
@@ -1,150 +0,0 @@
-# frozen_string_literal: true
-
-module QA
- RSpec.shared_context 'variable inheritance test prep' do
- let(:random_string) { Faker::Alphanumeric.alphanumeric(number: 8) }
-
- let(:group) do
- Resource::Group.fabricate_via_api! do |group|
- group.path = "group-for-variable-inheritance-#{random_string}"
- end
- end
-
- let(:upstream_project) do
- Resource::Project.fabricate_via_api! do |project|
- project.group = group
- project.name = 'upstream-variable-inheritance'
- project.description = 'Project for pipeline with variable defined via UI - Upstream'
- end
- end
-
- let(:downstream1_project) do
- Resource::Project.fabricate_via_api! do |project|
- project.group = group
- project.name = 'downstream1-variable-inheritance'
- project.description = 'Project for pipeline with variable defined via UI - Downstream'
- end
- end
-
- let(:downstream2_project) do
- Resource::Project.fabricate_via_api! do |project|
- project.group = group
- project.name = 'downstream2-variable-inheritance'
- project.description = 'Project for pipeline with variable defined via UI - Downstream'
- end
- end
-
- let!(:runner) do
- Resource::Runner.fabricate! do |runner|
- runner.token = group.reload!.runners_token
- runner.name = random_string
- runner.tags = [random_string]
- end
- end
-
- before do
- Runtime::Feature.enable(:ci_trigger_forward_variables)
- Flow::Login.sign_in
- end
-
- after do
- runner.remove_via_api!
- Runtime::Feature.disable(:ci_trigger_forward_variables)
- end
-
- def start_pipeline_with_variable
- upstream_project.visit!
- Flow::Pipeline.wait_for_latest_pipeline
- Page::Project::Pipeline::Index.perform(&:click_run_pipeline_button)
- Page::Project::Pipeline::New.perform do |new|
- new.add_variable('TEST_VAR', 'This is great!')
- new.click_run_pipeline_button
- end
- end
-
- def add_ci_file(project, files)
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add CI config file'
- commit.add_files(files)
- end
- end
-
- def visit_job_page(pipeline_title, job_name)
- Page::Project::Pipeline::Show.perform do |show|
- show.expand_child_pipeline(title: pipeline_title)
- show.click_job(job_name)
- end
- end
-
- def verify_job_log_shows_variable_value
- Page::Project::Job::Show.perform do |show|
- show.wait_until { show.successful? }
- expect(show.output).to have_content('This is great!')
- end
- end
-
- def verify_job_log_does_not_show_variable_value
- Page::Project::Job::Show.perform do |show|
- show.wait_until { show.successful? }
- expect(show.output).to have_no_content('This is great!')
- end
- end
-
- def upstream_child1_ci_file
- {
- file_path: '.child1-ci.yml',
- content: <<~YAML
- child1_job:
- stage: test
- tags: ["#{random_string}"]
- script:
- - echo $TEST_VAR
- - echo Done!
- YAML
- }
- end
-
- def upstream_child2_ci_file
- {
- file_path: '.child2-ci.yml',
- content: <<~YAML
- child2_job:
- stage: test
- tags: ["#{random_string}"]
- script:
- - echo $TEST_VAR
- - echo Done!
- YAML
- }
- end
-
- def downstream1_ci_file
- {
- file_path: '.gitlab-ci.yml',
- content: <<~YAML
- downstream1_job:
- stage: deploy
- tags: ["#{random_string}"]
- script:
- - echo $TEST_VAR
- - echo Done!
- YAML
- }
- end
-
- def downstream2_ci_file
- {
- file_path: '.gitlab-ci.yml',
- content: <<~YAML
- downstream2_job:
- stage: deploy
- tags: ["#{random_string}"]
- script:
- - echo $TEST_VAR
- - echo Done!
- YAML
- }
- end
- end
-end
diff --git a/qa/spec/support/shared_examples/merge_with_code_owner_shared_examples.rb b/qa/spec/support/shared_examples/merge_with_code_owner_shared_examples.rb
deleted file mode 100644
index 4bbad9bf3e5..00000000000
--- a/qa/spec/support/shared_examples/merge_with_code_owner_shared_examples.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-# frozen_string_literal: true
-
-module QA
- RSpec.shared_examples 'code owner merge request' do
- let(:branch_name) { 'new-branch' }
-
- it 'is approved and merged' do
- # Require one approval from any eligible user on any branch
- # This will confirm that this type of unrestricted approval is
- # also satisfied when a code owner grants approval
- Page::Project::Menu.perform(&:go_to_general_settings)
- Page::Project::Settings::Main.perform do |main|
- main.expand_merge_request_approvals_settings do |settings|
- settings.set_default_number_of_approvals_required(1)
- end
- end
-
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add CODEOWNERS'
- commit.add_files(
- [
- {
- file_path: 'CODEOWNERS',
- content: <<~CONTENT
- README.md @#{codeowner}
- CONTENT
- }
- ]
- )
- end
-
- # Require approval from code owners on the default branch
- protected_branch = Resource::ProtectedBranch.fabricate_via_api! do |branch|
- branch.project = project
- branch.branch_name = project.default_branch
- branch.new_branch = false
- branch.require_code_owner_approval = true
- end
- protected_branch.set_require_code_owner_approval
-
- # Push a change to the file with a CODEOWNERS rule
- Resource::Repository::Push.fabricate! do |push|
- push.repository_http_uri = project.repository_http_location.uri
- push.branch_name = branch_name
- push.file_name = 'README.md'
- push.file_content = 'Updated'
- end
-
- merge_request = Resource::MergeRequest.fabricate! do |merge_request|
- merge_request.project = project
- merge_request.target_new_branch = false
- merge_request.source_branch = branch_name
- merge_request.no_preparation = true
- end
-
- Flow::Login.while_signed_in(as: approver) do
- merge_request.visit!
-
- Page::MergeRequest::Show.perform do |merge_request|
- expect(merge_request.approvals_required_from).to include('Code Owners')
- expect(merge_request).not_to be_mergeable
-
- merge_request.click_approve
- merge_request.merge!
-
- expect(merge_request).to be_merged
- end
- end
- end
- end
-end