Support Spring Data's Repository interface
As far as I know (and as it is documented), the repository watcher (chaos.monkey.watcher.repository) only supports the @Repository stereotype.
There are use-cases where repositories are created without the user annotating them with the @Repository annotation.
E.g.: Spring Data JPA, Spring Data Rest, etc. generates implementation for interfaces that extend org.springframework.data.repository.Repository (or one of it's sub-interface like CrudRepository or PagingAndSortingRepository). These repositories are not watched by the repository watcher.
Expected Behavior
org.springframework.data.repository.Repository instances should be watched if chaos.monkey.watcher.repository is set to true.
Current Behavior
org.springframework.data.repository.Repository instances are not watched if chaos.monkey.watcher.repository is set to true.
Possible Solution
I'm not very familiar with the internals of the projects but loosening the predicate that decides if a bean is watched or not during scanning should solve this (I guess).
Steps to Reproduce
I think this is by-design but
here's a reproducer; you need to re-enable chaos-monkey and set chaos.monkey.watcher.repository=true.
Context (Environment)
I would like to inject errors and latency inside of my application close to the DB. I'm using Spring Boot 2.7.0 (latest right now)
I think this is supposed to already work that way, hence the bug label.
Update: This does work usually. I have not yet been able to identify why it doesn't work in your project. You could help us by slimming down the project to a minimum viable reproducer.
@F43nd1r I slimmed down one of your sample apps and it seems it does not work on my box: https://github.com/jonatan-ivanov/chaos-monkey-spring-boot/tree/spring-data-jpa-demo (the diff is not very nice so I recommend viewing the code, it's small)
A few notes for the demo app:
- I removed
@Repositoryfrom theHelloRepositoryinterface, the@Repositorystereotype is not for this use-case, it is not needed - If you call the
http://localhost:8080/helloendpoint (see:HelloController), chaos monkey does work:chaos.monkey.watcher.rest-controller=true - If you call the
http://localhost:8080/helloes(see:HelloRepository), chaos monkey does nothing:chaos.monkey.watcher.repository=true
Please let me know if you were able to repro the issue with this sample.
Your demo works as expected for me. Please note that enabling multiple assaults (exception and latency) means one will be picked at random, so not every request fails.
This issue was marked as stale because it has been open and waiting for feedback for 60 days with no activity. If no feedback is provided within 14 days, this will be closed.
@jonatan-ivanov This is probably fixed with #335. It works with the latest snapshot (instructions here.
Would be great if you let usknow if it works in your use case as well :)