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

82 lines
3.8 KiB
PHP

<?php
$root = dirname(__DIR__);
$schema = file_get_contents($root . '/sql/cloud.sql');
$setup = file_get_contents($root . '/app/Command/CloudSetup.php');
$service = file_get_contents(
$root . '/app/Services/Cloud/CloudPublicIpPoolReplacementBatchService.php'
);
$jobs = file_get_contents($root . '/app/Services/Cloud/CloudJobService.php');
$worker = file_get_contents($root . '/app/Services/Cloud/CloudWorkerService.php');
$assert = static function (bool $condition, string $message): void {
if (!$condition) {
throw new RuntimeException($message);
}
};
$assert(is_string($schema)
&& str_contains($schema,
'CREATE TABLE cloud_public_ip_pool_replacement_batches')
&& str_contains($schema,
'CREATE TABLE cloud_public_ip_pool_replacement_batch_items')
&& str_contains($schema, 'cloud_public_pool_replacement_active')
&& str_contains($schema, 'source_initial_state')
&& str_contains($schema,
"source_initial_state IN ('active','draining')")
&& str_contains($schema, 'source_public_ip_pool_id, active_claim')
&& str_contains($schema, 'target_public_ip_pool_id, active_claim, id')
&& str_contains($schema, 'cloud_public_pool_replacement_child')
&& str_contains($schema, "state IN ('queued','succeeded','failed','unknown')")
&& str_contains($schema, "state IN ('running','blocked','succeeded','failed')"),
'Public-pool replacement lacks durable batch, child, or active-claim schema.');
$assert(is_string($setup)
&& str_contains($setup,
"SCHEMA_VERSION = 'go-agent-wss-v27-public-pool-replacement'")
&& str_contains($setup,
"'cloud_public_ip_pool_replacement_batches'")
&& str_contains($setup,
"'cloud_public_ip_pool_replacement_batch_items'")
&& str_contains($setup,
"'chk_cloud_public_pool_replacement_source_initial'")
&& str_contains($setup,
"'chk_cloud_public_pool_replacement_claim'"),
'CloudSetup does not enforce the replacement batch schema.');
$assert(is_string($service)
&& str_contains($service, 'expected_source_revision')
&& str_contains($service, 'expected_target_revision')
&& str_contains($service, 'confirm_replacement')
&& str_contains($service, "->where('active_claim', 1)")
&& str_contains($service,
"'source_public_ip_pool_id', \$replacementPoolIds")
&& str_contains($service,
"'target_public_ip_pool_id', \$replacementPoolIds")
&& str_contains($service, "\$batch->state = 'blocked'")
&& str_contains($service, 'finishResolvedChildLocked')
&& str_contains($service, "self::setPoolStateLocked(\$source, 'disabled')")
&& str_contains($service,
'self::setPoolStateLocked($source, $sourceInitialState)')
&& str_contains($service, "'replacement_locked'")
&& str_contains($service, 'CloudAccess::manage($actor)')
&& str_contains($service, 'self::assertAdminRead($actor)'),
'Replacement service lost revision fencing, overlap locking, or unknown-effect convergence.');
$assert(is_string($jobs)
&& str_contains($jobs,
'enqueuePoolReplacementNetworkChangeLocked')
&& str_contains($jobs,
"'public_pool_replacement_batch_key' => \$batchKey")
&& str_contains($jobs, "'confirm_restart' => true")
&& str_contains($jobs, "\$targetIp->state = 'changing'"),
'Replacement children no longer freeze ordinary network-change identity.');
$assert(is_string($worker)
&& str_contains($worker,
'CloudPublicIpPoolReplacementBatchService::finishChildLocked')
&& str_contains($worker,
"'public_ip_pool_replacement_batch'")
&& str_contains($worker,
"\$preparedRecoveryMarker === null")
&& str_contains($worker, "? \$catalogStatus : 'uncertain'"),
'Worker no longer converges replacement children or excludes the local parent from dispatch.');
echo "Cloud public IP pool replacement schema contract tests passed\n";