- dev/betrieb/deploy.sh: Tag auschecken, composer, Caches leeren (bewusst
kein route:/config:cache wegen hostabhaengiger Routen und env()-Aufrufen),
horizon:terminate, FPM-Reload, Worker-Pruefung am Ende
- dev/betrieb/README.md: Einrichtung Server, Umstellung des Live-Verzeichnisses,
Release, Deploy, Rollback
- config('app.version') aus RELEASE, php artisan about --only=mivita
- monitoring:queue-probe prueft nach dem Deploy, ob Horizon Jobs abholt
- Vorlage dev/git-deploy-monitoring aus Pressekonto
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
54 lines
1.7 KiB
PHP
54 lines
1.7 KiB
PHP
<?php
|
|
|
|
use App\Jobs\Monitoring\QueueProbe;
|
|
use Illuminate\Support\Facades\Queue;
|
|
use Illuminate\Support\Sleep;
|
|
use Tests\TestCase;
|
|
|
|
uses(TestCase::class);
|
|
|
|
/**
|
|
* Worker-Prüfung am Ende von dev/betrieb/deploy.sh: kommt Horizon nach
|
|
* `horizon:terminate` nicht zurück, soll der Deploy das sofort melden.
|
|
*/
|
|
beforeEach(function () {
|
|
config(['queue.default' => 'sync', 'cache.default' => 'array']);
|
|
});
|
|
|
|
test('a running worker picks up the probe job', function () {
|
|
Sleep::fake();
|
|
|
|
$this->artisan('monitoring:queue-probe', ['--wait' => 30])
|
|
->expectsOutputToContain('Queue-Worker läuft (Test-Job nach 0 s abgeholt).')
|
|
->assertSuccessful();
|
|
|
|
Sleep::assertSleptTimes(0);
|
|
});
|
|
|
|
test('without a worker the probe fails after the waiting time with a hint', function () {
|
|
Sleep::fake();
|
|
Queue::fake();
|
|
|
|
$this->artisan('monitoring:queue-probe', ['--wait' => 5])
|
|
->expectsOutputToContain('Kein Queue-Worker hat den Test-Job innerhalb von 5 s abgeholt.')
|
|
->expectsOutputToContain('Horizon prüfen')
|
|
->assertFailed();
|
|
|
|
Queue::assertPushed(QueueProbe::class, fn (QueueProbe $job): bool => $job->queue === null);
|
|
Sleep::assertSleptTimes(5);
|
|
});
|
|
|
|
test('the probe job only acknowledges its own token', function () {
|
|
(new QueueProbe('abc'))->handle();
|
|
|
|
expect(cache()->has(QueueProbe::cacheKey('abc')))->toBeTrue()
|
|
->and(cache()->has(QueueProbe::cacheKey('xyz')))->toBeFalse();
|
|
});
|
|
|
|
test('the version shows up in artisan about', function () {
|
|
config(['app.version' => 'v9.9.9']);
|
|
|
|
$this->artisan('about', ['--only' => 'mivita'])
|
|
->expectsOutputToContain('v9.9.9')
|
|
->assertSuccessful();
|
|
});
|