commit15
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
// Read-only fingerprints of the disposable regression DB, never of client data.
|
||||
putenv('APP_ENV=testing');
|
||||
$runtime = 'C:/laragon/data/sgf-tempo/run';
|
||||
$state = json_decode(file_get_contents($runtime.'/modular-regression-current.json'), true, 512, JSON_THROW_ON_ERROR);
|
||||
if (!preg_match('/^[a-f0-9]{12}$/D', $state['id']) || realpath($state['root']) !== realpath($runtime.'/modular-regression-'.$state['id'])
|
||||
|| realpath($state['app']) !== realpath($state['root'].'/app') || $state['port'] !== 55439) throw new RuntimeException('Unexpected regression host');
|
||||
require $state['app'].'/vendor/autoload.php';
|
||||
$app = require $state['app'].'/bootstrap/app.php';
|
||||
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
||||
App\Shared\Testing\TestingDatabaseGuard::assertSafe();
|
||||
$db = Illuminate\Support\Facades\DB::connection();
|
||||
$db->beginTransaction();
|
||||
try {
|
||||
$db->statement('SET TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ ONLY');
|
||||
$identity = $db->selectOne("SELECT current_database() AS database,current_user AS role,inet_server_port() AS port,current_setting('cluster_name') AS cluster");
|
||||
if ($identity->database !== 'sgf_tempo_test' || $identity->role !== 'sgf_test_runner' || (int) $identity->port !== 55439
|
||||
|| $identity->cluster !== 'sgf_modular_regression_'.$state['id']) throw new RuntimeException('Unexpected effective regression identity');
|
||||
$tables = [];
|
||||
foreach (['a_clients', 'a_services', 'a_service_drafts', 'a_billing_drafts', 'identity_audit', 'users', 'permission_grants', 'company_memberships'] as $table) {
|
||||
$tables[$table] = $db->selectOne("SELECT count(*) AS rows,md5(coalesce(string_agg(row_to_json(t)::text,E'\\n' ORDER BY row_to_json(t)::text),'')) AS fingerprint FROM {$table} t");
|
||||
}
|
||||
echo json_encode(['identity' => $identity, 'tables' => $tables, 'read_only' => true], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR).PHP_EOL;
|
||||
} finally { $db->rollBack(); }
|
||||
Reference in New Issue
Block a user