@@ -9,25 +9,15 @@ use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
|
||||
$root = dirname(__DIR__);
|
||||
$proof = json_decode(file_get_contents($root.'/storage/app/private/investmoz-v2/opportunity-resources-backup-proof.json'), true, 512, JSON_THROW_ON_ERROR);
|
||||
$target = $proof['restored_target'];
|
||||
if (! ($proof['restore_verified'] ?? false) || ! preg_match('/^desk_restore_\d{8}_\d{6}_test$/D', $target['database']) || (int) $target['port'] !== 55441) {
|
||||
throw new RuntimeException('Verified restored QA target required');
|
||||
}
|
||||
foreach (['APP_ENV' => 'testing', 'APP_DEBUG' => 'false', 'APP_KEY' => 'base64:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=',
|
||||
'DB_CONNECTION' => 'pgsql', 'DB_HOST' => '127.0.0.1', 'DB_PORT' => '55441', 'DB_DATABASE' => $target['database'],
|
||||
'DB_USERNAME' => 'postgres', 'DB_PASSWORD' => '', 'DB_URL' => '', 'CACHE_STORE' => 'array', 'SESSION_DRIVER' => 'array', 'QUEUE_CONNECTION' => 'sync'] as $key => $value) {
|
||||
putenv($key.'='.$value);
|
||||
$_ENV[$key] = $_SERVER[$key] = $value;
|
||||
}
|
||||
require_once $root.'/tools/portal-qa-environment.php';
|
||||
$target = portalQaEnvironment();
|
||||
require $root.'/vendor/autoload.php';
|
||||
$app = require $root.'/bootstrap/app.php';
|
||||
$kernel = $app->make(Kernel::class);
|
||||
$kernel->bootstrap();
|
||||
$identity = DB::selectOne('SELECT current_database() AS database,inet_server_port() AS port');
|
||||
if ($identity->database !== $target['database'] || (int) $identity->port !== 55441) {
|
||||
throw new RuntimeException('Non-QA database rejected');
|
||||
}
|
||||
$identity = portalQaAssertTarget($target);
|
||||
DB::beginTransaction();
|
||||
DB::statement('SET TRANSACTION READ ONLY');
|
||||
// Enumerating the whole catalogue is a QA coverage run, independent of rate-limit acceptance.
|
||||
RateLimiter::for('api', fn () => Limit::none());
|
||||
$expected = app(InvestmentGeography::class)->publicReferences()->whereIn('location_type', ['province', 'district', 'admin_post', 'locality'])
|
||||
@@ -74,6 +64,7 @@ foreach (['province' => null, 'district' => 'province', 'admin_post' => 'distric
|
||||
if (count($seen) !== $expected->count()) {
|
||||
throw new RuntimeException('Unreachable catalogue references');
|
||||
}
|
||||
DB::rollBack();
|
||||
$result = ['captured_at' => gmdate('c'), 'target' => $identity, 'source' => 'Verified active backup restored in QA', 'counts' => $counts,
|
||||
'references_expected' => $expected->count(), 'references_recovered' => count($seen), 'api_requests' => count($results), 'checks' => $results,
|
||||
'visual_verified' => false, 'all_consumers_accepted' => false, 'geometry_rows' => DB::table('geo_geometries')->count(),
|
||||
|
||||
Reference in New Issue
Block a user