[CSHARP-3515] Sporadic tests failures: TestGuidRefId Created: 31/Mar/21 Updated: 28/Oct/23 Resolved: 16/Apr/21 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | BSON, Testing |
| Affects Version/s: | None |
| Fix Version/s: | 2.13.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Mikalai Mazurenka (Inactive) | Assignee: | Robert Stam |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Epic Link: | Improve Testing |
| Description |
|
MongoDB.Driver.Tests.MongoDBRefTests.TestGuidRefId fails occasionally.
|
| Comments |
| Comment by Githook User [ 16/Apr/21 ] | ||||||
|
Author: {'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}Message: | ||||||
| Comment by Robert Stam [ 07/Apr/21 ] | ||||||
|
I have not been able to reproduce this, but the theory is that one of the following global state properties has an unexpected value when the test is run:
These static properties were defined a very long time ago, and are lazily initialized. When initialized they capture some current values from BsonDefaults (which is also global state). Today we know that we should avoid global state, but this global state exists for historical reasons. The reason this global state might have unexpected values is because xUnit runs tests in random order, so depending on the order the tests were run in this global state might have different values. The proposed fix for this test is to ensure that this global state is saved at the beginning of the test, is set to a well defined state before the test is run, and restored to the prior state at the end of the test. This is accomplished by adding these values to the existing `GuidMode` class. This fix is general and can apply to any other test that also depends on this global state. |