aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@mageia.org>2023-12-10 21:43:07 +0000
committerPascal Terjan <pterjan@mageia.org>2023-12-11 23:45:04 +0000
commitc53d21cf38263206af292b48d6369ee1662bd4be (patch)
treeb402732dc7c0fe1268a6873791b8fc180508c202 /t
parent42466ac7d8bcd3fd1d1097d3dbf1f77cd1a2daa0 (diff)
downloadiurt-c53d21cf38263206af292b48d6369ee1662bd4be.tar
iurt-c53d21cf38263206af292b48d6369ee1662bd4be.tar.gz
iurt-c53d21cf38263206af292b48d6369ee1662bd4be.tar.bz2
iurt-c53d21cf38263206af292b48d6369ee1662bd4be.tar.xz
iurt-c53d21cf38263206af292b48d6369ee1662bd4be.zip
Limit retries in case of install_deps_failure
A new config option (backoff_delays) was added to ulri. It contains a list of delays (in seconds) between retries and default to [5*60, 30*60, 60*60, 120*60] (5m, 30m, 1h, 2h). When reaching the end of the list, we fail permanently. To never retry, set it to []. To retry forever, set it to undef.
Diffstat (limited to 't')
-rw-r--r--t/queue.t49
1 files changed, 48 insertions, 1 deletions
diff --git a/t/queue.t b/t/queue.t
index d9f8056..b480e67 100644
--- a/t/queue.t
+++ b/t/queue.t
@@ -1,6 +1,11 @@
-use Test::More;
use Iurt::Queue;
+use Test::More;
+
+use Cwd;
+use File::stat 'stat';
+use MDK::Common qw(cat_);
+
$config = {};
my $media = 'core/release';
@@ -57,4 +62,46 @@ $ent = create_ent();
remove_bot_from_package($ent, $media, 'h1', 2);
is_deeply $ent->{media}{$media}{bot}, [$b1, $b3] or diag explain $ent->{media}{$media}{bot};
+
+chdir 't' if -d 't';
+mkdir "tmp";
+my $dir = Cwd::cwd() . "/tmp";
+my $retry_file = "${dir}/test_noarch.retry";
+unlink $retry_file;
+
+sub verify_retry_file {
+ my ($test, $present, $content, $mtime) = @_;
+ if ($present) {
+ ok(-f $retry_file, "$test - $retry_file should exist");
+ } else {
+ ok(!-f $retry_file, "$test - $retry_file should not exist");
+ return;
+ }
+ is(cat_($retry_file), $content, "$test - $retry_file should contain $content");
+ if ($mtime) {
+ my $t = stat($retry_file)->mtime;
+ # Allow 5s difference if running on a very slow machine
+ ok($t > $mtime - 5);
+ ok($t < $mtime + 5);
+ }
+}
+
+unlink $retry_file;
+ok(schedule_next_retry({'backoff_delays' => [1000, 2000]}, $dir, 'test', 'noarch', 0), "schedule_next_retry - first failure is retried");
+verify_retry_file("schedule_next_retry - first failure is retried", 1, 1, time+1000);
+
+unlink $retry_file;
+ok(schedule_next_retry({'backoff_delays' => [1000, 2000]}, $dir, 'test', 'noarch', 1), "schedule_next_retry - one retry left is retried");
+verify_retry_file("schedule_next_retry - one retry left is retried", 1, 2, time+2000);
+
+unlink $retry_file;
+ok(!schedule_next_retry({'backoff_delays' => [120, 1000]}, $dir, 'test', 'noarch', 2), "schedule_next_retry - no retry left is failed");
+
+unlink $retry_file;
+ok(!schedule_next_retry({'backoff_delays' => []}, $dir, 'test', 'noarch', 0), "schedule_next_retry - no retry is failed");
+
+unlink $retry_file;
+ok(schedule_next_retry({}, $dir, 'test', 'noarch', 0), "schedule_next_retry - always retry is retried");
+verify_retry_file("schedule_next_retry - always retry is retried", 0);
+
done_testing();