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.
21 lines
982 B
PHP
21 lines
982 B
PHP
<?php
|
|
|
|
$root = dirname(__DIR__);
|
|
$python = file_get_contents(dirname($root) . '/engine/virsh_panel/database.py');
|
|
if (preg_match('/_METRIC_SCHEMA\s*=\s*"""(.*?)"""/s', $python, $match) !== 1) {
|
|
throw new RuntimeException('Engine metric schema missing');
|
|
}
|
|
$sql = file_get_contents($root . '/sql/cloud_log.sql');
|
|
$normalize = static function ($value): string {
|
|
$value = preg_replace('/^\s*--[^\n]*$/m', '', $value);
|
|
return rtrim(trim(preg_replace('/\s+/', ' ', $value)), ';');
|
|
};
|
|
$expected = str_replace('vm_metric_samples', 'engine_vm_metric_samples', $match[1]);
|
|
if ($normalize($sql) !== $normalize($expected)) {
|
|
throw new RuntimeException('Fresh-install metric SQL differs from engine-owned schema');
|
|
}
|
|
if (!str_contains($sql, 'CREATE TABLE IF NOT EXISTS engine_vm_metric_samples')) {
|
|
throw new RuntimeException('Metric initializer must execute DDL, not an empty/comment-only query');
|
|
}
|
|
echo "Fresh-install log metric DDL matches the Python engine schema.\n";
|