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.
63 lines
2.4 KiB
PHP
63 lines
2.4 KiB
PHP
<?php
|
|
|
|
$root = dirname(__DIR__);
|
|
$schema = file_get_contents($root . '/sql/cloud.sql');
|
|
$setup = file_get_contents($root . '/app/Command/CloudSetup.php');
|
|
$assert = static function ($condition, string $message): void {
|
|
if (!$condition) {
|
|
throw new RuntimeException($message);
|
|
}
|
|
};
|
|
|
|
foreach ([
|
|
'cloud_maintenance_notices',
|
|
'cloud_maintenance_notice_instances',
|
|
'cloud_maintenance_notice_recipients',
|
|
] as $table) {
|
|
$assert(str_contains($schema, 'CREATE TABLE ' . $table . ' ('),
|
|
'Maintenance notice schema is missing ' . $table . '.');
|
|
$assert(str_contains($setup, "'" . $table . "'"),
|
|
'CloudSetup does not require ' . $table . '.');
|
|
}
|
|
|
|
foreach ([
|
|
'UNIQUE KEY cloud_maintenance_notice_request',
|
|
'UNIQUE KEY cloud_maintenance_notice_instance (notice_id, instance_id)',
|
|
'UNIQUE KEY cloud_maintenance_notice_recipient (notice_id, user_id)',
|
|
'KEY cloud_maintenance_notice_recipient_due',
|
|
'KEY cloud_maintenance_notice_recipient_lease',
|
|
'fk_cloud_maintenance_notice_instance_notice',
|
|
'fk_cloud_maintenance_notice_recipient_notice',
|
|
"status IN (\n 'pending','sending','sent','failed','unknown','skipped','cancelled'",
|
|
] as $contract) {
|
|
$assert(str_contains($schema, $contract),
|
|
'Maintenance notice schema lost contract: ' . $contract);
|
|
}
|
|
|
|
foreach ([
|
|
"'chk_cloud_maintenance_notice_scope'",
|
|
"'chk_cloud_maintenance_notice_impact'",
|
|
"'chk_cloud_maintenance_notice_status'",
|
|
"'chk_cloud_maintenance_notice_window'",
|
|
"'chk_cloud_maintenance_notice_terminal'",
|
|
"'chk_cloud_maintenance_notice_recipient_status'",
|
|
"'chk_cloud_maintenance_notice_recipient_shape'",
|
|
"'cloud_maintenance_notice_request' => [",
|
|
"'columns' => [\n 'requested_by_user_id', 'request_idempotency_key',",
|
|
"'cloud_maintenance_notice_recipient' => [",
|
|
"'columns' => ['notice_id', 'user_id']",
|
|
"'cloud_maintenance_notice_recipient_due' => [",
|
|
"'columns' => ['status', 'available_at', 'id']",
|
|
"'cloud_maintenance_notice_recipient_lease' => [",
|
|
"'columns' => ['status', 'lease_until', 'id']",
|
|
] as $setupContract) {
|
|
$assert(str_contains($setup, $setupContract),
|
|
'CloudSetup lost maintenance notice contract: ' . $setupContract);
|
|
}
|
|
|
|
$assert(str_contains($setup,
|
|
"SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'"),
|
|
'CloudSetup schema version was not advanced for maintenance notices.');
|
|
|
|
echo "Maintenance notice schema contracts passed.\n";
|