summaryrefslogtreecommitdiff
path: root/qa/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-03-16 18:18:33 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-03-16 18:18:33 +0000
commitf64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch)
treea2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /qa/spec
parentbfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff)
downloadgitlab-ce-f64a639bcfa1fc2bc89ca7db268f594306edfd7c.tar.gz
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'qa/spec')
-rw-r--r--qa/spec/runtime/api/client_spec.rb2
-rw-r--r--qa/spec/runtime/env_spec.rb1
-rw-r--r--qa/spec/specs/helpers/quarantine_spec.rb73
-rw-r--r--qa/spec/support/matchers/have_matcher.rb1
-rw-r--r--qa/spec/support/ssh_spec.rb22
5 files changed, 73 insertions, 26 deletions
diff --git a/qa/spec/runtime/api/client_spec.rb b/qa/spec/runtime/api/client_spec.rb
index dd139fda980..36ee563de39 100644
--- a/qa/spec/runtime/api/client_spec.rb
+++ b/qa/spec/runtime/api/client_spec.rb
@@ -60,7 +60,7 @@ RSpec.describe QA::Runtime::API::Client do
end
it 'returns a created token' do
- client = described_class.new(user: { username: 'foo' })
+ client = described_class.new(user: Struct.new(:username, :admin?).new('foo', false))
expect(client).to receive(:create_personal_access_token).and_return('created_token')
diff --git a/qa/spec/runtime/env_spec.rb b/qa/spec/runtime/env_spec.rb
index 3396ae6f0b8..5a98721466f 100644
--- a/qa/spec/runtime/env_spec.rb
+++ b/qa/spec/runtime/env_spec.rb
@@ -232,6 +232,7 @@ RSpec.describe QA::Runtime::Env do
describe '.require_admin_access_token!' do
it 'raises ArgumentError if GITLAB_QA_ADMIN_ACCESS_TOKEN is not specified' do
+ described_class.instance_variable_set(:@admin_personal_access_token, nil)
stub_env('GITLAB_QA_ADMIN_ACCESS_TOKEN', nil)
expect { described_class.require_admin_access_token! }.to raise_error(ArgumentError)
diff --git a/qa/spec/specs/helpers/quarantine_spec.rb b/qa/spec/specs/helpers/quarantine_spec.rb
index 80fd65faeed..694c320ce3d 100644
--- a/qa/spec/specs/helpers/quarantine_spec.rb
+++ b/qa/spec/specs/helpers/quarantine_spec.rb
@@ -15,7 +15,7 @@ end
# expanding into the global state
# See: https://github.com/rspec/rspec-core/issues/2603
def describe_successfully(*args, &describe_body)
- example_group = RSpec.describe(*args, &describe_body)
+ example_group = RSpec.describe(*args, &describe_body)
ran_successfully = example_group.run RaiseOnFailuresReporter
expect(ran_successfully).to eq true
example_group
@@ -156,28 +156,51 @@ RSpec.describe QA::Specs::Helpers::Quarantine do
described_class.configure_rspec
end
- it 'is skipped when set on contexts or descriptions' do
- group = describe_successfully 'Quarantined in staging', quarantine: { only: { subdomain: :staging } } do
- it('runs in staging') {}
+ context 'no pipeline specified' do
+ it 'is skipped when set on contexts or descriptions' do
+ group = describe_successfully 'Quarantined in staging', quarantine: { only: { subdomain: :staging } } do
+ it('runs in staging') {}
+ end
+
+ expect(group.examples.first.execution_result.status).to eq(:pending)
+ expect(group.examples.first.execution_result.pending_message)
+ .to eq('In quarantine')
end
- expect(group.examples.first.execution_result.status).to eq(:pending)
- expect(group.examples.first.execution_result.pending_message)
- .to eq('In quarantine')
+ it 'is skipped only in staging' do
+ group = describe_successfully do
+ it('skipped in staging', quarantine: { only: { subdomain: :staging } }) {}
+ it('runs in staging', quarantine: { only: :production }) {}
+ it('skipped in staging also', quarantine: { only: { subdomain: %i[release staging] } }) {}
+ it('runs in any env') {}
+ end
+
+ expect(group.examples[0].execution_result.status).to eq(:pending)
+ expect(group.examples[1].execution_result.status).to eq(:passed)
+ expect(group.examples[2].execution_result.status).to eq(:pending)
+ expect(group.examples[3].execution_result.status).to eq(:passed)
+ end
end
- it 'is skipped only in staging' do
- group = describe_successfully do
- it('skipped in staging', quarantine: { only: { subdomain: :staging } }) {}
- it('runs in staging', quarantine: { only: :production }) {}
- it('skipped in staging also', quarantine: { only: { subdomain: %i[release staging] } }) {}
- it('runs in any env') {}
+ context 'multiple pipelines specified' do
+ shared_examples 'skipped in project' do |project|
+ before do
+ stub_env('CI_PROJECT_NAME', project)
+ described_class.configure_rspec
+ end
+
+ it "is skipped in #{project}" do
+ group = describe_successfully do
+ it('does not run in specified projects', quarantine: { only: { pipeline: [:staging, :canary, :production] } }) {}
+ end
+
+ expect(group.examples[0].execution_result.status).to eq(:pending)
+ end
end
- expect(group.examples[0].execution_result.status).to eq(:pending)
- expect(group.examples[1].execution_result.status).to eq(:passed)
- expect(group.examples[2].execution_result.status).to eq(:pending)
- expect(group.examples[3].execution_result.status).to eq(:passed)
+ it_behaves_like 'skipped in project', 'STAGING'
+ it_behaves_like 'skipped in project', 'CANARY'
+ it_behaves_like 'skipped in project', 'PRODUCTION'
end
end
@@ -368,8 +391,8 @@ RSpec.describe QA::Specs::Helpers::Quarantine do
it 'runs on a custom environment' do
group = describe_successfully do
- it('runs on release gitlab net', only: { tld: '.net', subdomain: :release, domain: 'gitlab' } ) {}
- it('does not run on release', only: :production ) {}
+ it('runs on release gitlab net', only: { tld: '.net', subdomain: :release, domain: 'gitlab' }) {}
+ it('does not run on release', only: :production) {}
end
expect(group.examples.first.execution_result.status).to eq(:passed)
@@ -384,7 +407,7 @@ RSpec.describe QA::Specs::Helpers::Quarantine do
it 'runs on production' do
group = describe_successfully do
- it('runs on prod', only: :production ) {}
+ it('runs on prod', only: :production) {}
it('does not run in prod', only: { subdomain: :staging }) {}
it('runs in prod and staging', only: { subdomain: /(staging.)?/, domain: 'gitlab' }) {}
end
@@ -412,7 +435,7 @@ RSpec.describe QA::Specs::Helpers::Quarantine do
it 'runs on any pipeline' do
group = describe_successfully do
- it('runs given a single named pipeline', only: { pipeline: :nightly } ) {}
+ it('runs given a single named pipeline', only: { pipeline: :nightly }) {}
it('runs given an array of pipelines', only: { pipeline: [:canary, :not_nightly] }) {}
end
@@ -431,9 +454,9 @@ RSpec.describe QA::Specs::Helpers::Quarantine do
it 'runs on default branch pipelines' do
group = describe_successfully do
- it('runs on master pipeline given a single pipeline', only: { pipeline: :master } ) {}
+ it('runs on master pipeline given a single pipeline', only: { pipeline: :master }) {}
it('runs in master given an array of pipelines', only: { pipeline: [:canary, :master] }) {}
- it('does not run in non-default pipelines', only: { pipeline: [:nightly, :not_nightly, :not_master] } ) {}
+ it('does not run in non-default pipelines', only: { pipeline: [:nightly, :not_nightly, :not_master] }) {}
end
aggregate_failures do
@@ -452,8 +475,8 @@ RSpec.describe QA::Specs::Helpers::Quarantine do
it 'runs on designated pipeline' do
group = describe_successfully do
- it('runs on nightly', only: { pipeline: :nightly } ) {}
- it('does not run in not_nightly', only: { pipeline: :not_nightly } ) {}
+ it('runs on nightly', only: { pipeline: :nightly }) {}
+ it('does not run in not_nightly', only: { pipeline: :not_nightly }) {}
it('runs on nightly given an array', only: { pipeline: [:canary, :nightly] }) {}
it('does not run in not_nightly given an array', only: { pipeline: [:not_nightly, :canary] }) {}
end
diff --git a/qa/spec/support/matchers/have_matcher.rb b/qa/spec/support/matchers/have_matcher.rb
index 43ae27f8796..81288b97e6f 100644
--- a/qa/spec/support/matchers/have_matcher.rb
+++ b/qa/spec/support/matchers/have_matcher.rb
@@ -15,6 +15,7 @@ module Matchers
pipeline
related_issue_item
snippet_description
+ tag
].each do |predicate|
RSpec::Matchers.define "have_#{predicate}" do |*args, **kwargs|
match do |page_object|
diff --git a/qa/spec/support/ssh_spec.rb b/qa/spec/support/ssh_spec.rb
index f4d382f8adc..2edff824fd6 100644
--- a/qa/spec/support/ssh_spec.rb
+++ b/qa/spec/support/ssh_spec.rb
@@ -26,6 +26,16 @@ RSpec.describe QA::Support::SSH do
end
end
+ context 'when no port specified in https uri' do
+ let(:uri) { 'https://foo.com' }
+
+ it 'does not provide port in ssh command' do
+ expect(ssh).to receive(:run).with(expected_ssh_command_no_port, any_args).and_return(result)
+
+ call_method
+ end
+ end
+
context 'when port 80 specified in uri' do
let(:uri) { 'http://foo.com:80' }
@@ -86,6 +96,18 @@ RSpec.describe QA::Support::SSH do
end
end
+ context 'when running on a review app in CI' do
+ let(:uri) { 'https://gitlab-review.app' }
+
+ before do
+ allow(QA::Runtime::Env).to receive(:running_in_ci?).and_return(true)
+ end
+
+ it 'returns git user' do
+ expect(ssh.send(:git_user)).to eq('git')
+ end
+ end
+
context 'when running against environment on a port other than 80 or 443' do
let(:uri) { 'http://localhost:3000' }