TT#139455 instances-info: Make output reproducible

We need to specify what to sort on, otherwise we are sorting based on
the references and not the actual keys. Add specific code blocks to sort
on the hash keys we are interested in. This makes the output
reproducible which makes the tests always pass, instead of randomly
failing depending on the ordering used randomly by perl.

Fixes: commit 83003649e3
Change-Id: I3dfc031a6c76db5153b7d05f6058e88d4b101599
(cherry picked from commit e48864fc33)
mr10.5.1
Guillem Jover 4 years ago
parent 62912d41fe
commit 96c059d1a0

@ -92,7 +92,7 @@ sub show_match {
$path = $bpath;
}
foreach my $info (sort @{$dirs->{$path}}) {
foreach my $info (sort { $a->{name} cmp $b->{name} } @{$dirs->{$path}}) {
my $dest;
if(defined $spath && defined $suffix) {
$dest = $info->{dest}."/${suffix}";
@ -106,11 +106,11 @@ sub show_match {
sub prepare_info {
return 0 unless defined $yaml->{instances};
foreach my $instance ( sort @{ $yaml->{instances} } ) {
foreach my $instance (sort { $a->{name} cmp $b->{name} } @{$yaml->{instances}}) {
$instances->{ $instance->{label} } //= ();
push @{ $instances->{ $instance->{label} } }, $instance->{name};
}
foreach my $def ( sort @{ $templ->{sources} } ) {
foreach my $def (sort { $a->{orig} cmp $b->{orig} } @{$templ->{sources}}) {
my $inst = $instances->{ $def->{label} };
next unless $inst;
my $orig = prefix_root $def->{orig};

@ -1,6 +1,6 @@
/etc/kamailio/lb:/etc/kamailio/lb_B:B
/etc/kamailio/lb:/etc/kamailio/lb_A:A
/etc/momo:/etc/momo_B:B
/etc/kamailio/lb:/etc/kamailio/lb_B:B
/etc/momo:/etc/momo_A:A
/etc/other/lb:/etc/other/lb_B:B
/etc/momo:/etc/momo_B:B
/etc/other/lb:/etc/other/lb_A:A
/etc/other/lb:/etc/other/lb_B:B

@ -1,2 +1,2 @@
/etc/kamailio/lb/db:/etc/kamailio/lb_B/db:B
/etc/kamailio/lb/db:/etc/kamailio/lb_A/db:A
/etc/kamailio/lb/db:/etc/kamailio/lb_B/db:B

@ -1,2 +1,2 @@
/etc/kamailio/lb:/etc/kamailio/lb_B:B
/etc/kamailio/lb:/etc/kamailio/lb_A:A
/etc/kamailio/lb:/etc/kamailio/lb_B:B

@ -1,6 +1,6 @@
/etc/kamailio/lb:/etc/kamailio/lb_B:B
/etc/kamailio/lb:/etc/kamailio/lb_A:A
/etc/momo:/etc/momo_B:B
/etc/kamailio/lb:/etc/kamailio/lb_B:B
/etc/momo:/etc/momo_A:A
/etc/other/lb:/etc/other/lb_B:B
/etc/momo:/etc/momo_B:B
/etc/other/lb:/etc/other/lb_A:A
/etc/other/lb:/etc/other/lb_B:B

Loading…
Cancel
Save