feat(store): add Area admission and audit outbox [T-010]
This commit is contained in:
@@ -22,7 +22,7 @@ foreach ($required in @($initdb, $pgCtl, $psql, $createdb)) {
|
||||
$postgresExe = Join-Path $bin 'postgres.exe'
|
||||
$version = (& $postgresExe --version 2>&1 | Out-String).Trim()
|
||||
if ($LASTEXITCODE -ne 0 -or $version -notmatch 'PostgreSQL\) 17\.10$') {
|
||||
throw 'T-009 integration requires the frozen PostgreSQL 17.10 binaries.'
|
||||
throw 'PostgreSQL integration requires the frozen PostgreSQL 17.10 binaries.'
|
||||
}
|
||||
|
||||
$existing5432 = @(
|
||||
@@ -40,7 +40,7 @@ $port = ([System.Net.IPEndPoint]$listener.LocalEndpoint).Port
|
||||
$listener.Stop()
|
||||
|
||||
$systemTemp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath())
|
||||
$clusterName = 'yovision-t009-pg-' + [guid]::NewGuid().ToString('N')
|
||||
$clusterName = 'yovision-t010-pg-' + [guid]::NewGuid().ToString('N')
|
||||
$dataDir = Join-Path $systemTemp $clusterName
|
||||
$logPath = Join-Path $systemTemp ($clusterName + '.log')
|
||||
$started = $false
|
||||
@@ -69,19 +69,26 @@ try {
|
||||
$started = $true
|
||||
|
||||
$adminRootDSN = "postgres://postgres@127.0.0.1:$port/postgres?sslmode=disable"
|
||||
$databaseName = 'yovision_t009'
|
||||
$databaseName = 'yovision_t010'
|
||||
$adminDatabaseDSN = "postgres://postgres@127.0.0.1:$port/${databaseName}?sslmode=disable"
|
||||
$senseDSN = "postgres://yovision_t009_sense@127.0.0.1:$port/${databaseName}?sslmode=disable"
|
||||
$senseDSN = "postgres://yovision_t010_sense@127.0.0.1:$port/${databaseName}?sslmode=disable"
|
||||
|
||||
Invoke-Checked $psql '-X' '-v' 'ON_ERROR_STOP=1' '-d' $adminRootDSN '-f' (Join-Path $repoRoot 'deploy\postgres\001_roles.sql')
|
||||
Invoke-Checked $createdb '-h' '127.0.0.1' '-p' ([string]$port) '-U' 'postgres' $databaseName
|
||||
|
||||
foreach ($pass in 1..2) {
|
||||
foreach ($name in @('002_bell.sql', '003_sense.sql', '004_privileges.sql')) {
|
||||
foreach ($name in @(
|
||||
'002_bell.sql',
|
||||
'003_sense.sql',
|
||||
'004_privileges.sql',
|
||||
'005_area_policy.sql',
|
||||
'006_device_operation_outbox.sql',
|
||||
'007_privileges_area_audit.sql'
|
||||
)) {
|
||||
Invoke-Checked $psql '-X' '-v' 'ON_ERROR_STOP=1' '-d' $adminDatabaseDSN '-f' (Join-Path $repoRoot "deploy\postgres\$name")
|
||||
}
|
||||
}
|
||||
Invoke-Checked $psql '-X' '-v' 'ON_ERROR_STOP=1' '-d' $adminRootDSN '-c' 'CREATE ROLE yovision_t009_sense LOGIN IN ROLE sense_app'
|
||||
Invoke-Checked $psql '-X' '-v' 'ON_ERROR_STOP=1' '-d' $adminRootDSN '-c' 'CREATE ROLE yovision_t010_sense LOGIN IN ROLE sense_app'
|
||||
Invoke-Checked $psql '-X' '-v' 'ON_ERROR_STOP=1' '-d' $adminDatabaseDSN '-f' (Join-Path $repoRoot 'deploy\postgres\tests\assertions.sql')
|
||||
|
||||
$env:YOVISION_TEST_POSTGRES_DSN = $senseDSN
|
||||
@@ -96,7 +103,7 @@ finally {
|
||||
if (-not $started -or $stopped) {
|
||||
$resolvedData = [IO.Path]::GetFullPath($dataDir)
|
||||
if (-not $resolvedData.StartsWith($systemTemp, [StringComparison]::OrdinalIgnoreCase) -or
|
||||
[IO.Path]::GetFileName($resolvedData) -notlike 'yovision-t009-pg-*') {
|
||||
[IO.Path]::GetFileName($resolvedData) -notlike 'yovision-t010-pg-*') {
|
||||
throw "Refusing to clean unexpected temporary path."
|
||||
}
|
||||
if (Test-Path -LiteralPath $resolvedData) {
|
||||
|
||||
Reference in New Issue
Block a user