mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-09-21 06:20:17 +00:00
If a URL test fails, display the Apache Request ID to aid debugging
This helps with #311.
This commit is contained in:
parent
7c47658bee
commit
e900dff28e
@ -26,6 +26,7 @@ my $case;
|
|||||||
my $helpmeplease = 0;
|
my $helpmeplease = 0;
|
||||||
my $testmode = 'DAVICAL';
|
my $testmode = 'DAVICAL';
|
||||||
my $save_location = "/var/log/davical";
|
my $save_location = "/var/log/davical";
|
||||||
|
my $request_id;
|
||||||
|
|
||||||
# Hash for eval'd Perl code to store long lived variables in
|
# Hash for eval'd Perl code to store long lived variables in
|
||||||
my %evaled;
|
my %evaled;
|
||||||
@ -75,7 +76,7 @@ die "You need to run this from the testing directory!\n"
|
|||||||
unless -d "tests";
|
unless -d "tests";
|
||||||
|
|
||||||
# Heuristics to work out if we should make $save_location elsewhere. We want
|
# Heuristics to work out if we should make $save_location elsewhere. We want
|
||||||
# /var/log/davical for the CI rig, but within the test directories for localo
|
# /var/log/davical for the CI rig, but within the test directories for local
|
||||||
# runs. Do we?
|
# runs. Do we?
|
||||||
if ($ENV{USER} ne 'testrunner') {
|
if ($ENV{USER} ne 'testrunner') {
|
||||||
$save_location = "tests/$suite/results/";
|
$save_location = "tests/$suite/results/";
|
||||||
@ -84,6 +85,11 @@ if ($ENV{USER} ne 'testrunner') {
|
|||||||
$save_location = "tests/$suite/results/";
|
$save_location = "tests/$suite/results/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Record the request_ids from the web server.
|
||||||
|
my $request_id_file = "$save_location/$case.request_id";
|
||||||
|
open(my $REQUEST_ID_FILE, "> $request_id_file")
|
||||||
|
|| die "Failed to open $request_id_file for writing";
|
||||||
|
|
||||||
my $datafile = $testdef;
|
my $datafile = $testdef;
|
||||||
$datafile =~ s{\.test$}{};
|
$datafile =~ s{\.test$}{};
|
||||||
push @arguments, "--header", 'X-DAViCal-Testcase: '.$datafile;
|
push @arguments, "--header", 'X-DAViCal-Testcase: '.$datafile;
|
||||||
@ -314,9 +320,10 @@ while( <TEST> ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! defined $url && ! defined $script && ! defined $sql_statement ) {
|
if ( ! defined $url && ! defined $script && ! defined $sql_statement
|
||||||
|
&& ! defined $perl_code ) {
|
||||||
print <<EOERROR ;
|
print <<EOERROR ;
|
||||||
The .test file must contain either a URL or a SCRIPT, or a QUERY.
|
The .test file must contain either at least one URL, SCRIPT, PERL, or QUERY.
|
||||||
EOERROR
|
EOERROR
|
||||||
exit (2);
|
exit (2);
|
||||||
}
|
}
|
||||||
@ -351,6 +358,13 @@ sub run_curl {
|
|||||||
while ( <RESULTS> ) {
|
while ( <RESULTS> ) {
|
||||||
my $line = $_;
|
my $line = $_;
|
||||||
|
|
||||||
|
# Grab the web server request_id for later reference
|
||||||
|
if ($line =~ /^Request-ID: (.*?)$/) {
|
||||||
|
$ENV{REQUEST_ID} = $1;
|
||||||
|
$request_id = $1;
|
||||||
|
print $REQUEST_ID_FILE "$1\n";
|
||||||
|
}
|
||||||
|
|
||||||
foreach my $replacement ( @$replacements ) {
|
foreach my $replacement ( @$replacements ) {
|
||||||
$line =~ s/$replacement->{'pattern'}/$replacement->{'replacement'}/;
|
$line =~ s/$replacement->{'pattern'}/$replacement->{'replacement'}/;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,8 +68,13 @@ check_result() {
|
|||||||
cat "${REGRESSION}/diffs/${TEST}"
|
cat "${REGRESSION}/diffs/${TEST}"
|
||||||
echo "======================================="
|
echo "======================================="
|
||||||
fi
|
fi
|
||||||
valid_answer=0
|
|
||||||
|
|
||||||
|
if [ -s "${REGRESSION}/results/${TEST}.request_id" ]; then
|
||||||
|
echo -e "\nLogging for the request(s) in this test will be in the Apache error log for\nthese request ID(s):\n"
|
||||||
|
cat "${REGRESSION}/results/${TEST}.request_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
valid_answer=0
|
||||||
while [ $valid_answer -eq 0 ]; do
|
while [ $valid_answer -eq 0 ]; do
|
||||||
if [ "${ACCEPT_ALL}" = "" ] ; then
|
if [ "${ACCEPT_ALL}" = "" ] ; then
|
||||||
read -p "[${TEST}] Accept new result [e/s/r/v/f/m/x/y/w/N/q/?]? " ACCEPT
|
read -p "[${TEST}] Accept new result [e/s/r/v/f/m/x/y/w/N/q/?]? " ACCEPT
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user