diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /qa/spec | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'qa/spec')
-rw-r--r-- | qa/spec/runtime/env_spec.rb | 6 | ||||
-rw-r--r-- | qa/spec/service/docker_run/gitlab_runner_spec.rb | 2 | ||||
-rw-r--r-- | qa/spec/specs/helpers/context_selector_spec.rb | 251 |
3 files changed, 218 insertions, 41 deletions
diff --git a/qa/spec/runtime/env_spec.rb b/qa/spec/runtime/env_spec.rb index 8218ab428b0..1d702b70d10 100644 --- a/qa/spec/runtime/env_spec.rb +++ b/qa/spec/runtime/env_spec.rb @@ -54,10 +54,10 @@ RSpec.describe QA::Runtime::Env do default: false end - describe '.chrome_headless?' do + describe '.webdriver_headless?' do it_behaves_like 'boolean method', - method: :chrome_headless?, - env_key: 'CHROME_HEADLESS', + method: :webdriver_headless?, + env_key: 'WEBDRIVER_HEADLESS', default: true end diff --git a/qa/spec/service/docker_run/gitlab_runner_spec.rb b/qa/spec/service/docker_run/gitlab_runner_spec.rb index 34d95943321..a8838db10cf 100644 --- a/qa/spec/service/docker_run/gitlab_runner_spec.rb +++ b/qa/spec/service/docker_run/gitlab_runner_spec.rb @@ -130,7 +130,7 @@ module QA end it 'mounts the docker socket to the host runner' do - expect(subject).to have_received(:shell).with(/-v \/var\/run\/docker.sock:\/var\/run\/docker.sock /) + expect(subject).to have_received(:shell).with(%r{-v /var/run/docker.sock:/var/run/docker.sock }) end it 'runs in privileged mode' do diff --git a/qa/spec/specs/helpers/context_selector_spec.rb b/qa/spec/specs/helpers/context_selector_spec.rb index 7792d33dcf9..f0250103008 100644 --- a/qa/spec/specs/helpers/context_selector_spec.rb +++ b/qa/spec/specs/helpers/context_selector_spec.rb @@ -49,8 +49,10 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do it 'matches multiple subdomains' do QA::Runtime::Scenario.define(:gitlab_address, "https://staging.gitlab.com") - expect(described_class.context_matches?(subdomain: [:release, :staging])).to be_truthy - expect(described_class.context_matches?(:production, subdomain: [:release, :staging])).to be_truthy + aggregate_failures do + expect(described_class.context_matches?(subdomain: [:release, :staging])).to be_truthy + expect(described_class.context_matches?(:production, subdomain: [:release, :staging])).to be_truthy + end end it 'matches :production' do @@ -87,6 +89,16 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do expect(group.examples[0].execution_result.status).to eq(:passed) end + + context 'when excluding contexts' do + it 'can apply to contexts or descriptions' do + group = describe_successfully 'skips staging', except: { subdomain: :staging } do + it('skips staging') {} + end + + expect(group.examples[0].execution_result.status).to eq(:pending) + end + end end context 'with different environment set' do @@ -102,6 +114,16 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do expect(group.examples[0].execution_result.status).to eq(:pending) end + + context 'when excluding contexts' do + it 'runs against production' do + group = describe_successfully 'Runs in staging', :something, except: { subdomain: :staging } do + it('runs in staging') {} + end + + expect(group.examples[0].execution_result.status).to eq(:passed) + end + end end end @@ -113,10 +135,28 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do 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) + aggregate_failures do + 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 + end + + context 'when excluding contexts' do + it 'skips staging' do + group = describe_successfully do + it('skips staging', except: { subdomain: :staging }) {} + it('runs in staging', except: :production) {} + it('skips staging also', except: { subdomain: %i[release staging] }) {} + end + + aggregate_failures do + 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) + end + end end context 'custom env' do @@ -130,8 +170,24 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do 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) + aggregate_failures do + expect(group.examples.first.execution_result.status).to eq(:passed) + expect(group.examples.last.execution_result.status).to eq(:pending) + end + end + + context 'when excluding contexts' do + it 'skips a custom environment' do + group = describe_successfully do + it('skips release gitlab net', except: { tld: '.net', subdomain: :release, domain: 'gitlab' }) {} + it('runs on release', except: :production) {} + end + + aggregate_failures do + expect(group.examples.first.execution_result.status).to eq(:pending) + expect(group.examples.last.execution_result.status).to eq(:passed) + end + end end end @@ -147,9 +203,27 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do 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) + aggregate_failures do + 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 + + context 'when excluding contexts' do + it 'skips production' do + group = describe_successfully do + it('skips prod', except: :production) {} + it('runs on prod', except: { subdomain: :staging }) {} + it('skips prod and staging', except: { subdomain: /(staging.)?/, domain: 'gitlab' }) {} + end + + aggregate_failures do + 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) + end + end end end @@ -179,6 +253,21 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do expect(group.examples[1].execution_result.status).to eq(:passed) end end + + context 'when excluding contexts' do + it 'runs in any pipeline' do + group = describe_successfully do + it('runs given a single named pipeline', except: { pipeline: :nightly }) {} + it('runs given an array of pipelines', except: { pipeline: [:canary, :not_nightly] }) {} + end + + aggregate_failures do + group.examples.each do |example| + expect(example.execution_result.status).to eq(:passed) + end + end + end + end end context 'when a pipeline triggered from the default branch runs in gitlab-qa' do @@ -200,6 +289,22 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do expect(group.examples[2].execution_result.status).to eq(:pending) end end + + context 'when excluding contexts' do + it 'skips default branch pipelines' do + group = describe_successfully do + it('skips main pipeline given a single pipeline', except: { pipeline: :main }) {} + it('skips main given an array of pipelines', except: { pipeline: [:canary, :main] }) {} + it('runs non-default pipelines', except: { pipeline: [:nightly, :not_nightly, :not_main] }) {} + end + + aggregate_failures do + expect(group.examples[0].execution_result.status).to eq(:pending) + expect(group.examples[1].execution_result.status).to eq(:pending) + expect(group.examples[2].execution_result.status).to eq(:passed) + end + end + end end context 'with CI_PROJECT_NAME set' do @@ -223,24 +328,42 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do expect(group.examples[3].execution_result.status).to eq(:pending) end end + + context 'when excluding contexts' do + it 'skips designated pipeline' do + group = describe_successfully do + it('skips nightly', except: { pipeline: :nightly }) {} + it('runs in not_nightly', except: { pipeline: :not_nightly }) {} + it('skips on nightly given an array', except: { pipeline: [:canary, :nightly] }) {} + it('runs in not_nightly given an array', except: { pipeline: [:not_nightly, :canary] }) {} + end + + aggregate_failures do + 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 end end - context 'when excluding contexts' do - context 'with job constraints' do - context 'without CI_JOB_NAME set' do - before do - stub_env('CI_JOB_NAME', nil) - described_class.configure_rspec - end + context 'with job constraints' do + context 'without CI_JOB_NAME set' do + before do + stub_env('CI_JOB_NAME', nil) + described_class.configure_rspec + end + context 'when excluding contexts' do it 'runs in any job' do group = describe_successfully do - it('runs given a single named job', exclude: { job: 'ee:instance-image' }) {} - it('runs given a single regex pattern', exclude: { job: '.*:instance-image' }) {} - it('runs given an array of jobs', exclude: { job: %w[ee:instance-image qa-schedules-browser_ui-3_create] }) {} - it('runs given an array of regex patterns', exclude: { job: %w[ee:.* qa-schedules-browser_ui.*] }) {} - it('runs given a mix of strings and regex patterns', exclude: { job: %w[ee:instance-image qa-schedules-browser_ui.*] }) {} + it('runs given a single named job', except: { job: 'ee:instance-image' }) {} + it('runs given a single regex pattern', except: { job: '.*:instance-image' }) {} + it('runs given an array of jobs', except: { job: %w[ee:instance-image qa-schedules-browser_ui-3_create] }) {} + it('runs given an array of regex patterns', except: { job: %w[ee:.* qa-schedules-browser_ui.*] }) {} + it('runs given a mix of strings and regex patterns', except: { job: %w[ee:instance-image qa-schedules-browser_ui.*] }) {} end aggregate_failures do @@ -251,19 +374,39 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do end end - context 'with CI_JOB_NAME set' do - before do - stub_env('CI_JOB_NAME', 'ee:instance-image') - described_class.configure_rspec + context 'when including only specific contexts' do + it 'runs in any job' do + group = describe_successfully do + it('runs given a single named job', only: { job: 'ee:instance-image' }) {} + it('runs given a single regex pattern', only: { job: '.*:instance-image' }) {} + it('runs given an array of jobs', only: { job: %w[ee:instance-image qa-schedules-browser_ui-3_create] }) {} + it('runs given an array of regex patterns', only: { job: %w[ee:.* qa-schedules-browser_ui.*] }) {} + it('runs given a mix of strings and regex patterns', only: { job: %w[ee:instance-image qa-schedules-browser_ui.*] }) {} + end + + aggregate_failures do + group.examples.each do |example| + expect(example.execution_result.status).to eq(:passed) + end + end end + end + end + + context 'with CI_JOB_NAME set' do + before do + stub_env('CI_JOB_NAME', 'ee:instance-image') + described_class.configure_rspec + end + context 'when excluding contexts' do it 'does not run in the specified job' do group = describe_successfully do - it('skips given a single named job', exclude: { job: 'ee:instance-image' }) {} - it('skips given a single regex pattern', exclude: { job: '.*:instance-image' }) {} - it('skips given an array of jobs', exclude: { job: %w[ee:instance-image qa-schedules-browser_ui-3_create] }) {} - it('skips given an array of regex patterns', exclude: { job: %w[ee:.* qa-schedules-browser_ui.*] }) {} - it('skips given a mix of strings and regex patterns', exclude: { job: %w[ee:instance-image qa-schedules-browser_ui.*] }) {} + it('skips given a single named job', except: { job: 'ee:instance-image' }) {} + it('skips given a single regex pattern', except: { job: '.*:instance-image' }) {} + it('skips given an array of jobs', except: { job: %w[ee:instance-image qa-schedules-browser_ui-3_create] }) {} + it('skips given an array of regex patterns', except: { job: %w[ee:.* qa-schedules-browser_ui.*] }) {} + it('skips given a mix of strings and regex patterns', except: { job: %w[ee:instance-image qa-schedules-browser_ui.*] }) {} end aggregate_failures do @@ -275,11 +418,11 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do it 'runs in jobs that do not match' do group = describe_successfully do - it('runs given a single named job', exclude: { job: 'ce:instance-image' }) {} - it('runs given a single regex pattern', exclude: { job: '.*:instance-image-quarantine' }) {} - it('runs given an array of jobs', exclude: { job: %w[ce:instance-image qa-schedules-browser_ui-3_create] }) {} - it('runs given an array of regex patterns', exclude: { job: %w[ce:.* qa-schedules-browser_ui.*] }) {} - it('runs given a mix of strings and regex patterns', exclude: { job: %w[ce:instance-image qa-schedules-browser_ui.*] }) {} + it('runs given a single named job', except: { job: 'ce:instance-image' }) {} + it('runs given a single regex pattern', except: { job: '.*:instance-image-quarantine' }) {} + it('runs given an array of jobs', except: { job: %w[ce:instance-image qa-schedules-browser_ui-3_create] }) {} + it('runs given an array of regex patterns', except: { job: %w[ce:.* qa-schedules-browser_ui.*] }) {} + it('runs given a mix of strings and regex patterns', except: { job: %w[ce:instance-image qa-schedules-browser_ui.*] }) {} end aggregate_failures do @@ -289,6 +432,40 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do end end end + + context 'when including only specific contexts' do + it 'runs only in the specified jobs' do + group = describe_successfully do + it('runs given a single named job', only: { job: 'ee:instance-image' }) {} + it('runs given a single regex pattern', only: { job: '.*:instance-image' }) {} + it('runs given an array of jobs', only: { job: %w[ee:instance-image qa-schedules-browser_ui-3_create] }) {} + it('runs given an array of regex patterns', only: { job: %w[ee:.* qa-schedules-browser_ui.*] }) {} + it('runs given a mix of strings and regex patterns', only: { job: %w[ee:instance-image qa-schedules-browser_ui.*] }) {} + end + + aggregate_failures do + group.examples.each do |example| + expect(example.execution_result.status).to eq(:passed) + end + end + end + + it 'does not run in jobs that do not match' do + group = describe_successfully do + it('skips given a single named job', only: { job: 'ce:instance-image' }) {} + it('skips given a single regex pattern', only: { job: '.*:instance-image-quarantine' }) {} + it('skips given an array of jobs', only: { job: %w[ce:instance-image qa-schedules-browser_ui-3_create] }) {} + it('skips given an array of regex patterns', only: { job: %w[ce:.* qa-schedules-browser_ui.*] }) {} + it('skips given a mix of strings and regex patterns', only: { job: %w[ce:instance-image qa-schedules-browser_ui.*] }) {} + end + + aggregate_failures do + group.examples.each do |example| + expect(example.execution_result.status).to eq(:pending) + end + end + end + end end end end |