-
-
Notifications
You must be signed in to change notification settings - Fork 457
Speed up tests #4641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Speed up tests #4641
Changes from all commits
3ec789b
ddeada2
1b6c6e0
59cb440
a18e719
975f6c7
47b3629
36e68d4
1ae3d92
fe36a4e
d3164a3
8662adb
9f086cd
618dfa2
3b965a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
release=release from sentry.properties | ||
logs.enabled=true | ||
shutdown-timeout=0 | ||
session-flush-timeout=0 | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,14 +81,51 @@ import org.springframework.web.servlet.HandlerExceptionResolver | |
|
||
class SentryAutoConfigurationTest { | ||
|
||
private val contextRunner = | ||
// Base context runner with performance optimizations | ||
private val baseContextRunner = | ||
WebApplicationContextRunner() | ||
.withConfiguration( | ||
AutoConfigurations.of( | ||
SentryAutoConfiguration::class.java, | ||
WebMvcAutoConfiguration::class.java, | ||
) | ||
) | ||
.withPropertyValues( | ||
// Speed up tests by reducing timeouts and disabling expensive operations | ||
"sentry.shutdownTimeoutMillis=0", | ||
"sentry.sessionFlushTimeoutMillis=0", | ||
"sentry.flushTimeoutMillis=0", | ||
"sentry.readTimeoutMillis=50", | ||
"sentry.connectionTimeoutMillis=50", | ||
"sentry.send-modules=false", // Disable expensive module sending | ||
"sentry.attach-stacktrace=false", // Disable expensive stacktrace collection | ||
"sentry.attach-threads=false", // Disable expensive thread info | ||
"sentry.enable-backpressure-handling=false", | ||
"sentry.enable-spotlight=false", | ||
"sentry.debug=false", | ||
"sentry.max-breadcrumbs=0", // Disable breadcrumb collection for performance | ||
) | ||
|
||
// Use the optimized base runner by default | ||
private val contextRunner = | ||
baseContextRunner.withUserConfiguration( | ||
NoOpTransportConfiguration::class.java | ||
) // Use no-op transport to avoid network calls | ||
|
||
// Specialized context runners for different test categories | ||
private val dsnEnabledRunner = | ||
baseContextRunner | ||
.withPropertyValues("sentry.dsn=http://key@localhost/proj") | ||
.withUserConfiguration( | ||
NoOpTransportConfiguration::class.java | ||
) // Use no-op transport to avoid network calls | ||
|
||
private val tracingEnabledRunner = | ||
baseContextRunner | ||
.withPropertyValues("sentry.dsn=http://key@localhost/proj", "sentry.traces-sample-rate=1.0") | ||
.withUserConfiguration( | ||
NoOpTransportConfiguration::class.java | ||
) // Use no-op transport to avoid network calls | ||
Comment on lines
+123
to
+128
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The I see that both the |
||
|
||
@Test | ||
fun `scopes is not created when auto-configuration dsn is not set`() { | ||
|
@@ -97,22 +134,17 @@ class SentryAutoConfigurationTest { | |
|
||
@Test | ||
fun `scopes is created when dsn is provided`() { | ||
contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj").run { | ||
assertThat(it).hasSingleBean(IScopes::class.java) | ||
} | ||
dsnEnabledRunner.run { assertThat(it).hasSingleBean(IScopes::class.java) } | ||
} | ||
|
||
@Test | ||
fun `OptionsConfiguration is created if custom one with name sentryOptionsConfiguration is not provided`() { | ||
contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj").run { | ||
assertThat(it).hasSingleBean(Sentry.OptionsConfiguration::class.java) | ||
} | ||
dsnEnabledRunner.run { assertThat(it).hasSingleBean(Sentry.OptionsConfiguration::class.java) } | ||
} | ||
|
||
@Test | ||
fun `OptionsConfiguration with name sentryOptionsConfiguration is created if another one with different name is provided`() { | ||
contextRunner | ||
.withPropertyValues("sentry.dsn=http://key@localhost/proj") | ||
dsnEnabledRunner | ||
.withUserConfiguration(CustomOptionsConfigurationConfiguration::class.java) | ||
.run { | ||
assertThat(it).getBeans(Sentry.OptionsConfiguration::class.java).hasSize(2) | ||
|
@@ -305,7 +337,7 @@ class SentryAutoConfigurationTest { | |
|
||
@Test | ||
fun `sets SDK version on sent events`() { | ||
contextRunner | ||
baseContextRunner | ||
.withPropertyValues("sentry.dsn=http://key@localhost/proj") | ||
.withUserConfiguration(MockTransportConfiguration::class.java) | ||
.run { | ||
|
@@ -410,7 +442,7 @@ class SentryAutoConfigurationTest { | |
|
||
@Test | ||
fun `sets release on SentryEvents if Git integration is configured`() { | ||
contextRunner | ||
baseContextRunner | ||
.withPropertyValues("sentry.dsn=http://key@localhost/proj") | ||
.withUserConfiguration( | ||
MockTransportConfiguration::class.java, | ||
|
@@ -429,7 +461,7 @@ class SentryAutoConfigurationTest { | |
|
||
@Test | ||
fun `sets custom release on SentryEvents if release property is set and Git integration is configured`() { | ||
contextRunner | ||
baseContextRunner | ||
.withPropertyValues("sentry.dsn=http://key@localhost/proj", "sentry.release=my-release") | ||
.withUserConfiguration( | ||
MockTransportConfiguration::class.java, | ||
|
@@ -742,7 +774,7 @@ class SentryAutoConfigurationTest { | |
|
||
@Test | ||
fun `when sentry-apache-http-client-5 is on the classpath, creates apache transport factory`() { | ||
contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj").run { | ||
baseContextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj").run { | ||
assertThat(it.getBean(SentryOptions::class.java).transportFactory) | ||
.isInstanceOf(ApacheHttpClientTransportFactory::class.java) | ||
} | ||
|
@@ -761,7 +793,7 @@ class SentryAutoConfigurationTest { | |
|
||
@Test | ||
fun `when sentry-apache-http-client-5 is on the classpath and custom transport factory bean is set, does not create apache transport factory`() { | ||
contextRunner | ||
baseContextRunner | ||
.withPropertyValues("sentry.dsn=http://key@localhost/proj") | ||
.withUserConfiguration(MockTransportConfiguration::class.java) | ||
.run { | ||
|
@@ -1097,6 +1129,15 @@ class SentryAutoConfigurationTest { | |
@Bean open fun sentryTransport() = transport | ||
} | ||
|
||
@Configuration(proxyBeanMethods = false) | ||
open class NoOpTransportConfiguration { | ||
|
||
@Bean | ||
open fun noOpTransportFactory(): ITransportFactory { | ||
return NoOpTransportFactory.getInstance() | ||
} | ||
} | ||
|
||
@Configuration(proxyBeanMethods = false) | ||
open class CustomBeforeSendCallbackConfiguration { | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.