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.
45 lines
2.4 KiB
PHP
45 lines
2.4 KiB
PHP
<?php
|
|
|
|
$root = dirname(__DIR__);
|
|
$controller = file_get_contents($root . '/app/Controllers/CloudAdminInstanceController.php');
|
|
$jobs = file_get_contents($root . '/app/Services/Cloud/CloudJobService.php');
|
|
$placement = file_get_contents($root . '/app/Services/Cloud/CloudPlacementService.php');
|
|
$worker = file_get_contents($root . '/app/Services/Cloud/CloudWorkerService.php');
|
|
|
|
$assert = static function ($condition, string $message): void {
|
|
if (!$condition) {
|
|
throw new RuntimeException($message);
|
|
}
|
|
};
|
|
|
|
$assert(is_string($controller)
|
|
&& str_contains($controller, "->where('state', 'available')")
|
|
&& str_contains($controller, 'isset($ledgerAvailable[$cidr])'),
|
|
'Network choices no longer intersect the engine free-list with the local available-IP ledger.');
|
|
$assert(is_string($jobs)
|
|
&& str_contains($jobs, '(string) $reservation->state !== \'committed\'')
|
|
&& str_contains($jobs, '(string) $source->state !== \'assigned\'')
|
|
&& str_contains($jobs, '(string) $target->state !== \'available\'')
|
|
&& str_contains($jobs, '$target->state = \'changing\'')
|
|
&& str_contains($jobs, '$target->operation_id = $job->operation_id')
|
|
&& str_contains($jobs, '$jobPayload[\'source_public_ip_id\']')
|
|
&& str_contains($jobs, '$jobPayload[\'target_public_ip_id\']'),
|
|
'Network-change enqueue no longer locks and persists the source/target ledger identity.');
|
|
$assert(is_string($worker)
|
|
&& str_contains($worker, "['succeeded', 'failed', 'uncertain']")
|
|
&& str_contains($worker, 'CloudPlacementService::finishNetworkChange')
|
|
&& str_contains($worker, '$markedUncertain !== 1')
|
|
&& str_contains($worker, "'uncertain'"),
|
|
'Worker no longer settles every terminal or ambiguous network-change outcome.');
|
|
$assert(is_string($placement)
|
|
&& str_contains($placement, '$reservation->public_ip_id = $targetIpId')
|
|
&& str_contains($placement, '$target->state = \'assigned\'')
|
|
&& str_contains($placement, '$target->state = \'uncertain\'')
|
|
&& str_contains($placement, '$source->state = \'available\'')
|
|
&& str_contains($placement, 'lockedHostAndReservation')
|
|
&& str_contains($placement, '(string) $reservation->state === \'committed\'')
|
|
&& str_contains($placement, '$ip->instance_id ?? 0'),
|
|
'Placement ledger no longer enforces atomic swaps, conservative uncertainty, and committed-state monotonicity.');
|
|
|
|
echo "Cloud network IP ledger contract tests passed\n";
|