Search code examples
springspring-bootintegration-testingcucumber-junitspring-boot-chaos-monkey

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


I am trying to run ChaosMonkey for my resilience tests. I'm using Spring Boot and the WebTestClient Class to make api requests in cucumber functional resilience tests. The responses show that Chaos Monkey latency is configured correctly, but I don't see any latency. Does anyone know why it's not working for my tests?

My watcher configuration (request from within the test):

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

My assault configuration (request from within the test):

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

My application-test.properties file matches my application-dev.properties file, which DOES WORK.

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

I'm using Chaos Monkey 2.5.4 and Spring Boot 2.3.12


Solution

  • I actually just figured out that you need to add @ComponentScan to the test app so that Chaos monkey can discover the components and annotations. It works fine for me now.