Skip to content
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

Compare bodies in playback tests #11624

Merged
merged 13 commits into from
Apr 28, 2020
Merged

Conversation

pakrym
Copy link
Contributor

@pakrym pakrym commented Apr 27, 2020

We've got em, let's use them

Copy link
Member

@tg-msft tg-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice change.

/// <param name="sanitizer">The test record sanitizer.</param>
public StorageRecordMatcher(RecordedTestSanitizer sanitizer)
: base(sanitizer)
public StorageRecordMatcher()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is already doing its own body comparison to determine whether or not we need to re-record. How does that fit with your vision here? Should we gut this type since we're now doing body comparisons in a more formal way?

Also, can we pass false to the base .ctor for the time being and file an issue about turning it back on? There are a lot of features being developed in other branches and I don't want to randomize them.

Copy link
Contributor Author

@pakrym pakrym Apr 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the IsEquivalent check that allows us to avoid unneeded re-recording should stay as it covers way more cases than byte-by-byte strict comparison here.

Also, can we pass false to the base .ctor for the time being and file an issue about turning it back on? There are a lot of features being developed in other branches and I don't want to randomize them.

Done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm misinterpreting @tg-msft's comment here, but does the system already determine if sessions need re-recording, or is that what he's suggesting? It would be nice if it did, but to date I've not seen that behavior and instead have been relying on committing files I know need to change, or robocopying all recordings over and checking if anything of substance changed in the git diffs.

Copy link
Contributor Author

@pakrym pakrym Apr 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a way to specify if re-recording is required but it's not plug-and-play as other framework features, it needs per library customization most of the time to know what's not important.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the test framework uses your RecordMatcher to determine whether the new record is consistent with what's already on disk so we're not always updating the recording files every time an ETag changes. I've got additional logic for Storage to ignore volatile fields in bodies, but it's super clunky because we have to support XML and JSON at the same time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't the files in artifacts/bin/{AssemblyName}/Debug/netstandard2.0/SessionRecords always recorded? I knew about the matcher, but thought it was up to us to determine which to copy. If there's something that will avoid writing out new files, I'd love to learn more. I've just never seen this behavior in KV or Search.

Copy link
Member

@annelo-msft annelo-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pakrym
Copy link
Contributor Author

pakrym commented Apr 28, 2020

/azp run net - search - ci

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pakrym
Copy link
Contributor Author

pakrym commented Apr 28, 2020

/azp run net - storage - ci

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pakrym pakrym merged commit e87a28d into Azure:master Apr 28, 2020
@pakrym pakrym deleted the pakrym/compare-bodies branch April 28, 2020 16:04
@@ -29,6 +29,8 @@ public partial class CertificateClientLiveTests : CertificatesTestBase
{
public CertificateClientLiveTests(bool isAsync, CertificateClientOptions.ServiceVersion serviceVersion) : base(isAsync, serviceVersion)
{
// TODO: https://github.com/Azure/azure-sdk-for-net/issues/11634
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Key Vault body differences aren't really something we can solve since we're generating keys on the server (will always be different). We could write our own matcher, but I imagine this problem will be common. Could we instead consider an approach that allows us to specify what should be ignored. For example, for JSON (most of our body content across the clients) we could specify JSONPaths. A comparer could do a recursive JSON object comparison and ignore anything specified by the JSONPath (or some filter). Idea for a future iteration, but seeing if anyone is open to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a good idea that we should try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants