mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 13:11:32 +00:00
Fix and test resource_diff().
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
{
|
||||
package Percona::WebAPI::Util;
|
||||
|
||||
use JSON;
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
|
||||
use Percona::WebAPI::Representation;
|
||||
@@ -32,8 +33,12 @@ sub resource_diff {
|
||||
my ($x, $y) = @_;
|
||||
return 0 if !$x && !$y;
|
||||
return 1 if ($x && !$y) || (!$x && $y);
|
||||
return md5_hex(Percona::WebAPI::Representation::as_json($x))
|
||||
ne md5_hex(Percona::WebAPI::Representation::as_json($y));
|
||||
my $json = JSON->new->canonical([1]); # avoid hash key sort diffs
|
||||
my $x_hex = md5_hex(
|
||||
Percona::WebAPI::Representation::as_json($x, json => $json));
|
||||
my $y_hex = md5_hex(
|
||||
Percona::WebAPI::Representation::as_json($y, json => $json));
|
||||
return $x_hex eq $y_hex ? 0 : 1;
|
||||
}
|
||||
|
||||
1;
|
||||
|
Reference in New Issue
Block a user