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

47 lines
2.4 KiB
PHTML

<?php
// Static migration contract for the lifecycle runtime poller. The scheduler
// must use one typed, explicitly addressed Agent observation per VM; a batch
// inventory response or the retired Python/SSH transport would reintroduce a
// host-wide authority boundary and cannot preserve per-row CAS fencing.
$root = dirname(__DIR__);
$assert = static function ($condition, string $message): void {
if (!$condition) {
throw new RuntimeException($message);
}
};
$service = file_get_contents($root . '/app/Services/Cloud/CloudInstanceRuntimeSyncService.php');
$observation = file_get_contents($root . '/app/Services/Cloud/CloudAgentObservationService.php');
$assert(is_string($service) && is_string($observation), 'Runtime sync sources are unreadable.');
$assert(str_contains($service, 'CloudAgentObservationService')
&& str_contains($service, 'CloudAgentHostClientResolverFactory::fromConfig()')
&& str_contains($service, '->observe(')
&& str_contains($service, '$instanceId,')
&& str_contains($service, 'CloudInstanceRuntimeService::beginObservation(')
&& str_contains($service, 'CloudInstanceRuntimeService::markObserved(')
&& str_contains($service, 'CloudInstanceRuntimeService::markUnavailable(')
&& str_contains($service, 'pruneReadOnly(')
&& str_contains($service, 'MAX_SYNC_SECONDS')
&& str_contains($service, 'hash_equals($uuid, $candidateUuid)')
&& !str_contains($service, 'CloudEngineClient')
&& !str_contains($service, 'vm-states')
&& !str_contains($service, 'shell_exec')
&& !str_contains($service, 'ssh'),
'Runtime sync must use typed Agent observations and no Python/SSH or host-wide vm-states fallback.');
$assert(str_contains($observation, 'resolveReadOnly($hostId)')
&& str_contains($observation, "'domain_observe'")
&& str_contains($observation, 'markUncertain')
&& str_contains($observation, 'observeMany'),
'Agent observation service must keep read-only resolver, typed operation and uncertain journal semantics.');
$runtime = file_get_contents($root . '/app/Services/Cloud/CloudInstanceRuntimeService.php');
$assert(is_string($runtime)
&& str_contains($runtime, 'Runtime observation CAS lost')
&& str_contains($runtime, '$revision !== null && (int) $updated !== 1'),
'Runtime cache writes must reject stale revision tokens instead of reporting an observation as committed.');
echo "Cloud Agent runtime sync contract passed.\n";