-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify error handling of downloader, avoid confusing error codes
* Remove the made-up HTTP response codes introduced by aea93ad (e.g. just log `Connect timeout` instead of `521 Connect timeout`) * Simplify the code * Keep retry behavior as-is, so if there's no response code at all or a real 5xx error code the downloader tries again * Simplify code * See https://progress.opensuse.org/issues/164222
- Loading branch information
Showing
2 changed files
with
29 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,15 +69,15 @@ $ua->connect_timeout(0.25)->inactivity_timeout(0.25); | |
|
||
subtest 'Connection refused' => sub { | ||
my $from = "http://$host/tests/922756/asset/hdd/[email protected]"; | ||
like $downloader->download($from, $to), qr/Download of "$to" failed: 521/, 'Failed'; | ||
like $downloader->download($from, $to), qr/Download of "$to" failed: Connection refused/, 'Failed'; | ||
|
||
ok !-e $to, 'File not downloaded'; | ||
|
||
like $cache_log, qr/Downloading "test.qcow" from "$from"/, 'Download attempt'; | ||
like $cache_log, qr/Download of "$to" failed: 521/, 'Real error is logged'; | ||
like $cache_log, qr/Download error 521, waiting .* seconds for next try \(2 remaining\)/, '2 tries remaining'; | ||
like $cache_log, qr/Download error 521, waiting .* seconds for next try \(1 remaining\)/, '1 tries remaining'; | ||
unlike $cache_log, qr/Download error 521, waiting .* seconds for next try \(3 remaining\)/, 'only 3 attempts'; | ||
like $cache_log, qr/Download of "$to" failed: Connection refused/, 'Real error is logged'; | ||
like $cache_log, qr/Download error, waiting .* seconds for next try \(2 remaining\)/, '2 tries remaining'; | ||
like $cache_log, qr/Download error, waiting .* seconds for next try \(1 remaining\)/, '1 tries remaining'; | ||
unlike $cache_log, qr/Download error, waiting .* seconds for next try \(3 remaining\)/, 'only 3 attempts'; | ||
$cache_log = ''; | ||
}; | ||
|
||
|
@@ -112,14 +112,14 @@ subtest 'Success' => sub { | |
|
||
subtest 'Connection closed early' => sub { | ||
my $from = "http://$host/tests/922756/asset/hdd/[email protected]"; | ||
like $downloader->download($from, $to), qr/Download of "$to" failed: 521 Premature connection close/, 'Failed'; | ||
like $downloader->download($from, $to), qr/Download of "$to" failed: Premature connection close/, 'Failed'; | ||
|
||
ok !-e $to, 'File not downloaded'; | ||
|
||
like $cache_log, qr/Downloading "test.qcow" from "$from"/, 'Download attempt'; | ||
like $cache_log, qr/Download of "$to" failed: 521 Premature connection close/, 'Real error is logged'; | ||
like $cache_log, qr/Download error 521, waiting .* seconds for next try \(2 remaining\)/, '2 tries remaining'; | ||
like $cache_log, qr/Download error 521, waiting .* seconds for next try \(1 remaining\)/, '1 tries remaining'; | ||
like $cache_log, qr/Download of "$to" failed: Premature connection close/, 'Real error is logged'; | ||
like $cache_log, qr/Download error, waiting .* seconds for next try \(2 remaining\)/, '2 tries remaining'; | ||
like $cache_log, qr/Download error, waiting .* seconds for next try \(1 remaining\)/, '1 tries remaining'; | ||
$cache_log = ''; | ||
}; | ||
|
||
|
@@ -144,8 +144,8 @@ subtest 'Size differs' => sub { | |
|
||
like $cache_log, qr/Downloading "test.qcow" from "$from"/, 'Download attempt'; | ||
like $cache_log, qr/Size of .+ differs, expected 10 Byte but downloaded 6 Byte/, 'Incomplete download logged'; | ||
like $cache_log, qr/Download error 598, waiting .* seconds for next try \(2 remaining\)/, '2 tries remaining'; | ||
like $cache_log, qr/Download error 598, waiting .* seconds for next try \(1 remaining\)/, '1 tries remaining'; | ||
like $cache_log, qr/Download error, waiting .* seconds for next try \(2 remaining\)/, '2 tries remaining'; | ||
like $cache_log, qr/Download error, waiting .* seconds for next try \(1 remaining\)/, '1 tries remaining'; | ||
$cache_log = ''; | ||
}; | ||
|
||
|