If a URL test fails, display the Apache Request ID to aid debugging

This helps with #311.
This commit is contained in:
Andrew Ruthven 2024-04-02 00:07:59 +13:00
parent 7c47658bee
commit e900dff28e
2 changed files with 23 additions and 4 deletions

View File

@ -26,6 +26,7 @@ my $case;
my $helpmeplease = 0;
my $testmode = 'DAVICAL';
my $save_location = "/var/log/davical";
my $request_id;
# Hash for eval'd Perl code to store long lived variables in
my %evaled;
@ -75,7 +76,7 @@ die "You need to run this from the testing directory!\n"
unless -d "tests";
# 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?
if ($ENV{USER} ne 'testrunner') {
$save_location = "tests/$suite/results/";
@ -84,6 +85,11 @@ if ($ENV{USER} ne 'testrunner') {
$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;
$datafile =~ s{\.test$}{};
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 ;
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
exit (2);
}
@ -351,6 +358,13 @@ sub run_curl {
while ( <RESULTS> ) {
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 ) {
$line =~ s/$replacement->{'pattern'}/$replacement->{'replacement'}/;
}

View File

@ -68,8 +68,13 @@ check_result() {
cat "${REGRESSION}/diffs/${TEST}"
echo "======================================="
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
if [ "${ACCEPT_ALL}" = "" ] ; then
read -p "[${TEST}] Accept new result [e/s/r/v/f/m/x/y/w/N/q/?]? " ACCEPT