mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-13 22:15:35 +00:00
Merge remote-tracking branch 'origin/next' into audit-policies
This commit is contained in:
commit
ad433a0798
18 files changed
+1008
-171
No files matched your search
@@ -173,6 +173,42 @@ test('scheduler log parser parses skip entries correctly', function () {
|
||||
@unlink($logPath);
|
||||
});
|
||||
|
||||
test('scheduler log parser excludes started events from runs', function () {
|
||||
$logPath = storage_path('logs/scheduled-test-started-filter.log');
|
||||
$logDir = dirname($logPath);
|
||||
if (! is_dir($logDir)) {
|
||||
mkdir($logDir, 0755, true);
|
||||
}
|
||||
|
||||
// Temporarily rename existing logs so they don't interfere
|
||||
$existingLogs = glob(storage_path('logs/scheduled-*.log'));
|
||||
$renamed = [];
|
||||
foreach ($existingLogs as $log) {
|
||||
$tmp = $log.'.bak';
|
||||
rename($log, $tmp);
|
||||
$renamed[$tmp] = $log;
|
||||
}
|
||||
|
||||
$logPath = storage_path('logs/scheduled-'.now()->format('Y-m-d').'.log');
|
||||
$lines = [
|
||||
'['.now()->format('Y-m-d H:i:s').'] production.INFO: ScheduledJobManager started {}',
|
||||
'['.now()->format('Y-m-d H:i:s').'] production.INFO: ScheduledJobManager completed {"duration_ms":74,"dispatched":1,"skipped":13}',
|
||||
];
|
||||
file_put_contents($logPath, implode("\n", $lines)."\n");
|
||||
|
||||
$parser = new SchedulerLogParser;
|
||||
$runs = $parser->getRecentRuns();
|
||||
|
||||
expect($runs)->toHaveCount(1);
|
||||
expect($runs->first()['message'])->toContain('completed');
|
||||
|
||||
// Cleanup
|
||||
@unlink($logPath);
|
||||
foreach ($renamed as $tmp => $original) {
|
||||
rename($tmp, $original);
|
||||
}
|
||||
});
|
||||
|
||||
test('scheduler log parser filters by team id', function () {
|
||||
$logPath = storage_path('logs/scheduled-'.now()->format('Y-m-d').'.log');
|
||||
$logDir = dirname($logPath);
|
||||
@@ -198,3 +234,39 @@ test('scheduler log parser filters by team id', function () {
|
||||
// Cleanup
|
||||
@unlink($logPath);
|
||||
});
|
||||
|
||||
test('skipped jobs show fallback when resource is deleted', function () {
|
||||
$this->actingAs($this->rootUser);
|
||||
session(['currentTeam' => $this->rootTeam]);
|
||||
|
||||
$logPath = storage_path('logs/scheduled-'.now()->format('Y-m-d').'.log');
|
||||
$logDir = dirname($logPath);
|
||||
if (! is_dir($logDir)) {
|
||||
mkdir($logDir, 0755, true);
|
||||
}
|
||||
|
||||
// Temporarily rename existing logs so they don't interfere
|
||||
$existingLogs = glob(storage_path('logs/scheduled-*.log'));
|
||||
$renamed = [];
|
||||
foreach ($existingLogs as $log) {
|
||||
$tmp = $log.'.bak';
|
||||
rename($log, $tmp);
|
||||
$renamed[$tmp] = $log;
|
||||
}
|
||||
|
||||
$lines = [
|
||||
'['.now()->format('Y-m-d H:i:s').'] production.INFO: Task skipped {"type":"task","skip_reason":"application_not_running","task_id":99999,"task_name":"my-cron-job","team_id":0}',
|
||||
];
|
||||
file_put_contents($logPath, implode("\n", $lines)."\n");
|
||||
|
||||
Livewire::test(ScheduledJobs::class)
|
||||
->assertStatus(200)
|
||||
->assertSee('my-cron-job')
|
||||
->assertSee('Application not running');
|
||||
|
||||
// Cleanup
|
||||
@unlink($logPath);
|
||||
foreach ($renamed as $tmp => $original) {
|
||||
rename($tmp, $original);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user