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.
42 lines
1.9 KiB
PHP
42 lines
1.9 KiB
PHP
<?php
|
|
|
|
// The list/detail page must not open the retired Python Engine merely to
|
|
// decorate a VM row. Live=1 status polling has a separate typed Agent seam;
|
|
// these two broad page paths are deliberately cache-first and get their
|
|
// observations from CloudInstanceRuntimeSyncService.
|
|
$source = file_get_contents(dirname(__DIR__) . '/app/Controllers/CloudApiController.php');
|
|
if (!is_string($source)) {
|
|
throw new RuntimeException('CloudApiController source is missing.');
|
|
}
|
|
|
|
$assert = static function (bool $condition, string $message): void {
|
|
if (!$condition) {
|
|
throw new RuntimeException($message);
|
|
}
|
|
};
|
|
|
|
$start = strpos($source, 'private function vmListContexts(');
|
|
$end = strpos($source, ' public function vms(', $start === false ? 0 : $start);
|
|
$list = ($start !== false && $end !== false) ? substr($source, $start, $end - $start) : '';
|
|
$assert(str_contains($list, 'CloudInstanceRuntimeService::forInstances')
|
|
&& str_contains($list, 'state_fresh')
|
|
&& str_contains($list, 'host unavailable'),
|
|
'VM list context no longer uses the bounded Go-Agent-fed runtime cache.');
|
|
foreach (['CloudEngineClient', '->host(', 'vms/'] as $forbidden) {
|
|
$assert(!str_contains($list, $forbidden),
|
|
'VM list context still contains a legacy Engine read: ' . $forbidden);
|
|
}
|
|
|
|
$start = strpos($source, 'private function vmData(');
|
|
$end = strpos($source, ' public function vms(', $start === false ? 0 : $start);
|
|
$detail = ($start !== false && $end !== false) ? substr($source, $start, $end - $start) : '';
|
|
$assert(str_contains($detail, 'CloudInstanceRuntimeService::forInstances')
|
|
&& str_contains($detail, 'state_fresh'),
|
|
'VM detail does not use the runtime cache when no preloaded context exists.');
|
|
foreach (['CloudEngineClient', '->host(', 'vms/'] as $forbidden) {
|
|
$assert(!str_contains($detail, $forbidden),
|
|
'VM detail still contains a legacy Engine read: ' . $forbidden);
|
|
}
|
|
|
|
fwrite(STDOUT, "Cloud API VM cache cutover contract passed.\n");
|