Commit 33d4e176 authored by Dan Davison's avatar Dan Davison Committed by Mark Lapierre

Disable monkey patching globally for QA tests

Fix all remaining occurrences of monkey patching
parent 3bb8e20d
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
context 'Manage', :requires_admin, :skip_live_env do RSpec.describe 'Manage', :requires_admin, :skip_live_env do
describe '2FA' do describe '2FA' do
let(:owner_user) do let(:owner_user) do
Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_2fa_owner_username_1, Runtime::Env.gitlab_qa_2fa_owner_password_1) Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_2fa_owner_username_1, Runtime::Env.gitlab_qa_2fa_owner_password_1)
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
context 'Manage', :requires_admin, :skip_live_env do RSpec.describe 'Manage', :requires_admin, :skip_live_env do
describe '2FA' do describe '2FA' do
let(:owner_user) do let(:owner_user) do
Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_2fa_owner_username_1, Runtime::Env.gitlab_qa_2fa_owner_password_1) Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_2fa_owner_username_1, Runtime::Env.gitlab_qa_2fa_owner_password_1)
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
context 'Create' do RSpec.describe 'Create' do
describe 'Contribution Analytics' do describe 'Contribution Analytics' do
let(:group) do let(:group) do
Resource::Group.fabricate_via_api! do |group| Resource::Group.fabricate_via_api! do |group|
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'securerandom' require 'securerandom'
module QA module QA
context 'Create', :requires_admin, :skip_live_env, quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/195179', type: :flaky } do RSpec.describe 'Create', :requires_admin, :skip_live_env, quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/195179', type: :flaky } do
describe 'Jenkins integration' do describe 'Jenkins integration' do
let(:project_name) { "project_with_jenkins_#{SecureRandom.hex(4)}" } let(:project_name) { "project_with_jenkins_#{SecureRandom.hex(4)}" }
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
context 'Create' do RSpec.describe 'Create' do
describe 'batch comments in merge request' do describe 'batch comments in merge request' do
let(:project) do let(:project) do
Resource::Project.fabricate_via_api! do |project| Resource::Project.fabricate_via_api! do |project|
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
context 'Create' do RSpec.describe 'Create' do
describe 'Approval rules', quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/225595', type: :investigating } do describe 'Approval rules', quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/225595', type: :investigating } do
let(:approver1) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1) } let(:approver1) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1) }
let(:approver2) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_2, Runtime::Env.gitlab_qa_password_2) } let(:approver2) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_2, Runtime::Env.gitlab_qa_password_2) }
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
context 'Create' do RSpec.describe 'Create' do
describe 'Codeowners' do describe 'Codeowners' do
# Create one user to be the assigned approver and another user who will not be an approver # Create one user to be the assigned approver and another user who will not be an approver
let(:approver) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1) } let(:approver) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1) }
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
context 'Create' do RSpec.describe 'Create' do
describe 'Codeowners' do describe 'Codeowners' do
let(:files) do let(:files) do
[ [
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
context 'Create' do RSpec.describe 'Create' do
describe 'File Locking' do describe 'File Locking' do
before do before do
Flow::Login.sign_in Flow::Login.sign_in
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
context 'Create' do RSpec.describe 'Create' do
describe 'Codeowners' do describe 'Codeowners' do
context 'when the project is in the root group', :requires_admin do context 'when the project is in the root group', :requires_admin do
let(:approver) do let(:approver) do
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
context 'Create' do RSpec.describe 'Create' do
describe 'Codeowners' do describe 'Codeowners' do
context 'when the project is in a subgroup', :requires_admin do context 'when the project is in a subgroup', :requires_admin do
let(:approver) do let(:approver) do
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
context 'Create' do RSpec.describe 'Create' do
describe 'Pull mirror a repository over HTTP' do describe 'Pull mirror a repository over HTTP' do
it 'configures and syncs a (pull) mirrored repository with password auth', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/520' do it 'configures and syncs a (pull) mirrored repository with password auth', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/520' do
Flow::Login.sign_in Flow::Login.sign_in
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
context 'Create' do RSpec.describe 'Create' do
describe 'Pull mirror a repository over SSH with a private key' do describe 'Pull mirror a repository over SSH with a private key' do
let(:source) do let(:source) do
Resource::Repository::ProjectPush.fabricate! do |project_push| Resource::Repository::ProjectPush.fabricate! do |project_push|
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
context 'Create' do RSpec.describe 'Create' do
context 'Push Rules' do context 'Push Rules' do
describe 'using non signed commits' do describe 'using non signed commits' do
before(:context) do before(:context) do
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
context 'Create' do RSpec.describe 'Create' do
describe 'Restricted protected branch push and merge' do describe 'Restricted protected branch push and merge' do
let(:user_developer) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1) } let(:user_developer) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1) }
let(:user_maintainer) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_2, Runtime::Env.gitlab_qa_password_2) } let(:user_maintainer) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_2, Runtime::Env.gitlab_qa_password_2) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
module QA module QA
# This test was quarantined because relative URL isn't supported # This test was quarantined because relative URL isn't supported
# See https://gitlab.com/gitlab-org/gitlab/issues/13833 # See https://gitlab.com/gitlab-org/gitlab/issues/13833
context 'Create', :runner, :quarantine do RSpec.describe 'Create', :runner, :quarantine do
describe 'Web IDE web terminal' do describe 'Web IDE web terminal' do
before do before do
project = Resource::Project.fabricate_via_api! do |project| project = Resource::Project.fabricate_via_api! do |project|
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
describe Service::DockerRun::GitlabRunner do RSpec.describe Service::DockerRun::GitlabRunner do
let(:runner_name) { 'test-runner' } let(:runner_name) { 'test-runner' }
let(:address) { 'gitlab.test' } let(:address) { 'gitlab.test' }
let(:token) { 'abc123' } let(:token) { 'abc123' }
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
describe Service::DockerRun::K3s do RSpec.describe Service::DockerRun::K3s do
describe '#host_name' do describe '#host_name' do
context 'in CI' do context 'in CI' do
let(:name) { 'k3s-12345' } let(:name) { 'k3s-12345' }
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
shared_examples 'code owner merge request' do RSpec.shared_examples 'code owner merge request' do
let(:branch_name) { 'new-branch' } let(:branch_name) { 'new-branch' }
it 'is approved and merged' do it 'is approved and merged' do
......
# frozen_string_literal: true # frozen_string_literal: true
shared_examples 'a QA scenario class' do module QA
let(:attributes) { spy('Runtime::Scenario') } RSpec.shared_examples 'a QA scenario class' do
let(:runner) { spy('Specs::Runner') } let(:attributes) { spy('Runtime::Scenario') }
let(:release) { spy('Runtime::Release') } let(:runner) { spy('Specs::Runner') }
let(:feature) { spy('Runtime::Feature') } let(:release) { spy('Runtime::Release') }
let(:feature) { spy('Runtime::Feature') }
let(:args) { { gitlab_address: 'http://gitlab_address' } }
let(:named_options) { %w[--address http://gitlab_address] } let(:args) { { gitlab_address: 'http://gitlab_address' } }
let(:tags) { [] } let(:named_options) { %w[--address http://gitlab_address] }
let(:options) { %w[path1 path2] } let(:tags) { [] }
let(:options) { %w[path1 path2] }
before do
stub_const('QA::Specs::Runner', runner) before do
stub_const('QA::Runtime::Release', release) stub_const('QA::Specs::Runner', runner)
stub_const('QA::Runtime::Scenario', attributes) stub_const('QA::Runtime::Release', release)
stub_const('QA::Runtime::Feature', feature) stub_const('QA::Runtime::Scenario', attributes)
stub_const('QA::Runtime::Feature', feature)
allow(runner).to receive(:perform).and_yield(runner)
allow(QA::Runtime::Address).to receive(:valid?).and_return(true) allow(runner).to receive(:perform).and_yield(runner)
end allow(QA::Runtime::Address).to receive(:valid?).and_return(true)
end
it 'responds to perform' do it 'responds to perform' do
expect(subject).to respond_to(:perform) expect(subject).to respond_to(:perform)
end end
it 'sets an address of the subject' do it 'sets an address of the subject' do
subject.perform(args) subject.perform(args)
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 it 'performs before hooks only once' do
subject.perform(args) subject.perform(args)
expect(release).to have_received(:perform_before_hooks).once expect(release).to have_received(:perform_before_hooks).once
end end
it 'sets tags on runner' do it 'sets tags on runner' do
subject.perform(args) subject.perform(args)
expect(runner).to have_received(:tags=).with(tags) expect(runner).to have_received(:tags=).with(tags)
end end
context 'specifying RSpec options' do context 'specifying RSpec options' do
it 'sets options on runner' do it 'sets options on runner' do
subject.perform(args, *options) subject.perform(args, *options)
expect(runner).to have_received(:options=).with(options) expect(runner).to have_received(:options=).with(options)
end
end end
end
context 'with named command-line options' do context 'with named command-line options' do
it 'converts options to attributes' do it 'converts options to attributes' do
described_class.launch!(named_options) described_class.launch!(named_options)
args do |k, v| args do |k, v|
expect(attributes).to have_received(:define).with(k, v) expect(attributes).to have_received(:define).with(k, v)
end
end end
end
it 'raises an error if the option is invalid' do it 'raises an error if the option is invalid' do
expect { described_class.launch!(['--foo']) }.to raise_error(OptionParser::InvalidOption) expect { described_class.launch!(['--foo']) }.to raise_error(OptionParser::InvalidOption)
end end
it 'passes on options after --' do it 'passes on options after --' do
expect(described_class).to receive(:perform).with(attributes, *%w[--tag quarantine]) expect(described_class).to receive(:perform).with(attributes, *%w[--tag quarantine])
described_class.launch!(named_options.push(*%w[-- --tag quarantine])) described_class.launch!(named_options.push(*%w[-- --tag quarantine]))
end
end end
end end
end end
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