Skip to content

Clear Sentry and Raven settings after the related tests

Furkan Ayhan requested to merge 432145-433450-fix-sentry-tests into master

What does this MR do and why?

When we setup Sentry/Raven, we don't clear their settings. And this causes some flaky tests.

In this commit, we are adding the new clear_sentry_settings method.

Related #432145 (closed)

Note: This is the second attempt because the first one (!138304 (merged)) was reverted (!138604 (merged)).

#433450 (closed)

The only difference is that we added Sentry.init and Sentry.close in the config.around(:example, :sentry) block.

How to set up and validate locally

For a quick reproduction, here's the command;

bundle exec rspec -f d spec/lib/gitlab/error_tracking_spec.rb spec/lib/gitlab/http_spec.rb -e "when exceptions for dev should be raised" -e "when there is a DB call in the concurrent thread"
Gitlab::ErrorTracking
  # order random
  .track_and_raise_for_dev_exception
    when exceptions for dev should be raised
      raises the exception
      with tags
        includes additional tags

Gitlab::HTTP
  .get
    when passing async:true
      when there is a DB call in the concurrent thread

Also, this passes, via #433450 (comment 1677046080);

bundle exec rspec spec/lib/gitlab/error_tracking_spec.rb  spec/lib/gitlab/error_tracking/processor/sidekiq_processor_spec.rb

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #432145 (closed)

Edited by Furkan Ayhan

Merge request reports