-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Unstable test "should reload config on change" #1700
Comments
@ggnaegi Hey Guillaume! |
@raman-m Ok, we have a problem here. How could I possibly reproduce the same conditions as the CI Pipeline? In xUnit, tests (facts) are designed to be run in isolation, which means there's no guaranteed order of execution. This is intentional and follows the unit testing best practice of ensuring that each test is independent and doesn't rely on state changes from other tests. |
@raman-m What we could do, is provide a factory for the configuration files and change the configuration files id depending on the facts |
@ggnaegi
1st solution is sequential. Complexity: I'm okay with all three solutions because they fix stability of the test. Please, choose the favorite solution which you're liking... |
@raman-m 1 is ok, but xunit assumes the facts in the same class are isolated and side effects free. So it would mean, we would have to refactor the code like that:
It's a bit ugly, no. So that is why I came up with the factory idea... |
@ggnaegi You can simply extract all tests that use ocelot.json to a separate class and disable parallelizm on them. |
@raman-m Yeah well, it's sunday, it's mistakes prone... |
I like the 2nd solution to run test on a separate test file. |
@raman-m We have 168 references to |
In xUnit, each [Fact] or [Theory] method gets a fresh instance of the test class. This means that any instance variables you've declared in the class are re-instantiated for each test method. So, the Steps class is re-instantiated for each test method. So each fact/theory has his own Steps instance. Maybe we could use a uuid in Steps class and create a path like uuid-ocelot.json In Dispose, we would delete the uuid-ocelot.json file. @raman-m I have the feeling, that would be a good solution... |
@ggnaegi |
@raman-m As you can see, I can reproduce the error with Open_circuit_should_not_effect_different_route(). After 133 iterations it eventually failed. |
…g parallel execution (#1703) * When instantiating steps, creating a custom ocelot config file name. Finally deleting the newly created config file when disposing the Step instance. * Removing DeleteOcelotConfig from GivenThereIsAConfiguration, since File.WriteAllText will overwrite the file. * using xunit.runner.json it's getting on my nerves * Trying yet another strategy * Revert "using xunit.runner.json it's getting on my nerves" This reverts commit 9fac778. * Not sure about GC.SuppressFinalize here * correct usage of Wait.WaitFor... * Do we really need to get a random port? Wouldn't be enough to get the next available port? Adding lock for thread safety * Updating duration of break in Open_circuit_should_not_effect_different_routes from 1000 ms to 1500 ms * ConfigurationReloadTests as sealed class * moving variables initializations to Steps constructor * putting back during of break to 1000, out of scope of current PR * Code review --------- Co-authored-by: raman-m <[email protected]>
* Add sequential tests with disabled parallelization
Expected Behavior
The test
should_reload_config_on_change
doesn't fail in 100% of runningActual Behavior / Motivation for New Feature
Currently the test should_reload_config_on_change fails sometimes: in 1/3 or even 1/2 cases.
Possible reason: multithreading for file access when test class tests being run in parallel.
Steps to Reproduce the Problem
develop builds:
PR builds:
Specifications
The text was updated successfully, but these errors were encountered: