I want to inject java.sql.SQLException Exception Assault using CM4SB library in target spring boot application for org.springframework.data.repository.CrudRepository.findById method.
Need help with working Assault-watcher configuration.
I tried multiple way but could not get any working solution.
I referred - https://codecentric.github.io/chaos-monkey-spring-boot/latest/#_properties for assault-watcher configuration.
Appreciate your helps !! Thanks !!
Configure Chaos Monkey to target repository methods like findById().
chaos.monkey.enabled=trueEnsure you have a Spring Data repository:
@Service
public class UserService {
@Autowired
private UserRepository userRepository;
public User getUserById(Long id) {
return userRepository.findById(id)
.orElseThrow(() -> new RuntimeException("User not found"));
}
}
Run your application and test calling the endpoint. If CM4SB is enabled, some requests will fail with SQLException as configured.
If you need dynamic control, enable Spring Boot Actuator and Chaos Monkey:
management.endpoints.web.exposure.include=chaosmonkey
management.endpoint.chaosmonkey.enabled=true
Then, toggle assaults dynamically via:
curl -X POST http://localhost:8080/actuator/chaosmonkey/assaults/exception
Make sure chaos.monkey.watcher.repository=true is enabled.
cheers