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
path: root/qa/spec
diff options
context:
space:
mode:
Diffstat (limited to 'qa/spec')
-rw-r--r--qa/spec/fixtures/ff/bulk_import_projects.yml8
-rw-r--r--qa/spec/resource/base_spec.rb22
-rw-r--r--qa/spec/resource/user_spec.rb9
-rw-r--r--qa/spec/specs/helpers/context_selector_spec.rb20
-rw-r--r--qa/spec/tools/ci/ff_changes_spec.rb51
-rw-r--r--qa/spec/tools/ci/non_empty_suites_spec.rb19
-rw-r--r--qa/spec/tools/ci/qa_changes_spec.rb87
7 files changed, 212 insertions, 4 deletions
diff --git a/qa/spec/fixtures/ff/bulk_import_projects.yml b/qa/spec/fixtures/ff/bulk_import_projects.yml
new file mode 100644
index 00000000000..853389577cf
--- /dev/null
+++ b/qa/spec/fixtures/ff/bulk_import_projects.yml
@@ -0,0 +1,8 @@
+---
+name: bulk_import_projects
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68873
+rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/339941
+milestone: '14.3'
+type: development
+group: group::import
+default_enabled: false
diff --git a/qa/spec/resource/base_spec.rb b/qa/spec/resource/base_spec.rb
index f23f4aa728b..195e497f290 100644
--- a/qa/spec/resource/base_spec.rb
+++ b/qa/spec/resource/base_spec.rb
@@ -24,6 +24,10 @@ RSpec.describe QA::Resource::Base do
'block'
end
+ attribute :token do
+ 'token_value'
+ end
+
attribute :username do
'qa'
end
@@ -208,6 +212,24 @@ RSpec.describe QA::Resource::Base do
.to have_received(:debug).with(/api_with_block/)
end
end
+
+ context 'when the attribute is token and has a block' do
+ let(:api_resource) { { token: 'another_token_value' } }
+
+ before do
+ allow(QA::Runtime::Logger).to receive(:debug)
+ end
+
+ it 'emits a masked debug log entry' do
+ result = subject.fabricate!(resource: resource)
+
+ expect(result).to be_a(described_class)
+ expect(result.token).to eq('another_token_value')
+
+ expect(QA::Runtime::Logger)
+ .to have_received(:debug).with(/MASKED/)
+ end
+ end
end
context 'when the attribute is populated via direct assignment' do
diff --git a/qa/spec/resource/user_spec.rb b/qa/spec/resource/user_spec.rb
index e7397d9c0bf..c0140abf298 100644
--- a/qa/spec/resource/user_spec.rb
+++ b/qa/spec/resource/user_spec.rb
@@ -23,14 +23,15 @@ RSpec.describe QA::Resource::User do
end
describe '#password' do
- it 'generates a default password' do
- expect(subject.password).to eq('password')
+ it 'generates a random 16 character password by default' do
+ expect(subject.password).to match(/\w{16}/)
end
it 'is possible to set the password' do
- subject.password = 'secret'
+ new_password = "21c7a808"
+ subject.password = new_password
- expect(subject.password).to eq('secret')
+ expect(subject.password).to eq(new_password)
end
end
diff --git a/qa/spec/specs/helpers/context_selector_spec.rb b/qa/spec/specs/helpers/context_selector_spec.rb
index 5a320cde71f..7541bb45d82 100644
--- a/qa/spec/specs/helpers/context_selector_spec.rb
+++ b/qa/spec/specs/helpers/context_selector_spec.rb
@@ -57,6 +57,26 @@ RSpec.describe QA::Specs::Helpers::ContextSelector do
expect(described_class.context_matches?(:production)).to be_truthy
end
+ it 'matches domain' do
+ QA::Runtime::Scenario.define(:gitlab_address, 'https://jihulab.com')
+
+ aggregate_failures do
+ expect(described_class.context_matches?(:production)).to be_falsey
+ expect(described_class.context_matches?(domain: 'gitlab')).to be_falsey
+ expect(described_class.context_matches?(domain: 'jihulab')).to be_truthy
+ end
+ end
+
+ it 'matches tld' do
+ QA::Runtime::Scenario.define(:gitlab_address, 'https://gitlab.cn')
+
+ aggregate_failures do
+ expect(described_class.context_matches?).to be_falsey
+ expect(described_class.context_matches?(tld: 'net')).to be_falsey
+ expect(described_class.context_matches?(tld: 'cn')).to be_truthy
+ end
+ end
+
it 'doesnt match with mismatching switches' do
QA::Runtime::Scenario.define(:gitlab_address, 'https://gitlab.test')
diff --git a/qa/spec/tools/ci/ff_changes_spec.rb b/qa/spec/tools/ci/ff_changes_spec.rb
new file mode 100644
index 00000000000..71ca26867e0
--- /dev/null
+++ b/qa/spec/tools/ci/ff_changes_spec.rb
@@ -0,0 +1,51 @@
+# frozen_string_literal: true
+
+RSpec.describe QA::Tools::Ci::FfChanges do
+ subject(:ff_changes) { described_class.new(mr_diff) }
+
+ before do
+ allow(Gitlab::QA::TestLogger).to receive(:logger).and_return(Logger.new(StringIO.new))
+ end
+
+ context "with merge request pipeline" do
+ let(:deleted_file) { false }
+ let(:mr_diff) do
+ [
+ {
+ path: "config/feature_flags/development/bulk_import_projects.yml",
+ deleted_file: deleted_file
+ }
+ ]
+ end
+
+ before do
+ allow(File).to receive(:read)
+ .with(File.expand_path("../#{mr_diff.first[:path]}", QA::Runtime::Path.qa_root))
+ .and_return(File.read("spec/fixtures/ff/bulk_import_projects.yml"))
+ end
+
+ context "with changed feature flag" do
+ it "returns inverse ff state option" do
+ expect(ff_changes.fetch).to eq("bulk_import_projects=enabled")
+ end
+ end
+
+ context "with deleted feature flag" do
+ let(:deleted_file) { true }
+
+ it "returns deleted ff state option" do
+ expect(ff_changes.fetch).to eq("bulk_import_projects=deleted")
+ end
+ end
+ end
+
+ context "without merge request pipeline" do
+ let(:mr_diff) { [] }
+
+ context "with empty mr diff" do
+ it "doesn't return any ff options" do
+ expect(ff_changes.fetch).to be_nil
+ end
+ end
+ end
+end
diff --git a/qa/spec/tools/ci/non_empty_suites_spec.rb b/qa/spec/tools/ci/non_empty_suites_spec.rb
new file mode 100644
index 00000000000..d9bfe1eebe7
--- /dev/null
+++ b/qa/spec/tools/ci/non_empty_suites_spec.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+RSpec.describe QA::Tools::Ci::NonEmptySuites do
+ let(:non_empty_suites) { described_class.new(nil) }
+
+ let(:status) { instance_double(Process::Status, success?: true) }
+
+ before do
+ allow(Gitlab::QA::TestLogger).to receive(:logger).and_return(Logger.new(StringIO.new))
+ allow(Open3).to receive(:capture3).and_return(["output\n0", "", status])
+ allow(Open3).to receive(:capture3)
+ .with("bundle exec bin/qa Test::Instance::All --count-examples-only --address http://dummy1.test")
+ .and_return(["output\n1", "", status])
+ end
+
+ it "returns runnable test suites" do
+ expect(non_empty_suites.fetch).to eq("Test::Instance::All")
+ end
+end
diff --git a/qa/spec/tools/ci/qa_changes_spec.rb b/qa/spec/tools/ci/qa_changes_spec.rb
new file mode 100644
index 00000000000..bc98ec16d7f
--- /dev/null
+++ b/qa/spec/tools/ci/qa_changes_spec.rb
@@ -0,0 +1,87 @@
+# frozen_string_literal: true
+
+RSpec.describe QA::Tools::Ci::QaChanges do
+ subject(:qa_changes) { described_class.new(mr_diff, mr_labels) }
+
+ let(:mr_labels) { [] }
+
+ before do
+ allow(File).to receive(:directory?).and_return(false)
+ end
+
+ context "with spec only changes" do
+ let(:mr_diff) do
+ [
+ { path: "qa/qa/specs/features/test_spec.rb", diff: "" },
+ { path: "qa/qa/specs/features/another_test_spec.rb", diff: "" }
+ ]
+ end
+
+ it ".qa_tests return changed specs" do
+ expect(qa_changes.qa_tests).to eq(
+ "qa/specs/features/test_spec.rb qa/specs/features/another_test_spec.rb"
+ )
+ end
+
+ it ".framework_changes? return false" do
+ expect(qa_changes.framework_changes?).to eq(false)
+ end
+
+ it ".quarantine_changes? return false" do
+ expect(qa_changes.quarantine_changes?).to eq(false)
+ end
+ end
+
+ context "with framework changes" do
+ let(:mr_diff) { [{ path: "qa/qa.rb" }] }
+
+ it ".qa_tests do not return specifix specs" do
+ expect(qa_changes.qa_tests).to be_nil
+ end
+
+ it ".framework_changes? return true" do
+ expect(qa_changes.framework_changes?).to eq(true)
+ end
+
+ it ".quarantine_changes? return false" do
+ expect(qa_changes.quarantine_changes?).to eq(false)
+ end
+ end
+
+ context "with non qa changes" do
+ let(:mr_diff) { [{ path: "Gemfile" }] }
+
+ it ".framework_changes? return false" do
+ expect(qa_changes.framework_changes?).to eq(false)
+ end
+
+ it ".quarantine_changes? return false" do
+ expect(qa_changes.quarantine_changes?).to eq(false)
+ end
+
+ context "without mr labels" do
+ it ".qa_tests do not return any specific specs" do
+ expect(qa_changes.qa_tests).to be_nil
+ end
+ end
+
+ context "with mr label" do
+ let(:mr_labels) { ["devops::manage"] }
+
+ it ".qa_tests return specs for devops stage" do
+ expect(qa_changes.qa_tests.split(" ")).to include(
+ "qa/specs/features/browser_ui/1_manage/",
+ "qa/specs/features/api/1_manage/"
+ )
+ end
+ end
+ end
+
+ context "with quarantine changes" do
+ let(:mr_diff) { [{ path: "qa/qa/specs/features/test_spec.rb", diff: "+ , quarantine: true" }] }
+
+ it ".quarantine_changes? return true" do
+ expect(qa_changes.quarantine_changes?).to eq(true)
+ end
+ end
+end