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

approvals: use go-cmp instead of gojsondiff #2968

Merged
merged 2 commits into from
Nov 27, 2019
Merged

Conversation

axw
Copy link
Member

@axw axw commented Nov 27, 2019

While working on #2839, I found that large maps with many differences would lead to gojsondiff causing tests to churn CPU and eventually time out. This PR replaces use of gojsondiff with go-cmp, which has no such issues.

There is one functional difference: if the approval file is missing, we now compare the received JSON with null rather than {}. This is to cater for some uses of ApproveEvents with nil maps. Whereas gojsondiff will produce no diff when comparing nil and empty maps, go-cmp will. This is why some approval files have been added.

axw added 2 commits November 27, 2019 15:48
gojsondiff is unusably slow when comparing
large maps with many differences. I triggered
this in the profile integration tests, when
the `profile.id` field changed in every single
document. Use go-cmp instead, which is much faster.
@codecov-io
Copy link

Codecov Report

Merging #2968 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #2968   +/-   ##
=======================================
  Coverage   78.74%   78.74%           
=======================================
  Files          84       84           
  Lines        4380     4380           
=======================================
  Hits         3449     3449           
  Misses        931      931

Copy link
Contributor

@simitt simitt left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for the effort.

@simitt
Copy link
Contributor

simitt commented Nov 27, 2019

Failing tests are all unrelated, feel free to merge any time and please backport to 7.x

@axw axw merged commit 21207bc into elastic:master Nov 27, 2019
@axw axw deleted the approvals-gocmp branch November 27, 2019 08:24
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.

3 participants