RecordMatcher fails with doubles on different runtime versions
See original GitHub issueI have some doubles in both requests and reponses, and the RecordMatcher
has a problem with doubles in requests on .NET 5.0 vs older versions. For example, here’s what I get in a test that was recorded with .NET 5.0 but used on older runtimes:
Message:
Azure.Core.TestFramework.TestRecordingMismatchException : Unable to find a record for the request POST https://wuppe.api.cognitive.microsoft.com/language/:query-knowledgebases?projectName=190a9e13-8ede-4e4b-a8fd-c4d7f2aeab6c&deploymentName=test&api-version=2021-05-01-preview
Header differences:
<Content-Length> values differ, request <360>, record <328>
Body differences:
Request and response bodies do not match at index 109:
request: "shold":0.20000000000000001,"co"
record: "shold":0.2,"context":{"previou"
I can disable body comparisons, but I’m wondering if we could have the recording framework somehow inject a double converter to control precision.
For example, I believe Newtonsoft.Json uses double.ToString("R")
so maybe we could as well, or even pass something like “f8” to always emit 8 decimal places (or whatever number) unconditionally.
Issue Analytics
- State:
- Created 2 years ago
- Comments:21 (21 by maintainers)
Top Results From Across the Web
Synthetics runtime versions - Amazon CloudWatch
Explains the versions of CloudWatch Synthetics runtimes, libraries, and configuration information.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m not sure this is worth fixing in lieu of simpler workarounds like only disabling body compare when not on framework like we are doing here:
https://github.com/Azure/azure-sdk-for-net/blob/bd5c715e0b25f80fee7e78f779c1cab9f6387f50/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/tests/ObjectAnchorsConversionClientLiveTests.cs#L38-L42
Speaking of recording on Core, I opened #31768 that might help. Right now, if you just press the “Play” button in Test Explorer, net461 will run first and all tests get recorded there and used in subsequent (“Core”) runtimes. I want to default test runs to the latest and “filter” the test coverage reports similar. The order as it is was intentional, though someone effectively “broke” it when they added “net6.0” last.