Fix slow SafeUpgradeServiceTest by optimizing snapshot pruning

This commit is contained in:
Andy Miller
2025-11-20 10:51:45 +00:00
parent ce6a1b3bcb
commit b0301beee3
2 changed files with 6 additions and 4 deletions

View File

@@ -1184,7 +1184,12 @@ class SafeUpgradeService
// Sort by created_at descending
usort($manifests, static function ($a, $b) {
return $b['created_at'] <=> $a['created_at'];
$result = $b['created_at'] <=> $a['created_at'];
if ($result === 0) {
return strcmp($b['path'], $a['path']);
}
return $result;
});
$toDelete = array_slice($manifests, $limit);

View File

@@ -128,9 +128,6 @@ class SafeUpgradeServiceTest extends \Codeception\TestCase\Test
$manifests[] = $service->promote($package, '1.8.' . $i, ['backup', 'cache', 'images', 'logs', 'tmp', 'user']);
// Ensure subsequent promotions have a marker to restore.
file_put_contents($root . '/ORIGINAL', 'state-' . $i);
// Sleep to ensure different timestamps for sorting (time() has 1s resolution)
sleep(1);
usleep(100000); // +100ms to be sure
}
$files = glob($manifestStore . '/*.json');