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.
51 lines
1.8 KiB
PHP
51 lines
1.8 KiB
PHP
<?php
|
|
|
|
$root = dirname(__DIR__);
|
|
$schema = file_get_contents($root . '/sql/cloud.sql');
|
|
$failures = [];
|
|
$assert = static function (bool $condition, string $message) use (&$failures): void {
|
|
if (!$condition) {
|
|
$failures[] = $message;
|
|
}
|
|
};
|
|
|
|
foreach ([
|
|
'cloud_host_resource_pool_memberships',
|
|
'cloud_host_network_attachments',
|
|
'cloud_public_ip_pools',
|
|
] as $table) {
|
|
$assert(str_contains($schema, 'CREATE TABLE IF NOT EXISTS ' . $table . ' ('),
|
|
$table . ' schema is missing.');
|
|
}
|
|
|
|
$assert(str_contains($schema,
|
|
'UNIQUE KEY cloud_host_pool_membership (host_id, resource_pool_id)'),
|
|
'A physical host must not have duplicate memberships in one resource pool.');
|
|
$assert(str_contains($schema,
|
|
'UNIQUE KEY cloud_host_network_attachment_key (host_id, attachment_key)'),
|
|
'Network attachment keys must be stable and host-scoped.');
|
|
$assert(str_contains($schema,
|
|
'UNIQUE KEY cloud_public_ip_pool_key (host_id, pool_key)'),
|
|
'Public pool keys must be stable and host-scoped.');
|
|
$assert(str_contains($schema,
|
|
'KEY cloud_public_ip_pool_available (public_ip_pool_id, state, id)'),
|
|
'Concrete public IP allocation must be indexed by public pool.');
|
|
$assert(str_contains($schema,
|
|
'KEY cloud_resource_reservation_network (network_attachment_id, public_ip_pool_id)'),
|
|
'Reservations must retain their immutable network allocation boundary.');
|
|
|
|
foreach ([
|
|
'app/Models/CloudHostResourcePoolMembership.php',
|
|
'app/Models/CloudHostNetworkAttachment.php',
|
|
'app/Models/CloudPublicIpPool.php',
|
|
] as $model) {
|
|
$assert(is_file($root . '/' . $model), $model . ' is missing.');
|
|
}
|
|
|
|
if ($failures !== []) {
|
|
fwrite(STDERR, implode("\n", $failures) . "\n");
|
|
exit(1);
|
|
}
|
|
|
|
echo "Cloud multi-public-pool schema definitions passed.\n";
|