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/CloudRescueMountIdentityCon...

62 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
$root = dirname(__DIR__);
$controller = file_get_contents(
$root . '/app/Controllers/CloudApiController.php'
);
$identity = file_get_contents(
$root . '/app/Services/Cloud/CloudOperationRecoveryIdentity.php'
);
$worker = file_get_contents(
$root . '/app/Services/Cloud/CloudWorkerService.php'
);
$agent = file_get_contents(
dirname($root) . '/agent/hypervisor/libvirt_domain_features.go'
);
$resources = file_get_contents(
dirname($root) . '/agent/hypervisor/libvirt_resources.go'
);
$migration = file_get_contents(
dirname($root) . '/agent/hypervisor/libvirt_backup.go'
);
$assert = static function (bool $condition, string $message): void {
if (!$condition) {
throw new RuntimeException($message);
}
};
$assert(
str_contains($controller,
'CloudRescueTemplateReplicaCoordinator::isExactReplica(')
&& str_contains($controller,
"'revision' => (int) \$template->revision")
&& str_contains($controller,
"'generation_token' =>")
&& str_contains($identity,
"'operation_id', 'template_id', 'revision'")
&& str_contains($identity,
"'generation_token'")
&& str_contains($worker,
'assertRescueResultMatchesRequest('),
'Panel rescue dispatch is not pinned to one exact ready replica.'
);
$assert(
str_contains($agent, 'metadata.RescueTemplateRevision = request.Revision')
&& str_contains($agent,
'metadata.RescueTemplateGeneration = request.GenerationToken')
&& str_contains($agent, 'live and persistent rescue generations')
&& str_contains($agent, 'rescue_generation_mismatch'),
'Agent rescue XML and live-state validation lost the exact generation.'
);
$assert(
substr_count($resources, '"rescue_active"') >= 2
&& str_contains($migration, '"backup_rescue_active"'),
'Resize or migration can cross an attached rescue generation.'
);
echo "Cloud rescue mount identity contract passed.\n";