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.
48 lines
1.4 KiB
PHTML
48 lines
1.4 KiB
PHTML
|
10 hours ago
|
<?php
|
||
|
|
|
||
|
|
$root = dirname(__DIR__);
|
||
|
|
$schema = file_get_contents($root . '/sql/user_log.sql');
|
||
|
|
$crontab = file_get_contents($root . '/crontab');
|
||
|
|
|
||
|
|
$assert = static function (bool $condition, string $message): void {
|
||
|
|
if (!$condition) {
|
||
|
|
throw new RuntimeException($message);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
$settingBlock = '';
|
||
|
|
if (preg_match(
|
||
|
|
'/ALTER TABLE `setting`(?<body>.*?);/s',
|
||
|
|
(string) $schema,
|
||
|
|
$matches
|
||
|
|
) === 1) {
|
||
|
|
$settingBlock = (string) $matches['body'];
|
||
|
|
}
|
||
|
|
$assert($settingBlock !== '', 'setting indexes are missing');
|
||
|
|
$assert(
|
||
|
|
substr_count($settingBlock, 'UNIQUE KEY') === 1,
|
||
|
|
'setting must have exactly one unique key index'
|
||
|
|
);
|
||
|
|
$assert(
|
||
|
|
str_contains($settingBlock, 'UNIQUE KEY `uniq_setting_key` (`key`)'),
|
||
|
|
'setting unique key index must use the canonical name'
|
||
|
|
);
|
||
|
|
$assert(
|
||
|
|
!str_contains((string) $schema, 'idx_setting_'),
|
||
|
|
'legacy duplicate setting indexes must not remain in fresh schema'
|
||
|
|
);
|
||
|
|
|
||
|
|
$expectedAnalytics = '*/5 * * * * /usr/bin/php '
|
||
|
|
. '/home/virt-cloud/web/xcat siteAnalyticsJob 2 '
|
||
|
|
. '>> /home/virt-cloud/web/storage/logs/site_analytics.log 2>&1';
|
||
|
|
$assert(
|
||
|
|
str_contains((string) $crontab, $expectedAnalytics),
|
||
|
|
'site analytics must retain the original five-minute cron schedule'
|
||
|
|
);
|
||
|
|
$assert(
|
||
|
|
!str_contains((string) $crontab, '/home/www/virt-cloud'),
|
||
|
|
'crontab must use the documented deployment root'
|
||
|
|
);
|
||
|
|
|
||
|
|
echo "Log schema and crontab contract test passed\n";
|