From bddc4d61526a9fa5149c47feec4b26e650dcb3d8 Mon Sep 17 00:00:00 2001 From: Mykola Malkov Date: Wed, 7 Sep 2022 15:01:23 +0300 Subject: [PATCH] TT#133502 Exit with non-zero if schemes are different If formatter=tap is used - exit with 0 code so jenkins can parse tap report. If this option is not set - exit 0 if schemes are equal but exit 1 if they are not. Change-Id: Ie1f034205acde538187e016e51ebad1caf555d91 --- helper/compare_dbs.pl | 3 ++- sbin/ngcp-mysql-compare-dbs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/helper/compare_dbs.pl b/helper/compare_dbs.pl index 6686eb9..3c03611 100755 --- a/helper/compare_dbs.pl +++ b/helper/compare_dbs.pl @@ -184,13 +184,13 @@ foreach my $schema ( split( / /, $argv->{schemes} ) ) { $struct2 = $dbh2->selectall_hashref( $queries->{$obj}, 'key_col' ); unless ( Compare($struct1, $struct2) ) { - $exit = 1; print_diff($struct1, $struct2, $obj, $res, $schema); } } } if ( $argv->{formatter} eq 'tap' ) { + $exit = 0; tap_output(); } else { @@ -316,6 +316,7 @@ sub tap_output { sub human_output { my $number = scalar(@{$res}); if ( $number > 0 ) { + $exit = 1; print "The following errors were found:\n\n"; foreach my $err ( @{$res} ) { print "$err\n"; diff --git a/sbin/ngcp-mysql-compare-dbs b/sbin/ngcp-mysql-compare-dbs index 04c3fc7..bf82541 100755 --- a/sbin/ngcp-mysql-compare-dbs +++ b/sbin/ngcp-mysql-compare-dbs @@ -62,4 +62,4 @@ if [[ -n "${FORMATTER}" ]]; then fi /usr/share/ngcp-system-tests/compare_dbs.pl \ --schemes="${NGCP_DB_BACKUP_FINAL_LIST[*]}" \ - "${opts[@]}" || true + "${opts[@]}"