Merge remote-tracking branch 'origin/main' into next

This commit is contained in:
github-actions[bot]
2026-10-06 21:20:02 +00:00
3 changed files with 68 additions and 12 deletions
+42 -8
View File
@@ -4,6 +4,7 @@ use App\Models\InstanceSettings;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Collection;
uses(RefreshDatabase::class);
@@ -74,22 +75,55 @@ it('schedules stuck resource cleanup in the background once per day', function (
->and($event->runInBackground)->toBeTrue();
});
it('runs one scheduled job dispatcher for each schedule type from the scheduler instead of a queue', function () {
$events = collect(app(Schedule::class)->events());
function scheduledJobDispatchersForMode(?string $mode, bool $selfHosted = true): Collection
{
config()->set('constants.coolify.self_hosted', $selfHosted);
config()->set('constants.coolify.scheduled_jobs_dispatch_mode', $mode);
$dispatchers = $events->filter(fn ($event) => str_contains((string) $event->command, 'scheduled:dispatch'));
$schedule = new Schedule;
(fn () => $this->schedule($schedule))->call(app(Kernel::class));
expect($dispatchers->map(fn ($event) => str((string) $event->command)->after('--type=')->value())->values()->all())
->toBe(['backups', 'tasks', 'volume-backups', 'docker-cleanups']);
$events = collect($schedule->events());
expect($events->contains(fn ($event) => str_contains((string) $event->description, 'ScheduledJobManager')))->toBeFalse();
$dispatchers = $events->filter(fn ($event) => str_contains((string) $event->command, 'scheduled:dispatch'))->values();
$dispatchers->each(function ($event) {
expect($event->expression)->toBe('* * * * *')
->and($event->onOneServer)->toBeTrue()
->and($event->withoutOverlapping)->toBeTrue()
->and($event->runInBackground)->toBeTrue();
});
// Each type has its own overlap lock.
expect($dispatchers->map->mutexName()->unique())->toHaveCount(4)
->and($events->contains(fn ($event) => str_contains((string) $event->description, 'ScheduledJobManager')))->toBeFalse();
return $dispatchers;
}
it('runs all scheduled job types in one dispatcher process by default on self-hosted', function () {
$dispatchers = scheduledJobDispatchersForMode(null);
expect($dispatchers)->toHaveCount(1)
->and((string) $dispatchers->first()->command)->toEndWith('scheduled:dispatch')
->and((string) $dispatchers->first()->command)->not->toContain('--type=');
});
it('runs one scheduled job dispatcher for each schedule type in concurrent mode', function (?string $mode, bool $selfHosted) {
$dispatchers = scheduledJobDispatchersForMode($mode, $selfHosted);
expect($dispatchers->map(fn ($event) => str((string) $event->command)->after('--type=')->value())->all())
->toBe(['backups', 'tasks', 'volume-backups', 'docker-cleanups'])
// Each type has its own overlap lock.
->and($dispatchers->map->mutexName()->unique())->toHaveCount(4);
})->with([
'set on self-hosted' => ['concurrent', true],
'default on Coolify Cloud' => [null, false],
]);
it('runs one dispatcher process when sequential mode is set on Coolify Cloud', function () {
expect(scheduledJobDispatchersForMode('sequential', false))->toHaveCount(1);
});
it('falls back to the default dispatch mode for an unknown value', function () {
expect(scheduledJobDispatchersForMode('parallel'))->toHaveCount(1)
->and(scheduledJobDispatchersForMode('parallel', false))->toHaveCount(4);
});
it('schedules GitHub runner reconciliation every minute on Coolify Cloud', function () {