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.
66 lines
2.6 KiB
PHP
66 lines
2.6 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 (bool $condition, string $message): void {
|
|
if (!$condition) {
|
|
throw new RuntimeException($message);
|
|
}
|
|
};
|
|
if (!is_string($schema) || !is_string($setup)) {
|
|
throw new RuntimeException('Rescue catalog schema sources are unreadable.');
|
|
}
|
|
|
|
foreach ([
|
|
'cloud_rescue_templates',
|
|
'cloud_rescue_template_artifacts',
|
|
'cloud_rescue_template_replicas',
|
|
] as $table) {
|
|
$assert(str_contains($schema, 'CREATE TABLE ' . $table . ' ('),
|
|
'Missing global rescue catalog table: ' . $table);
|
|
$assert(str_contains($setup, "'" . $table . "'"),
|
|
'CloudSetup does not require global rescue table: ' . $table);
|
|
}
|
|
|
|
$catalog = preg_match(
|
|
'/CREATE TABLE cloud_rescue_templates \((.*?)\n\) ENGINE=/s',
|
|
$schema,
|
|
$catalogMatch
|
|
) === 1 ? $catalogMatch[1] : '';
|
|
$artifact = preg_match(
|
|
'/CREATE TABLE cloud_rescue_template_artifacts \((.*?)\n\) ENGINE=/s',
|
|
$schema,
|
|
$artifactMatch
|
|
) === 1 ? $artifactMatch[1] : '';
|
|
$replica = preg_match(
|
|
'/CREATE TABLE cloud_rescue_template_replicas \((.*?)\n\) ENGINE=/s',
|
|
$schema,
|
|
$replicaMatch
|
|
) === 1 ? $replicaMatch[1] : '';
|
|
|
|
$assert($catalog !== ''
|
|
&& str_contains($catalog, 'generation_token CHAR(32)')
|
|
&& str_contains($catalog, 'revision BIGINT UNSIGNED')
|
|
&& str_contains($catalog, 'active_job_id BIGINT UNSIGNED'),
|
|
'Rescue master does not retain immutable identity and active-job fencing.');
|
|
$assert($artifact !== ''
|
|
&& !str_contains($artifact, 'sealed_storage_runtime')
|
|
&& str_contains($artifact, 'storage_artifact_id BIGINT UNSIGNED')
|
|
&& str_contains($artifact, 'object_version_id VARCHAR(1024)')
|
|
&& str_contains($artifact, 'delete_presence_confirmations')
|
|
&& str_contains($artifact, 'delete_attention_at'),
|
|
'Rescue artifact retained a legacy runtime or lost exact deletion identity.');
|
|
$assert($replica !== ''
|
|
&& str_contains($replica, 'observed_generation_token CHAR(32)')
|
|
&& str_contains($replica, 'observed_sha256 CHAR(64)')
|
|
&& str_contains($replica, 'cleanup_resolved_at BIGINT UNSIGNED'),
|
|
'Rescue replica cannot prove exact identity or retain cleanup debt.');
|
|
$assert(str_contains($setup,
|
|
"SCHEMA_VERSION = 'go-agent-wss-v42-abuse-observation'")
|
|
&& str_contains($setup, "'cloud_rescue_artifact_delete_due'")
|
|
&& str_contains($setup, "'cloud_rescue_replica_cleanup'"),
|
|
'CloudSetup version or rescue catalog indexes are incomplete.');
|
|
|
|
echo "Global rescue catalog schema contract passed.\n";
|