Skip to content
代码片段 群组 项目
提交 813e83e9 编辑于 作者: Furkan Ayhan's avatar Furkan Ayhan
浏览文件

Clear Sentry and Raven settings after the related tests

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 https://gitlab.com/gitlab-org/gitlab/-/issues/432145
上级 4fa941ad
No related branches found
No related tags found
无相关合并请求
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
end end
after do after do
Sentry.get_current_scope.clear clear_sentry_settings
end end
describe '.track_and_raise_for_dev_exception' do describe '.track_and_raise_for_dev_exception' do
......
...@@ -55,8 +55,7 @@ ...@@ -55,8 +55,7 @@
end end
context 'when there is a DB call in the concurrent thread' do context 'when there is a DB call in the concurrent thread' do
it 'raises Gitlab::Utils::ConcurrentRubyThreadIsUsedError error', it 'raises Gitlab::Utils::ConcurrentRubyThreadIsUsedError error' do
quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/432145' do
stub_request(:get, 'http://example.org').to_return(status: 200, body: 'hello world') stub_request(:get, 'http://example.org').to_return(status: 200, body: 'hello world')
result = described_class.get('http://example.org', async: true) do |_fragment| result = described_class.get('http://example.org', async: true) do |_fragment|
......
...@@ -320,6 +320,10 @@ def set_param(key, value) ...@@ -320,6 +320,10 @@ def set_param(key, value)
Gitlab::ErrorTracking.configure Gitlab::ErrorTracking.configure
end end
after do
clear_sentry_settings
end
it 'does not report a MethodNotAllowed exception to Sentry' do it 'does not report a MethodNotAllowed exception to Sentry' do
exception = Grape::Exceptions::MethodNotAllowed.new({ 'X-GitLab-Test' => '1' }) exception = Grape::Exceptions::MethodNotAllowed.new({ 'X-GitLab-Test' => '1' })
allow(exception).to receive(:backtrace).and_return(caller) allow(exception).to receive(:backtrace).and_return(caller)
......
...@@ -120,6 +120,12 @@ def stub_sentry_settings(enabled: true) ...@@ -120,6 +120,12 @@ def stub_sentry_settings(enabled: true)
.to receive(:sentry_clientside_dsn) { clientside_dsn } .to receive(:sentry_clientside_dsn) { clientside_dsn }
end end
def clear_sentry_settings
::Sentry.get_current_scope.clear
::Sentry.close
::Raven.configuration = ::Raven::Configuration.new
end
def stub_microsoft_graph_mailer_setting(messages) def stub_microsoft_graph_mailer_setting(messages)
allow(Gitlab.config.microsoft_graph_mailer).to receive_messages(to_settings(messages)) allow(Gitlab.config.microsoft_graph_mailer).to receive_messages(to_settings(messages))
end end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册