Files
coolify/tests/Feature/ScheduledInstanceJobsUniqueLockTest.php
Andras Bacsai 407c384b09 feat(backups): add configurable missing volume backup alerts
Check enabled volume backup schedules hourly and notify teams when no
execution occurs within the configured number of days. Expose the alert
threshold in the UI and API, with alerts disabled by default.

Route volume backup results and warnings to the appropriate Telegram
backup threads.
2026-10-07 09:37:35 +02:00

36 lines
1.3 KiB
PHP

<?php
use App\Jobs\CheckMissingDatabaseBackupsJob;
use App\Jobs\CheckMissingVolumeBackupsJob;
use App\Jobs\CleanupInstanceStuffsJob;
use App\Jobs\CleanupOrphanedPreviewContainersJob;
use Illuminate\Support\Facades\Queue;
beforeEach(function () {
config()->set('cache.default', 'array');
Queue::fake();
});
dataset('scheduled instance jobs', [
'orphaned preview containers cleanup' => [CleanupOrphanedPreviewContainersJob::class, 600],
'instance cleanup' => [CleanupInstanceStuffsJob::class, 60],
'missing database backups check' => [CheckMissingDatabaseBackupsJob::class, 1800],
'missing volume backups check' => [CheckMissingVolumeBackupsJob::class, 1800],
]);
it('does not queue the job again while its unique lock is held', function (string $jobClass, int $lockSeconds) {
$jobClass::dispatch();
$this->travel($lockSeconds - 1)->seconds();
$jobClass::dispatch();
Queue::assertPushed($jobClass, 1);
})->with('scheduled instance jobs');
it('queues the job again after a unique lock left by a killed worker expires', function (string $jobClass, int $lockSeconds) {
$jobClass::dispatch();
$this->travel($lockSeconds + 1)->seconds();
$jobClass::dispatch();
Queue::assertPushed($jobClass, 2);
})->with('scheduled instance jobs');