summaryrefslogtreecommitdiff
path: root/qa/spec/support
diff options
context:
space:
mode:
Diffstat (limited to 'qa/spec/support')
-rw-r--r--qa/spec/support/allure_metadata_formatter_spec.rb46
-rw-r--r--qa/spec/support/matchers/eventually_matcher.rb19
-rw-r--r--qa/spec/support/retrier_spec.rb10
3 files changed, 62 insertions, 13 deletions
diff --git a/qa/spec/support/allure_metadata_formatter_spec.rb b/qa/spec/support/allure_metadata_formatter_spec.rb
new file mode 100644
index 00000000000..cb208642716
--- /dev/null
+++ b/qa/spec/support/allure_metadata_formatter_spec.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+
+describe QA::Support::AllureMetadataFormatter do
+ include Helpers::StubENV
+
+ let(:formatter) { described_class.new(StringIO.new) }
+
+ let(:rspec_example_notification) { double('RSpec::Core::Notifications::ExampleNotification', example: rspec_example) }
+ let(:rspec_example) do
+ double(
+ 'RSpec::Core::Example',
+ tms: nil,
+ issue: nil,
+ add_link: nil,
+ attempts: 0,
+ file_path: 'file/path/spec.rb',
+ metadata: {
+ testcase: 'testcase',
+ quarantine: { issue: 'issue' }
+ }
+ )
+ end
+
+ let(:ci_job) { 'ee:relative 5' }
+ let(:ci_job_url) { 'url' }
+
+ before do
+ stub_env('CI', 'true')
+ stub_env('CI_JOB_NAME', ci_job)
+ stub_env('CI_JOB_URL', ci_job_url)
+ end
+
+ it "adds additional data to report" do
+ formatter.example_started(rspec_example_notification)
+
+ aggregate_failures do
+ expect(rspec_example).to have_received(:tms).with('Testcase', 'testcase')
+ expect(rspec_example).to have_received(:issue).with('Quarantine issue', 'issue')
+ expect(rspec_example).to have_received(:add_link).with(name: "Job(#{ci_job})", url: ci_job_url)
+ expect(rspec_example).to have_received(:issue).with(
+ 'Failure issues',
+ 'https://gitlab.com/gitlab-org/gitlab/-/issues?scope=all&state=opened&search=spec.rb'
+ )
+ end
+ end
+end
diff --git a/qa/spec/support/matchers/eventually_matcher.rb b/qa/spec/support/matchers/eventually_matcher.rb
index 3f0afd6fb54..7a35a3165ae 100644
--- a/qa/spec/support/matchers/eventually_matcher.rb
+++ b/qa/spec/support/matchers/eventually_matcher.rb
@@ -9,7 +9,7 @@
# expect { Something.that.takes.time.to_appear }.not_to eventually_eq(expected_result)
#
# With duration and attempts override
-# expect { Something.that.takes.time.to_appear }.to eventually_eq(expected_result).within(duration: 10, attempts: 5)
+# expect { Something.that.takes.time.to_appear }.to eventually_eq(expected_result).within(max_duration: 10, max_attempts: 5)
module Matchers
%w[
@@ -21,9 +21,9 @@ module Matchers
be_empty
].each do |op|
RSpec::Matchers.define(:"eventually_#{op}") do |*expected|
- chain(:within) do |options = {}|
- @duration = options[:duration]
- @attempts = options[:attempts]
+ chain(:within) do |kwargs = {}|
+ @retry_args = kwargs
+ @retry_args[:sleep_interval] = 0.5 unless @retry_args[:sleep_interval]
end
def supports_block_expectations?
@@ -52,11 +52,12 @@ module Matchers
# @param [Symbol] expectation_name
# @return [Boolean]
def wait_and_check(actual, expectation_name)
- QA::Support::Retrier.retry_until(
- max_attempts: @attempts,
- max_duration: @duration,
- sleep_interval: 0.5
- ) do
+ attempt = 0
+
+ QA::Runtime::Logger.debug("Running eventually matcher with '#{operator_msg}' operator")
+ QA::Support::Retrier.retry_until(**@retry_args) do
+ QA::Runtime::Logger.debug("evaluating expectation, attempt: #{attempt += 1}")
+
public_send(expectation_name, actual)
rescue RSpec::Expectations::ExpectationNotMetError, QA::Resource::ApiFabricator::ResourceNotFoundError
false
diff --git a/qa/spec/support/retrier_spec.rb b/qa/spec/support/retrier_spec.rb
index 6f052519516..4e27915553c 100644
--- a/qa/spec/support/retrier_spec.rb
+++ b/qa/spec/support/retrier_spec.rb
@@ -70,8 +70,9 @@ RSpec.describe QA::Support::Retrier do
describe '.retry_on_exception' do
context 'when the condition is true' do
it 'logs max_attempts, reload_page, and sleep_interval parameters' do
- expect { subject.retry_on_exception(max_attempts: 1, reload_page: nil, sleep_interval: 0) { true } }
- .to output(/with retry_on_exception: max_attempts: 1; reload_page: ; sleep_interval: 0/).to_stdout_from_any_process
+ message = /with retry_on_exception: max_attempts: 1; reload_page: true; sleep_interval: 0/
+ expect { subject.retry_on_exception(max_attempts: 1, reload_page: true, sleep_interval: 0) { true } }
+ .to output(message).to_stdout_from_any_process
end
it 'logs the end' do
@@ -82,8 +83,9 @@ RSpec.describe QA::Support::Retrier do
context 'when the condition is false' do
it 'logs the start' do
- expect { subject.retry_on_exception(max_attempts: 1, reload_page: nil, sleep_interval: 0) { false } }
- .to output(/with retry_on_exception: max_attempts: 1; reload_page: ; sleep_interval: 0/).to_stdout_from_any_process
+ message = /with retry_on_exception: max_attempts: 1; reload_page: true; sleep_interval: 0/
+ expect { subject.retry_on_exception(max_attempts: 1, reload_page: true, sleep_interval: 0) { false } }
+ .to output(message).to_stdout_from_any_process
end
it 'logs the end' do