Get all parameters at once to avoid conflicts in parallel testing#211
Merged
alexeyzimarev merged 4 commits intoEventuous:devfrom May 2, 2023
Alejandro-SB:dev
Merged
Get all parameters at once to avoid conflicts in parallel testing#211alexeyzimarev merged 4 commits intoEventuous:devfrom Alejandro-SB:dev
alexeyzimarev merged 4 commits intoEventuous:devfrom
Alejandro-SB:dev
Conversation
alexeyzimarev
approved these changes
May 2, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR should hopefully close #181.
A testing branch was created here to check the scenario.
As #181 explains, this problem arises when tests are being executed in parallel, randomly throwing
ArgumentNullExceptionin theAllStreamSubscriptionconstructor.After debugging this case, this was narrowed down to the
SubscriptionBuilder.ResolveSubscriptionmethod. Although I still don't know exactly why, the execution goes as follows.First, the
GetConstructors<TOptions>extension method is called, returning the constructors that haveTOptionsas a parameter.eventuous/src/Core/src/Eventuous.Subscriptions/Registrations/SubscriptionBuilder.cs
Line 194 in 3209ab3
This extension method returns the constructor and also the
TOptionsParameterInfoin a tuple.Then, in line 216,
GetParametersis called again to get this constructor parameters and map them to their correct value.eventuous/src/Core/src/Eventuous.Subscriptions/Registrations/SubscriptionBuilder.cs
Line 216 in 3209ab3
Finally, in line 224, a check is run to see if the parameter being mapped to its correct value is the options parameter, to get them from the IMonitorOptions.
eventuous/src/Core/src/Eventuous.Subscriptions/Registrations/SubscriptionBuilder.cs
Line 224 in 3209ab3
For some reason, when working in parallel, although they refer to the same parameter, they are completely different instances and don't match, omitting this check and returning null. To fix it, this PR returns only one array with the parameters of the constructor, avoiding the second call.
In the testing branch mentioned earlier, this behaviour can be replicated with ease. If line 220 is uncommented, test will start to fail, as now the
GetParameters()method is returning different instances of the parameter.Also, a
System.Diagnostics.Debugger.Launch()is set in line 252 to debug this problem.