ci-server-engineer/examples/CI-Eng-Sample/shared/snapshot.ps1
cliu 48426a0a14 R1.05 write tests V9, V10, V12, V15 on the shared test server
With the user's approval: item blocking and string length, alarm raise /
acknowledge / delay / repeat and INFO event, report generate / print /
item trigger / rptstp / SPOOL, class change and reset and attribute
change. All results match R1.03 (ISS-028 still holds). Everything was
removed again; before/after snapshot identical. ISS-129 and ISS-158
closed. Test package saved in examples/CI-Eng-Sample/shared/write_test;
snapshot.ps1 now removes the dss_*.tmp files its own exports leave.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 10:52:20 +11:00

43 lines
2.5 KiB
PowerShell

# Read-only snapshot of everything the reduced CI-Eng-Sample test can touch.
param([string]$Out)
$ErrorActionPreference = 'Continue'
$started = Get-Date
$w = New-Object System.Collections.Generic.List[string]
$tmp = Join-Path $PSScriptRoot 'snapx'
New-Item -ItemType Directory -Force -Path $tmp | Out-Null
$ds = 'SECTION_DF','ITEM_DF','SUB_ITEM_DF','ALARM_ACK_DF','ALARM_AOI_DF','ALARM_ASA_DF','TRIGGER_DF',
'CLASS_DF','OBJECT_DF','LINE_DF','STATION_DF','POINT_DF','MODBUS_LINE_DF','MODBUS_STATION_DF',
'MODBUS_SCAN_TYPE_DF','MODBUS_POINT_DF','OPCUAC_LINE_DF','OPCUAC_STATION_DF',
'OPCUAC_SUBSCRIPTION_DF','OPCUAC_POINT_DF','PRINTER_DEV_DF','PRINTER_DEST_DF','REPORT_DF',
'AUDIT_SELGRP_DF','OPCUAC_PKI_CERTIFICATES_DF'
foreach ($d in $ds) {
$f = Join-Path $tmp "$d.qlo"
$null = & dssqld -e $f -d $d -c 2>&1
$names = @()
if (Test-Path $f) { $names = @(Import-Csv $f | ForEach-Object { $_.NAME }) | Sort-Object }
$sha = [BitConverter]::ToString((New-Object Security.Cryptography.SHA256Managed).ComputeHash([Text.Encoding]::UTF8.GetBytes(($names -join "`n")))).Replace('-','').Substring(0,16)
$mine = @($names | Where-Object { $_ -match 'CIENG|CI-Eng' })
$w.Add("DS $d count=$($names.Count) hash=$sha cieng=$($mine.Count) $($mine -join ';')")
}
Remove-Item -Recurse -Force $tmp
# The exports above (OBJECT_DF) leave empty dss_*.tmp files in tls\lst (ISS-119): remove the ones
# this run wrote, so the snapshot does not change the system it describes.
Get-ChildItem -Path $env:TLS_LST_PATH -Filter 'dss_*.tmp' -ErrorAction SilentlyContinue |
Where-Object { $_.Length -eq 0 -and $_.LastWriteTime -ge $started } |
Remove-Item -ErrorAction SilentlyContinue
$root = $env:TLS_ALLUSERS_PATH
foreach ($sub in 'com','sup','sav','lst') {
foreach ($i in (Get-ChildItem -Path (Join-Path $env:TLS_ROOT_PATH "tls\$sub") -File | Sort-Object Name)) {
if ($sub -eq 'lst' -or $sub -eq 'sav') { $w.Add("FILE $sub\$($i.Name)") }
else { $w.Add("FILE $sub\$($i.Name) $($i.Length) $($i.LastWriteTime.ToString('s'))") }
}
}
foreach ($i in (Get-ChildItem -Path (Join-Path $root 'pki') -Recurse -File | Sort-Object FullName)) {
$w.Add("PKI $($i.FullName.Substring($root.Length)) $($i.Length)")
}
$exe = Join-Path $env:TLS_ROOT_PATH 'tls\exe'
foreach ($g in (Get-Process | Where-Object { $_.Path -like "$exe*" } | Group-Object Name | Sort-Object Name)) {
$w.Add("PROC $($g.Name) x$($g.Count)")
}
$w | Set-Content -Encoding utf8 $Out
"snapshot: $($w.Count) lines -> $Out"