弹簧集成测试消耗大量内存,在GradleWorkerMain中使用大量重复线程备选案文1.配置渐变测试任务备选案文2.向测试资源添加 spring.properties结论奖金
我有一个有点复杂的Spring Boot应用程序,有大量的测试。
在运行测试时,它似乎正在积累很多线程,其中一个线程有多个实例,并且被称为 ,我将其追溯到此依赖项SimplePauseDetectorThread_0
| | | \--- io.micrometer:micrometer-core:1.1.1
| | | +--- org.latencyutils:LatencyUtils:2.0.3
这似乎发生在Spring Boot 2.0.6以及2.1.1上。
典型的测试可能如下所示:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK)
@ActiveProfiles(profiles = {"test"})
public class MyTest {
[...]
我的执行器配置如下所示:
management.endpoints.enabled-by-default=false
management.endpoint.prometheus.enabled=true
management.endpoints.web.base-path=/
management.endpoints.web.exposure.include=prometheus
management.endpoints.web.path-mapping.prometheus=prometheus
spring.metrics.prometheus.enabled=true
查看随附的屏幕截图