Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-17 19:05:49 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-17 19:05:49 +0300
commit43a25d93ebdabea52f99b05e15b06250cd8f07d7 (patch)
treedceebdc68925362117480a5d672bcff122fb625b /qa/spec/specs/helpers
parent20c84b99005abd1c82101dfeff264ac50d2df211 (diff)
Add latest changes from gitlab-org/gitlab@16-0-stable-eev16.0.0-rc42
Diffstat (limited to 'qa/spec/specs/helpers')
-rw-r--r--qa/spec/specs/helpers/context_selector_spec.rb158
-rw-r--r--qa/spec/specs/helpers/feature_flag_spec.rb64
2 files changed, 222 insertions, 0 deletions
diff --git a/qa/spec/specs/helpers/context_selector_spec.rb b/qa/spec/specs/helpers/context_selector_spec.rb
index 7541bb45d82..f6134cc6177 100644
--- a/qa/spec/specs/helpers/context_selector_spec.rb
+++ b/qa/spec/specs/helpers/context_selector_spec.rb
@@ -43,6 +43,7 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do
end
it 'matches multiple subdomains' do
+ allow(GitlabEdition).to receive(:jh?).and_return(false)
QA::Runtime::Scenario.define(:gitlab_address, "https://staging.gitlab.com")
aggregate_failures do
@@ -51,13 +52,35 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do
end
end
+ it 'matches multiple subdomains on jh side' do
+ allow(GitlabEdition).to receive(:jh?).and_return(true)
+ QA::Runtime::Scenario.define(:gitlab_address, "https://staging.jihulab.com")
+
+ 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
+ allow(GitlabEdition).to receive(:jh?).and_return(false)
QA::Runtime::Scenario.define(:gitlab_address, "https://gitlab.com/")
expect(described_class.context_matches?(:production)).to be_truthy
end
+ it 'matches :production on jh side' do
+ allow(GitlabEdition).to receive(:jh?).and_return(true)
+
+ QA::Runtime::Scenario.define(:gitlab_address, "https://jihulab.com/")
+ expect(described_class.context_matches?(:production)).to be_truthy
+
+ QA::Runtime::Scenario.define(:gitlab_address, "https://gitlab.hk/")
+ expect(described_class.context_matches?(:production)).to be_truthy
+ end
+
it 'matches domain' do
+ allow(GitlabEdition).to receive(:jh?).and_return(false)
QA::Runtime::Scenario.define(:gitlab_address, 'https://jihulab.com')
aggregate_failures do
@@ -67,6 +90,26 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do
end
end
+ it 'matches domain on jh side' do
+ # To simulate run tests in JH
+ allow(GitlabEdition).to receive(:jh?).and_return(true)
+ QA::Runtime::Scenario.define(:gitlab_address, 'https://jihulab.com')
+
+ aggregate_failures do
+ expect(described_class.context_matches?(:production)).to be_truthy
+ expect(described_class.context_matches?(domain: 'gitlab')).to be_falsey
+ expect(described_class.context_matches?(domain: 'jihulab')).to be_truthy
+ end
+
+ QA::Runtime::Scenario.define(:gitlab_address, 'https://gitlab.hk')
+
+ aggregate_failures do
+ expect(described_class.context_matches?(:production)).to be_truthy
+ expect(described_class.context_matches?(domain: 'jihulab')).to be_falsey
+ expect(described_class.context_matches?(domain: 'gitlab')).to be_truthy
+ end
+ end
+
it 'matches tld' do
QA::Runtime::Scenario.define(:gitlab_address, 'https://gitlab.cn')
@@ -89,6 +132,20 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do
end
end
+ context 'with generic condition context matcher' do
+ it 'matches truthy lambda condition result' do
+ expect(described_class.context_matches?(condition: -> { true })).to be_truthy
+ end
+
+ it 'matches truthy condition result' do
+ expect(described_class.context_matches?(condition: true)).to be_truthy
+ end
+
+ it 'skips falsey condition result' do
+ expect(described_class.context_matches?(condition: false)).to be_falsey
+ end
+ end
+
it 'returns false for mismatching' do
QA::Runtime::Scenario.define(:gitlab_address, "https://staging.gitlab.com")
@@ -119,6 +176,7 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do
context 'with different environment set' do
before do
+ allow(GitlabEdition).to receive(:jh?).and_return(false)
QA::Runtime::Scenario.define(:gitlab_address, 'https://gitlab.com')
end
@@ -140,6 +198,31 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do
end
end
end
+
+ context 'with different environment set on jh side' do
+ before do
+ allow(GitlabEdition).to receive(:jh?).and_return(true)
+ QA::Runtime::Scenario.define(:gitlab_address, 'https://jihulab.com')
+ 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
+
+ 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
it 'runs only in staging' do
@@ -226,6 +309,7 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do
context 'production' do
before do
+ allow(GitlabEdition).to receive(:jh?).and_return(false)
QA::Runtime::Scenario.define(:gitlab_address, 'https://gitlab.com/')
end
@@ -260,6 +344,80 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do
end
end
+ context 'jh mainland production ' do
+ before do
+ allow(GitlabEdition).to receive(:jh?).and_return(true)
+ QA::Runtime::Scenario.define(:gitlab_address, 'https://jihulab.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: 'jihulab' }) {}
+ end
+
+ 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: 'jihulab' }) {}
+ 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
+
+ context 'jh hk production ' do
+ before do
+ allow(GitlabEdition).to receive(:jh?).and_return(true)
+ QA::Runtime::Scenario.define(:gitlab_address, 'https://gitlab.hk/')
+ 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
+
+ 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
+
it 'outputs a message for invalid environments' do
group = describe_successfully do
it('will skip', only: :production) {}
diff --git a/qa/spec/specs/helpers/feature_flag_spec.rb b/qa/spec/specs/helpers/feature_flag_spec.rb
index 491fc22f026..e9f64dab587 100644
--- a/qa/spec/specs/helpers/feature_flag_spec.rb
+++ b/qa/spec/specs/helpers/feature_flag_spec.rb
@@ -122,6 +122,10 @@ RSpec.describe QA::Specs::Helpers::FeatureFlag do
end
context 'when run on production' do
+ before do
+ allow(GitlabEdition).to receive(:jh?).and_return(false)
+ end
+
before(:context) do
QA::Runtime::Scenario.define(:gitlab_address, 'https://gitlab.com')
end
@@ -147,6 +151,66 @@ RSpec.describe QA::Specs::Helpers::FeatureFlag do
it_behaves_like 'skips with given feature flag metadata', { name: 'global_ff', scope: :global }
end
+ context 'when run on jh production mainland' do
+ before do
+ allow(GitlabEdition).to receive(:jh?).and_return(true)
+ end
+
+ before(:context) do
+ QA::Runtime::Scenario.define(:gitlab_address, 'https://jihulab.com')
+ end
+
+ context 'when no scope is defined' do
+ it_behaves_like 'skips with given feature flag metadata', { name: 'no_scope_ff' }
+
+ context 'for only one test in the example group' do
+ it 'only skips specified test and runs all others' do
+ group = describe_successfully 'Feature flag set for one test' do
+ it('is skipped', feature_flag: { name: 'single_test_ff' }) {}
+ it('passes') {}
+ end
+
+ expect(group.examples[0].execution_result.status).to eq(:pending)
+ expect(group.examples[1].execution_result.status).to eq(:passed)
+ end
+ end
+ end
+
+ it_behaves_like 'skips with given feature flag metadata', { name: 'actor_ff', scope: :project }
+
+ it_behaves_like 'skips with given feature flag metadata', { name: 'global_ff', scope: :global }
+ end
+
+ context 'when run on jh production hk' do
+ before do
+ allow(GitlabEdition).to receive(:jh?).and_return(true)
+ end
+
+ before(:context) do
+ QA::Runtime::Scenario.define(:gitlab_address, 'https://gitlab.hk')
+ end
+
+ context 'when no scope is defined' do
+ it_behaves_like 'skips with given feature flag metadata', { name: 'no_scope_ff' }
+
+ context 'for only one test in the example group' do
+ it 'only skips specified test and runs all others' do
+ group = describe_successfully 'Feature flag set for one test' do
+ it('is skipped', feature_flag: { name: 'single_test_ff' }) {}
+ it('passes') {}
+ end
+
+ expect(group.examples[0].execution_result.status).to eq(:pending)
+ expect(group.examples[1].execution_result.status).to eq(:passed)
+ end
+ end
+ end
+
+ it_behaves_like 'skips with given feature flag metadata', { name: 'actor_ff', scope: :project }
+
+ it_behaves_like 'skips with given feature flag metadata', { name: 'global_ff', scope: :global }
+ end
+
context 'when run on pre' do
before(:context) do
QA::Runtime::Scenario.define(:gitlab_address, 'https://pre.gitlab.com')