mirror of
https://github.com/coollabsio/coolify.git
synced 2026-10-29 01:54:37 +08:00
Queued GetContainersStatus runs are unique per server until a worker starts them, and CleanupHelperContainersJob locks per server instead of class-wide. Add UniqueUntilProcessingJobDecorator for laravel-actions.
27 lines
771 B
PHP
27 lines
771 B
PHP
<?php
|
|
|
|
use App\Jobs\CleanupHelperContainersJob;
|
|
use App\Models\Server;
|
|
use App\Models\Team;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\Queue;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
beforeEach(function () {
|
|
Server::flushIdentityMap();
|
|
$this->team = Team::factory()->create();
|
|
});
|
|
|
|
it('queues one helper container cleanup per server', function () {
|
|
Queue::fake();
|
|
$first = Server::factory()->create(['team_id' => $this->team->id]);
|
|
$second = Server::factory()->create(['team_id' => $this->team->id]);
|
|
|
|
CleanupHelperContainersJob::dispatch($first);
|
|
CleanupHelperContainersJob::dispatch($second);
|
|
CleanupHelperContainersJob::dispatch($first);
|
|
|
|
Queue::assertPushed(CleanupHelperContainersJob::class, 2);
|
|
});
|