Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Spring Data's Repository interface #317

Closed
jonatan-ivanov opened this issue May 31, 2022 · 6 comments
Closed

Support Spring Data's Repository interface #317

jonatan-ivanov opened this issue May 31, 2022 · 6 comments

Comments

@jonatan-ivanov
Copy link

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)

@F43nd1r
Copy link
Member

F43nd1r commented Jun 3, 2022

I think this is supposed to already work that way, hence the bug label.

@F43nd1r F43nd1r added the bug label Jun 3, 2022
@F43nd1r
Copy link
Member

F43nd1r commented Jun 3, 2022

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.

@jonatan-ivanov
Copy link
Author

jonatan-ivanov commented Jun 4, 2022

@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 @Repository from the HelloRepository interface, the @Repository stereotype is not for this use-case, it is not needed
  • If you call the http://localhost:8080/hello endpoint (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.

@F43nd1r
Copy link
Member

F43nd1r commented Jun 10, 2022

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.

@github-actions
Copy link

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.

@github-actions github-actions bot added the Stale label Oct 19, 2022
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 3, 2022
@WtfJoke
Copy link
Contributor

WtfJoke commented Feb 5, 2023

@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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants