فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
test(holoo): add direct SQL lab readiness without VM prerequisite
Davood Mehraban committed
Nov 22, 2026 at 20:38 UTC
90086609fcd1c5153bd448227e32ed45c861afc0
1 file changed
+24
scripts/holoo-direct-sql-readiness.ps1
new
+24
@@ -0,0 +1,24 @@
1
+# Read-only readiness check for direct Holoo SQL testing on Aram.
2
+[CmdletBinding()]
3
+param([string]$Server='ARAM\TNC',[string]$Database='HolooBackup_050808_LAB_20261110',[switch]$Json)
4
+$ErrorActionPreference='Stop'
5
+$checks=New-Object System.Collections.Generic.List[object]
6
+function Add-Check($Name,$Status,$Detail){$checks.Add([pscustomobject]@{name=$Name;status=$Status;detail=$Detail})}
7
+if($Database -notmatch '^Holoo[A-Za-z0-9_]+LAB_[0-9]{8}$') {Add-Check 'database-selection' 'BLOCKED' 'Only explicitly named LAB databases are accepted'} else {Add-Check 'database-selection' 'PASS' 'Explicit LAB database selected'}
8
+try {
9
+ Add-Type -AssemblyName System.Data
10
+ $c=New-Object System.Data.SqlClient.SqlConnection("Server=$Server;Database=master;Integrated Security=True;Connection Timeout=5")
11
+ $c.Open()
12
+ Add-Check 'connection' 'PASS' 'Windows authentication connected to SQL Server'
13
+ $q=$c.CreateCommand();$q.CommandText='SELECT state_desc,is_read_only FROM sys.databases WHERE name=@db';$null=$q.Parameters.Add('@db',[System.Data.SqlDbType]::NVarChar,128);$q.Parameters['@db'].Value=$Database
14
+ $r=$q.ExecuteReader()
15
+ if(-not $r.Read()){Add-Check 'database' 'BLOCKED' 'Selected database not found'} else {
16
+ $state=$r.GetString(0);$ro=$r.GetBoolean(1)
17
+ if($state -ne 'ONLINE'){Add-Check 'database' 'BLOCKED' 'Database is not online'} elseif($ro){Add-Check 'database' 'BLOCKED' 'Database is read-only'} else {Add-Check 'database' 'PASS' 'Selected LAB database is online and writable'}
18
+ }
19
+ $r.Close();$c.Close()
20
+} catch {Add-Check 'connection' 'BLOCKED' ('SQL connectivity failed: '+$_.Exception.GetType().Name)}
21
+$blocked=@($checks|Where-Object {$_.status -eq 'BLOCKED'}).Count
22
+$result=[pscustomobject]@{schemaVersion=1;readyForLabSql=($blocked -eq 0);checks=$checks.ToArray();note='Readiness does not authorize writes or prove Holoo behavioral parity'}
23
+if($Json){$result|ConvertTo-Json -Depth 5}else{$checks|Format-Table -AutoSize;Write-Output ('READY_FOR_LAB_SQL='+$result.readyForLabSql)}
24
+if($blocked -gt 0){exit 2}