diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /qa/spec | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'qa/spec')
-rw-r--r-- | qa/spec/runtime/api/request_spec.rb | 6 | ||||
-rw-r--r-- | qa/spec/runtime/env_spec.rb | 42 | ||||
-rw-r--r-- | qa/spec/specs/helpers/quarantine_spec.rb | 123 |
3 files changed, 168 insertions, 3 deletions
diff --git a/qa/spec/runtime/api/request_spec.rb b/qa/spec/runtime/api/request_spec.rb index a20f1cf8559..8354eff6234 100644 --- a/qa/spec/runtime/api/request_spec.rb +++ b/qa/spec/runtime/api/request_spec.rb @@ -22,6 +22,12 @@ describe QA::Runtime::API::Request do end end + describe '#mask_url' do + it 'returns the full API request url with the token masked' do + expect(request.mask_url).to eq 'http://example.com/api/v4/users?private_token=[****]' + end + end + describe '#request_path' do it 'prepends the api path' do expect(request.request_path('/users')).to eq '/api/v4/users' diff --git a/qa/spec/runtime/env_spec.rb b/qa/spec/runtime/env_spec.rb index f2e5eb35871..0cfb9a70c88 100644 --- a/qa/spec/runtime/env_spec.rb +++ b/qa/spec/runtime/env_spec.rb @@ -341,7 +341,7 @@ describe QA::Runtime::Env do end end - describe '.dot_com?' do + describe '.address_matches?' do it 'returns true when url has .com' do QA::Runtime::Scenario.define(:gitlab_address, "https://staging.gitlab.com") @@ -351,7 +351,45 @@ describe QA::Runtime::Env do it 'returns false when url does not have .com' do QA::Runtime::Scenario.define(:gitlab_address, "https://gitlab.test") - expect(described_class.dot_com?).to be_falsy + expect(described_class.dot_com?).to be_falsey + end + + context 'with arguments' do + it 'returns true when :subdomain is set' do + QA::Runtime::Scenario.define(:gitlab_address, "https://staging.gitlab.com") + + expect(described_class.dot_com?(subdomain: :staging)).to be_truthy + end + + it 'matches multiple subdomains' do + QA::Runtime::Scenario.define(:gitlab_address, "https://staging.gitlab.com") + + expect(described_class.address_matches?(subdomain: [:release, :staging])).to be_truthy + expect(described_class.address_matches?(:production, subdomain: [:release, :staging])).to be_truthy + end + + it 'matches :production' do + QA::Runtime::Scenario.define(:gitlab_address, "https://gitlab.com/") + + expect(described_class.address_matches?(:production)).to be_truthy + end + + it 'doesnt match with mismatching switches' do + QA::Runtime::Scenario.define(:gitlab_address, 'https://gitlab.test') + + aggregate_failures do + expect(described_class.address_matches?(tld: '.net')).to be_falsey + expect(described_class.address_matches?(:production)).to be_falsey + expect(described_class.address_matches?(subdomain: [:staging])).to be_falsey + expect(described_class.address_matches?(domain: 'example')).to be_falsey + end + end + end + + it 'returns false for mismatching' do + QA::Runtime::Scenario.define(:gitlab_address, "https://staging.gitlab.com") + + expect(described_class.address_matches?(:production)).to be_falsey end end end diff --git a/qa/spec/specs/helpers/quarantine_spec.rb b/qa/spec/specs/helpers/quarantine_spec.rb index 1f09c3f73ac..9686a9771c4 100644 --- a/qa/spec/specs/helpers/quarantine_spec.rb +++ b/qa/spec/specs/helpers/quarantine_spec.rb @@ -124,7 +124,7 @@ describe QA::Specs::Helpers::Quarantine do end end - describe '.skip_or_run_quarantined_tests' do + describe '.skip_or_run_quarantined_tests_or_contexts' do context 'with no tag focused' do before do described_class.configure_rspec @@ -148,6 +148,37 @@ describe QA::Specs::Helpers::Quarantine do expect(group.examples.first.execution_result.status).to eq(:passed) end + context 'with environment set' do + before do + QA::Runtime::Scenario.define(:gitlab_address, 'https://staging.gitlab.com') + 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') {} + end + + expect(group.examples.first.execution_result.status).to eq(:pending) + expect(group.examples.first.execution_result.pending_message) + .to eq('In quarantine') + 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') {} + 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 + context 'quarantine message' do shared_examples 'test with quarantine message' do |quarantine_tag| it 'outputs the quarantine message' do @@ -280,4 +311,94 @@ describe QA::Specs::Helpers::Quarantine do end end end + + describe 'running against specific environments' do + before do + QA::Runtime::Scenario.define(:gitlab_address, 'https://staging.gitlab.com') + described_class.configure_rspec + end + + describe 'description and context blocks' do + context 'with environment set' do + it 'can apply to contexts or descriptions' do + group = describe_successfully 'Runs in staging', only: { subdomain: :staging } do + it('runs in staging') {} + end + + expect(group.examples[0].execution_result.status).to eq(:passed) + end + end + + context 'with different environment set' do + before do + QA::Runtime::Scenario.define(:gitlab_address, 'https://gitlab.com') + described_class.configure_rspec + end + + it 'does not run against production' do + group = describe_successfully 'Runs in staging', :something, only: { subdomain: :staging } do + it('runs in staging') {} + end + + expect(group.examples[0].execution_result.status).to eq(:pending) + end + end + end + + it 'runs only in staging' do + group = describe_successfully do + it('runs in staging', only: { subdomain: :staging }) {} + it('doesnt run in staging', only: :production) {} + it('runs in staging also', only: { subdomain: %i[release staging] }) {} + it('runs in any env') {} + end + + expect(group.examples[0].execution_result.status).to eq(:passed) + expect(group.examples[1].execution_result.status).to eq(:pending) + expect(group.examples[2].execution_result.status).to eq(:passed) + expect(group.examples[3].execution_result.status).to eq(:passed) + end + + context 'custom env' do + before do + QA::Runtime::Scenario.define(:gitlab_address, 'https://release.gitlab.net') + end + + 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 ) {} + end + + expect(group.examples.first.execution_result.status).to eq(:passed) + expect(group.examples.last.execution_result.status).to eq(:pending) + end + end + + context 'production' do + before do + QA::Runtime::Scenario.define(:gitlab_address, 'https://gitlab.com/') + end + + it 'runs on production' do + group = describe_successfully do + 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 + + expect(group.examples[0].execution_result.status).to eq(:passed) + expect(group.examples[1].execution_result.status).to eq(:pending) + expect(group.examples[2].execution_result.status).to eq(:passed) + end + end + + it 'outputs a message for invalid environments' do + group = describe_successfully do + it('will skip', only: :production) {} + end + + expect(group.examples.first.execution_result.pending_message).to match(/[Tt]est.*not compatible.*environment/) + end + end end |