TT#81700 generate_test_tt2.pl: add P-LB-Uptime to common subst headers

* remove invite_conference_update media file, this has to be a link
* ngcpcfg apply executed outside /etc/ngcp-config seems to generate
  .ngcpcfg_perms file in $pwd so adding a workaround to avoid it
* bench.sh: support selecting the GROUP scenario
* show_flow_diff.pl: improve the diff output adding the values of
  the flows not only the names

Change-Id: I40db8433595168ce8d3ef061f77f02a1616ed980
changes/77/40177/2
Victor Seva 6 years ago
parent 6f6e07eba7
commit 36349d44d9

@ -1,21 +1,24 @@
#!/bin/bash #!/bin/bash
SKIP_CONFIG=false SKIP_CONFIG=false
PROFILE=CE PROFILE=CE
GROUP="${GROUP:-scenarios}"
usage() { usage() {
echo "Usage: bench.sh [-p PROFILE] [-C] [num_runs]" echo "Usage: bench.sh [-p PROFILE] [-C] [num_runs]"
echo "Options:" echo "Options:"
echo -e "\t-p CE|PRO default is CE" echo -e "\t-p CE|PRO default is CE"
echo -e "\t-C skips configuration of the environment" echo -e "\t-C skips configuration of the environment"
echo -e "\t-x set GROUP scenario. Default: scenarios"
echo -e "\t-h this help" echo -e "\t-h this help"
echo -e "num_runs default is 20" echo -e "num_runs default is 20"
} }
while getopts 'hCp:' opt; do while getopts 'hCp:x:' opt; do
case $opt in case $opt in
h) usage; exit 0;; h) usage; exit 0;;
C) SKIP_CONFIG=true;; C) SKIP_CONFIG=true;;
p) PROFILE=${OPTARG};; p) PROFILE=${OPTARG};;
x) GROUP=${OPTARG};;
*) echo "Unknown option $opt"; usage; exit 1;; *) echo "Unknown option $opt"; usage; exit 1;;
esac esac
done done
@ -28,7 +31,7 @@ if [ "${PROFILE}" != "CE" ] && [ "${PROFILE}" != "PRO" ]; then
fi fi
NUM=${1:-20} NUM=${1:-20}
RUN_OPS=(-C -c -r -p"${PROFILE}") RUN_OPS=(-C -c -r -p"${PROFILE}" -x"${GROUP}")
# clean previous # clean previous
rm -rf log_* result_* rm -rf log_* result_*
@ -39,8 +42,11 @@ export BASE_DIR
if ! "${SKIP_CONFIG}" ; then if ! "${SKIP_CONFIG}" ; then
export PERL5LIB="${BASE_DIR}/lib" export PERL5LIB="${BASE_DIR}/lib"
echo "add configuration for tests" echo "add configuration for tests"
./bin/config_debug.pl on ./bin/config_debug.pl -g"${GROUP}" on
ngcpcfg apply 'k-c-t on' (
cd /etc/ngcp-config || true
ngcpcfg apply "k-c-t ${GROUP} on"
)
fi fi
echo "$(date) - Starting $NUM tests" echo "$(date) - Starting $NUM tests"
@ -67,6 +73,9 @@ set +o pipefail
if ! "${SKIP_CONFIG}" ; then if ! "${SKIP_CONFIG}" ; then
echo "remove configuration for tests" echo "remove configuration for tests"
./bin/config_debug.pl off ./bin/config_debug.pl -g"${GROUP}" off
ngcpcfg apply 'k-c-t off' (
cd /etc/ngcp-config || true
ngcpcfg apply "k-c-t ${GROUP} off"
)
fi fi

@ -93,6 +93,8 @@ sub subst_common
$line =~ s/^: Sipwise .+/: Sipwise NGCP Proxy/; $line =~ s/^: Sipwise .+/: Sipwise NGCP Proxy/;
} elsif($line =~ /^Content-Length: [1-9]/i) { } elsif($line =~ /^Content-Length: [1-9]/i) {
$line =~ s/: \d+/: \\d+/; $line =~ s/: \d+/: \\d+/;
} elsif($line =~ /^P-LB-Uptime: /i) {
$line =~ s/: \d+/: \\d+/;
} }
return $line; return $line;
} }

@ -29,6 +29,7 @@ use YAML::XS;
use utf8; use utf8;
use JSON; use JSON;
use Text::Diff; use Text::Diff;
use Scalar::Util qw(reftype);
sub usage sub usage
{ {
@ -59,21 +60,49 @@ my $log;
$log = decode_json($json); $log = decode_json($json);
} }
sub str_values
{
my $data = shift;
my $res = shift;
foreach my $key (keys %{$data})
{
my $_type = defined(reftype($data->{$key})) ? reftype($data->{$key}) : "HASH";
if( $_type eq 'ARRAY') {
$res .= " ".$key.": [\n";
foreach my $val (@{$data->{$key}}){
$res .= " ".$val.",\n";
}
$res .= " ]\n";
} elsif( $_type eq 'HASH') {
$res .= " ".$key.": ".$data->{$key}."\n";
}
}
return $res;
}
my $text_yml = ""; my $text_yml = "";
foreach my $i (@{$test->{'flow'}}) foreach my $i (@{$test->{'flow'}})
{ {
foreach my $key (keys %{$i}) foreach my $key (keys %{$i})
{ {
$text_yml .= " - ".$key.":\n"; $text_yml .= " - ".$key.":\n";
if($i->{$key}) {
$text_yml = str_values($i->{$key}, $text_yml);
}
} }
} }
my $text_json = ""; my $text_json = "";
foreach my $i (@{$log->{'flow'}}) while (my ($index, $element) = each(@{$log->{'flow'}}))
{ {
foreach my $key (keys %{$i}) my $element_yml = @{$test->{'flow'}}[$index];
foreach my $key (keys %{$element})
{ {
$text_json .= " - ".$key.":\n"; $text_json .= " - ".$key.":\n";
if(defined($element_yml->{$key})) {
$text_json = str_values($element_yml->{$key}, $text_json);
}
} }
} }

@ -32,6 +32,7 @@ echo "$(date) - Removed apicert.pem"
rm -f "${BASE_DIR}/apicert.pem" rm -f "${BASE_DIR}/apicert.pem"
echo "$(date) - Setting config debug on" echo "$(date) - Setting config debug on"
"${BIN_DIR}/config_debug.pl" -g "${GROUP}" on ${DOMAIN} "${BIN_DIR}/config_debug.pl" -g "${GROUP}" on ${DOMAIN}
cd /etc/ngcp-config || exit 3
if ! ngcpcfg apply "config debug on via kamailio-config-tests" ; then if ! ngcpcfg apply "config debug on via kamailio-config-tests" ; then
echo "$(date) - ngcpcfg apply returned $?" echo "$(date) - ngcpcfg apply returned $?"
error_flag=4 error_flag=4

Loading…
Cancel
Save