Chaos Monkey Spring Boot 在开发环境中工作,但在测试环境中不适用于功能测试

Chaos Monkey Spring Boot works in dev environment but doesn't work for functional test in test environment

我正在尝试 运行 ChaosMonkey 进行弹性测试。我正在使用 Spring BootWebTestClient Class 在黄瓜功能弹性测试中发出 api 请求。响应显示 Chaos Monkey 延迟配置正确,但我没有看到任何延迟。有谁知道为什么它对我的测试不起作用?

我的观察者配置(测试中的请求):

{
    "controller": false,
    "restController": false,
    "service": false,
    "repository": false,
    "component": false,
    "restTemplate": false,
    "webClient": false,
    "actuatorHealth": false,
    "beans": []
}

我的攻略配置(测试中求):

{
    "level":1,
    "latencyRangeStart":5000,
    "latencyRangeEnd":5000,
    "latencyActive":true,
    "watchedCustomServices":["com.my.correct.repository.ClassName"]
}

我的 application-test.properties 文件与我的 application-dev.properties 文件匹配,这确实有效。

spring.profiles.include=resilience4J-test,chaos-monkey
server.error.include-message=always

chaos.monkey.enabled=true

management.endpoint.chaosmonkey.enabled=true
management.endpoint.chaosmonkeyjmx.enabled=true
management.endpoints.web.exposure.include=health,info,chaosmonkey
management.endpoint.health.show-details=always
management.health.circuitbreakers.enabled=true
management.endpoint.circuitbreakers.enabled=true

我正在使用 Chaos Monkey 2.5.4Spring Boot 2.3.12

其实我刚刚发现你需要将@ComponentScan 添加到测试应用程序中,以便 Chaos monkey 可以发现组件和注释。现在对我来说很好用。