You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
virt/web/tests/CloudPublicNetworkLegacyWri...

97 lines
3.5 KiB
PHP

<?php
$root = dirname(__DIR__);
$read = static function (string $path) use ($root): string {
$source = file_get_contents($root . '/' . $path);
if (!is_string($source)) {
throw new RuntimeException('Unreadable source: ' . $path);
}
return $source;
};
$assert = static function (bool $condition, string $message): void {
if (!$condition) {
throw new RuntimeException($message);
}
};
$services = $root . '/app/Services/Cloud';
$assert(!is_file($services . '/CloudPublicNetworkTransitionGate.php'),
'The retired public-network compatibility gate still exists.');
$placement = $read('app/Services/Cloud/CloudPlacementService.php');
$worker = $read('app/Services/Cloud/CloudWorkerService.php');
$jobs = $read('app/Services/Cloud/CloudJobService.php');
$backup = $read('app/Services/Cloud/CloudBackupService.php');
$identity = $read('app/Services/Cloud/CloudOperationRecoveryIdentity.php');
$adminRecovery = $read(
'app/Services/Cloud/CloudAdminOperationRecoveryService.php'
);
$deleteAuthority = $read(
'app/Services/Cloud/CloudInstanceResourceRelease.php'
);
foreach ([
'reserveBackupRestore(',
'preparedBackupRestorePlacement(',
'finishBackupRestore(',
'finishNetworkChange(',
'assertBackupRestoreTransitionReady(',
'availablePublicIpQuery(',
'publicIpBelongsToPool(',
] as $retired) {
$assert(!str_contains($placement, $retired),
'Placement retained retired writer: ' . $retired);
}
$assert(str_contains($jobs, "if (\$kind === 'network_change')")
&& str_contains($jobs, '旧公网网络写入口已停用')
&& str_contains($worker,
"throw new CloudError('旧公网网络写任务已停用', 409)")
&& str_contains($worker,
"throw new CloudError('旧备份恢复任务已停用', 409)")
&& str_contains($worker,
'CloudPublicNetworkTransitionWorkflow::finishJobLocked(')
&& !str_contains($worker, 'CloudPlacementService::finishNetworkChange('),
'Worker or enqueue retained a dispatchable scalar public-network path.');
$assert(!str_contains($backup, 'finishRestoreLocked(')
&& str_contains($backup,
'CloudPortableRestoreFinalizer::finishJobLocked(')
&& str_contains($backup,
'CloudPortableRestoreFinalizer::markJobUncertain('),
'Backup restore retained its singular-IP finalizer.');
foreach ([
'legacyBackupRestoreIdentity(',
'backupRestoreAction(',
] as $retired) {
$assert(!str_contains($identity, $retired),
'Recovery identity retained legacy restore support: ' . $retired);
}
$assert(!str_contains($adminRecovery, "'public_ip_cidr'")
&& !str_contains($adminRecovery, "'public_pool_key'"),
'Administrator recovery retained scalar restore-result fields.');
$php = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(
$services,
FilesystemIterator::SKIP_DOTS
));
foreach ($php as $file) {
if (!$file->isFile() || $file->getExtension() !== 'php') {
continue;
}
$source = file_get_contents($file->getPathname());
$assert(is_string($source)
&& !str_contains($source, 'CloudPublicNetworkTransitionGate'),
'Production service retained the legacy gate: '
. $file->getFilename());
}
$assert(str_contains($deleteAuthority,
'CloudPublicNetworkAllocationService::currentClaimSet(')
&& str_contains($deleteAuthority,
'CloudPortableRestoreInstanceDeletion::releaseCommitted('),
'Deleting canonical instances lost dual-stack source authority.');
echo "Legacy public-network writers are retired.\n";