fix: harden baseline queue runtime
This commit is contained in:
parent
5a9f11b14f
commit
9838111a21
@ -41,6 +41,8 @@ class CaptureBaselineSnapshotJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public int $timeout = 300;
|
||||
|
||||
public ?OperationRun $operationRun = null;
|
||||
|
||||
public function __construct(
|
||||
|
||||
@ -58,6 +58,8 @@ class CompareBaselineToTenantJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public int $timeout = 300;
|
||||
|
||||
/**
|
||||
* @var array<int, string>
|
||||
*/
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
'connection' => env('DB_QUEUE_CONNECTION'),
|
||||
'table' => env('DB_QUEUE_TABLE', 'jobs'),
|
||||
'queue' => env('DB_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
|
||||
'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 600),
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
'driver' => 'beanstalkd',
|
||||
'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'),
|
||||
'queue' => env('BEANSTALKD_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90),
|
||||
'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 600),
|
||||
'block_for' => 0,
|
||||
'after_commit' => false,
|
||||
],
|
||||
@ -68,7 +68,7 @@
|
||||
'driver' => 'redis',
|
||||
'connection' => env('REDIS_QUEUE_CONNECTION', 'default'),
|
||||
'queue' => env('REDIS_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90),
|
||||
'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 600),
|
||||
'block_for' => null,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
20
tests/Feature/Operations/BaselineQueueRuntimeGuardTest.php
Normal file
20
tests/Feature/Operations/BaselineQueueRuntimeGuardTest.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Jobs\CaptureBaselineSnapshotJob;
|
||||
use App\Jobs\CompareBaselineToTenantJob;
|
||||
use App\Models\OperationRun;
|
||||
|
||||
it('keeps baseline jobs within a safe queue timeout and retry window', function (): void {
|
||||
$captureJob = new CaptureBaselineSnapshotJob(new OperationRun);
|
||||
$compareJob = new CompareBaselineToTenantJob(new OperationRun);
|
||||
|
||||
$databaseRetryAfter = (int) config('queue.connections.database.retry_after');
|
||||
$maximumJobTimeout = max($captureJob->timeout, $compareJob->timeout);
|
||||
|
||||
expect($captureJob->timeout)->toBe(300)
|
||||
->and($compareJob->timeout)->toBe(300)
|
||||
->and($databaseRetryAfter)->toBeGreaterThan($maximumJobTimeout)
|
||||
->and($databaseRetryAfter)->toBeGreaterThanOrEqual(600);
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user