From a9d0babcbd2619db48f1be5c2ffcf9323793b6a5 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Fri, 29 Apr 2016 12:05:55 -0700 Subject: [PATCH] add an option to upload_logs to avoid dying on failure in Fedora we use upload_logs a lot in post-fail hooks, and in some cases the file may not exist. For instance, anaconda creates lots of log files, some of which may not exist in some circumstances. We would like to just be able to try and upload them all but not have the post-fail hook die if any of them does not exist, instead of having to test for each file's existence before uploading it, or have a bunch of conditionals that magically know which log files will exist in which state. --- testapi.pm | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/testapi.pm b/testapi.pm index 78ef865..e6fa7ae 100755 --- a/testapi.pm +++ b/testapi.pm @@ -1004,21 +1004,31 @@ sub data_url($) { =head2 upload_logs - upload_logs $file; + upload_logs $file [,$failok]; Upload C<$file> to OpenQA WebUI as a log file and -return the uploaded file name. +return the uploaded file name. If failok is not set, a failed upload +will cause the test to die. Failed uploads happen if the file does not +exist or is over 20GiB in size, so failok is useful when you just want +to upload the file if it exists but not mind if it doesn't. =cut sub upload_logs { - my ($file) = @_; + my ($file, $failok) = @_; + $failok //= 0; bmwqemu::log_call('upload_logs', file => $file); my $basename = basename($file); my $upname = ref($autotest::current_test) . '-' . $basename; my $cmd = "curl --form upload=\@$file --form upname=$upname "; $cmd .= autoinst_url("/uploadlog/$basename"); - assert_script_run($cmd); + if ($failok) { + # just use script_run so we don't care if the upload fails + script_run($cmd); + } + else { + assert_script_run($cmd); + } return $upname; } -- 2.7.4