Add spec for multiple quarantine projects

parent d7560d31
...@@ -15,7 +15,7 @@ end ...@@ -15,7 +15,7 @@ end
# expanding into the global state # expanding into the global state
# See: https://github.com/rspec/rspec-core/issues/2603 # See: https://github.com/rspec/rspec-core/issues/2603
def describe_successfully(*args, &describe_body) 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 ran_successfully = example_group.run RaiseOnFailuresReporter
expect(ran_successfully).to eq true expect(ran_successfully).to eq true
example_group example_group
...@@ -156,28 +156,51 @@ RSpec.describe QA::Specs::Helpers::Quarantine do ...@@ -156,28 +156,51 @@ RSpec.describe QA::Specs::Helpers::Quarantine do
described_class.configure_rspec described_class.configure_rspec
end end
it 'is skipped when set on contexts or descriptions' do context 'no pipeline specified' do
group = describe_successfully 'Quarantined in staging', quarantine: { only: { subdomain: :staging } } do it 'is skipped when set on contexts or descriptions' do
it('runs in staging') {} 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 end
expect(group.examples.first.execution_result.status).to eq(:pending) it 'is skipped only in staging' do
expect(group.examples.first.execution_result.pending_message) group = describe_successfully do
.to eq('In quarantine') 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 end
it 'is skipped only in staging' do context 'multiple pipelines specified' do
group = describe_successfully do shared_examples 'skipped in project' do |project|
it('skipped in staging', quarantine: { only: { subdomain: :staging } }) {} before do
it('runs in staging', quarantine: { only: :production }) {} stub_env('CI_PROJECT_NAME', project)
it('skipped in staging also', quarantine: { only: { subdomain: %i[release staging] } }) {} described_class.configure_rspec
it('runs in any env') {} 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 end
expect(group.examples[0].execution_result.status).to eq(:pending) it_behaves_like 'skipped in project', 'STAGING'
expect(group.examples[1].execution_result.status).to eq(:passed) it_behaves_like 'skipped in project', 'CANARY'
expect(group.examples[2].execution_result.status).to eq(:pending) it_behaves_like 'skipped in project', 'PRODUCTION'
expect(group.examples[3].execution_result.status).to eq(:passed)
end end
end end
...@@ -368,8 +391,8 @@ RSpec.describe QA::Specs::Helpers::Quarantine do ...@@ -368,8 +391,8 @@ RSpec.describe QA::Specs::Helpers::Quarantine do
it 'runs on a custom environment' do it 'runs on a custom environment' do
group = describe_successfully do group = describe_successfully do
it('runs on release gitlab net', only: { tld: '.net', subdomain: :release, domain: 'gitlab' } ) {} it('runs on release gitlab net', only: { tld: '.net', subdomain: :release, domain: 'gitlab' }) {}
it('does not run on release', only: :production ) {} it('does not run on release', only: :production) {}
end end
expect(group.examples.first.execution_result.status).to eq(:passed) expect(group.examples.first.execution_result.status).to eq(:passed)
...@@ -384,7 +407,7 @@ RSpec.describe QA::Specs::Helpers::Quarantine do ...@@ -384,7 +407,7 @@ RSpec.describe QA::Specs::Helpers::Quarantine do
it 'runs on production' do it 'runs on production' do
group = describe_successfully 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('does not run in prod', only: { subdomain: :staging }) {}
it('runs in prod and staging', only: { subdomain: /(staging.)?/, domain: 'gitlab' }) {} it('runs in prod and staging', only: { subdomain: /(staging.)?/, domain: 'gitlab' }) {}
end end
...@@ -412,7 +435,7 @@ RSpec.describe QA::Specs::Helpers::Quarantine do ...@@ -412,7 +435,7 @@ RSpec.describe QA::Specs::Helpers::Quarantine do
it 'runs on any pipeline' do it 'runs on any pipeline' do
group = describe_successfully 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] }) {} it('runs given an array of pipelines', only: { pipeline: [:canary, :not_nightly] }) {}
end end
...@@ -431,9 +454,9 @@ RSpec.describe QA::Specs::Helpers::Quarantine do ...@@ -431,9 +454,9 @@ RSpec.describe QA::Specs::Helpers::Quarantine do
it 'runs on default branch pipelines' do it 'runs on default branch pipelines' do
group = describe_successfully 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('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 end
aggregate_failures do aggregate_failures do
...@@ -452,8 +475,8 @@ RSpec.describe QA::Specs::Helpers::Quarantine do ...@@ -452,8 +475,8 @@ RSpec.describe QA::Specs::Helpers::Quarantine do
it 'runs on designated pipeline' do it 'runs on designated pipeline' do
group = describe_successfully do group = describe_successfully do
it('runs on nightly', only: { pipeline: :nightly } ) {} it('runs on nightly', only: { pipeline: :nightly }) {}
it('does not run in not_nightly', only: { pipeline: :not_nightly } ) {} it('does not run in not_nightly', only: { pipeline: :not_nightly }) {}
it('runs on nightly given an array', only: { pipeline: [:canary, :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] }) {} it('does not run in not_nightly given an array', only: { pipeline: [:not_nightly, :canary] }) {}
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