-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[WIP-DO NOT MERGE] Add InjectFault and InjectLatency features #508
Conversation
Created this PR to get reviews on the top level functions. Will start working on the tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mebjas This is looking great. Thank you very much for all the work on it!
(Review here may look like lots of comments, but mainly it is just a simple few things repeating because of the repetitive Polly syntax model; the concept coded is 👍 .)
Func<Context, CancellationToken, Task<TResult>> action, | ||
Context context, | ||
CancellationToken cancellationToken, | ||
Func<Context, Task> fault, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Func<Context, CancellationToken, Task>
Func<Context, CancellationToken, Task<TResult>> action, | ||
Context context, | ||
CancellationToken cancellationToken, | ||
Func<Context, Task<Exception>> fault, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Func<Context, CancellationToken, Task<DelegateResult<TResult>>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah this is a todo, I'll add.
@mebjas Apart from minor review above we can move to adding tests 👍 (as you say). For writing deterministic unit tests for the code involving randomisation, an approach could be similar to the way existing Polly tests involving time abstract
(Time fits the ambient-context pattern for the dependency rather than constructor injection or property injection because there is a sensible local default and there are not known good use cases for varying the implementation in production. Similar arguments can apply to randomisation.) |
@reisenberger I have dealt with most of the comments. Had some comments in the |
@mebjas Thank you again for your contributions! Re:
If we adopt the same strategy as
Tests can then replace the
It's important then to add this attribute to classes containing tests which manipulate And: the test class should be IDisposable with the Dispose() method using a
(xUnit uses the Overall, this is the same pattern you can see in use with tests manipulating I will aim to check your other qs and the overloads in the coming days. |
@reisenberger pretty neat, thanks for that. The other question is around usage of |
- added proper engine for TReult based faults and implementation in InjectFault layer - RandomGenerator class corrected
- Added Tests for MonkeySyntax, MonkeyTResultSyntax, MonkeySyntaxAsync and MonkeyTResultSyntaxAsync
Covered all overloads
@reisenberger I have added decent amount of test cases to cover all syntaxes. Please have a look. |
I was just having a look at this PR out of curiosity, and I wondered is there any argument for the delegates for checking if faults being enabled in the async cases to also have an overload to accept a The use case I'm thinking of is for where someone might plumb in something where something external is called out to to determine if things are enabled or not? Of course that might be an edge-case and/or a bad idea, but thought I'd just throw the idea out there. |
Like this - https://github.com/mebjas/Polly/blob/dev-minhazv/src/Polly.Shared/Monkey/MonkeyEngineAsync.cs#L14 ? |
Yeah, like that. |
Yeah problems similar to this was addressed in one or other comments. And was implemented post that. @martincostello - Thanks! |
@reisenberger AFAIK the fluent assertion tests would be running in parallel. Even if I set RandomGenerator.GetRandomNumber = () => 0.1; and reset in |
Hi @mebjas . To force certain tests to not run in parallel, so that they don't cross-pollute:
(We should probably rename the attribute to something like: |
Added the attribute. The attribute is being used in a lot of places. Should it be renamed in this PR? |
Great, thanks! I am happy if you want to leave the renaming to me as a clean-up pass after we have finished all the changes for v6.2.0. |
Sounds great
|
@reisenberger sounds great!
Thanks @reisenberger for all your extra work on this! |
Thanks @reisenberger @vany0114 @bartelink |
Thank you @mebjas @vany0114 @bartelink . Courtesy update: I am likely to next get a chunk of time to progress, in late December. |
Thanks for this! Is there any documentation on how this hosting policies outside polly looks like? |
I have rebased the PR onto v7.0.0 branch, and am aiming to push a commit to show how the policies would join to the new v7.0.0 approach. Full documentation (for the wider user community) will also follow. |
@mebjas @vany0114 I was unable to push further changes to this PR, being today's modifications to bring everything into line with v7.0.0. (Maybe we have rebased the PR too many times ... not digging further now.) I have opened a separate PR #553 as a mechanism only to show you latest modifications:
Thanks for the huge amount of work you did @mebjas @vany0114 to get PR 508 to functionality-ready. My last piece here bridges us to a way forward with Simmy as a separate package to Polly v7; and implements the syntax preferences described in the consulation document. Any comment welcome. Next steps (probably not before next weekend) : Set up the new Simmy repo and build; and move the code over to it. Given the syntax preferences are done, I think the code as #553 is ready to go (in the new repo), bar trivial re-namespacing ( |
@mebjas @vany0114 Note: The state that #508 has got into due to repeated re-basing/upward merges, means we may not be able/be wise to do the merge/de-merge from to master on Polly (I'm not that happy about risking the state of the Polly master branch from this PR ...), but we will ensure that you get credit for this work all over the doco. Thanks! |
Thanks for all your work on this PR, looking forward to see Polly v7 and Simmy! |
@reisenberger I can see a lot of efforts were put into the redesign and it looks much more polished. Thanks for the contribution :) Look forward to the new repo and adaptation. |
Thanks @reisenberger |
Thanks @reisenberger! If you need some help, just let me know. |
@mebjas @vany0114 / anyone interested: I created the new repo for Simmy! Please head over! If you are interested to take up any of the items marked help-wanted, that will speed us all along! (Post on the issue to say anything you are picking up ...). Thanks! I am half-way thru the custom policy documentation, and will check in with something for all to read (and comment) soon as I can. Thanks! |
Guys, I picked this one up for now |
Hi @mebjas Re:
The Readme and Wiki of this repo. We also sometimes blog.
The readme directs people to sources of info on changes |
Bring Simmy codebase across from App-vNext/Polly#553 (and originally App-vNext/Polly#508). Represents original contributions by @vany0114 , @mebjas and @reisenberger, which @vany0114 has brought to the Simmy repo from Polly. Noting that all contributors @vany0114 , @mebjas and @reisenberger had signed the .NET Foundation Contributors License Agreement against the Polly repo.
Locking this thread so that conversation can relate to the latest issues and version of the codebase on the Simmy repo; interested users should head over there! If anyone has concerns/questions about anything mentioned higher up this thread, please do mention it on Simmy or the design thread here on Polly. |
Closing as this codebase now exists definitively in the Simmy repo, the readme now links out to Simmy and #499 still tracks on the issues page. |
The issue or feature being addressed
Support for failure / chaos injection policies to test resilience of the system. Being discussed in details - #499
Details on the issue fix or feature implementation
Introduced a base
Monkey
Policy along with support forPolicy.InjectFault
andPolicy.InjectLatency
as first class citizens in the library.Confirm the following