You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
os-autoinst/0001-add-an-option-to-uploa...

62 lines
2.0 KiB

From cbe86deb74ba4ac216227d2e6f4e12d9d06f150a Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
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 | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/testapi.pm b/testapi.pm
index 78ef865..1c1bb21 100755
--- a/testapi.pm
+++ b/testapi.pm
@@ -1004,21 +1004,32 @@ sub data_url($) {
=head2 upload_logs
- upload_logs $file;
+ upload_logs($file [, failok => 0 ]);
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 = shift;
+ my %args = @_;
+ my $failok = $args{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