feat(sense): implement Control API v1 [T-011]
This commit is contained in:
@@ -40,7 +40,7 @@ $port = ([System.Net.IPEndPoint]$listener.LocalEndpoint).Port
|
||||
$listener.Stop()
|
||||
|
||||
$systemTemp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath())
|
||||
$clusterName = 'yovision-t010-pg-' + [guid]::NewGuid().ToString('N')
|
||||
$clusterName = 'yovision-t011-pg-' + [guid]::NewGuid().ToString('N')
|
||||
$dataDir = Join-Path $systemTemp $clusterName
|
||||
$logPath = Join-Path $systemTemp ($clusterName + '.log')
|
||||
$started = $false
|
||||
@@ -69,9 +69,9 @@ try {
|
||||
$started = $true
|
||||
|
||||
$adminRootDSN = "postgres://postgres@127.0.0.1:$port/postgres?sslmode=disable"
|
||||
$databaseName = 'yovision_t010'
|
||||
$databaseName = 'yovision_t011'
|
||||
$adminDatabaseDSN = "postgres://postgres@127.0.0.1:$port/${databaseName}?sslmode=disable"
|
||||
$senseDSN = "postgres://yovision_t010_sense@127.0.0.1:$port/${databaseName}?sslmode=disable"
|
||||
$senseDSN = "postgres://yovision_t011_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
|
||||
@@ -83,12 +83,14 @@ try {
|
||||
'004_privileges.sql',
|
||||
'005_area_policy.sql',
|
||||
'006_device_operation_outbox.sql',
|
||||
'007_privileges_area_audit.sql'
|
||||
'007_privileges_area_audit.sql',
|
||||
'008_control_api.sql',
|
||||
'009_privileges_control_api.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_t010_sense LOGIN IN ROLE sense_app'
|
||||
Invoke-Checked $psql '-X' '-v' 'ON_ERROR_STOP=1' '-d' $adminRootDSN '-c' 'CREATE ROLE yovision_t011_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
|
||||
@@ -103,7 +105,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-t010-pg-*') {
|
||||
[IO.Path]::GetFileName($resolvedData) -notlike 'yovision-t011-pg-*') {
|
||||
throw "Refusing to clean unexpected temporary path."
|
||||
}
|
||||
if (Test-Path -LiteralPath $resolvedData) {
|
||||
|
||||
Reference in New Issue
Block a user