mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-21 11:25:56 +00:00
Preserve local historical work separately from the release candidate
This commit is contained in:
1 parent
654b7cddd3
commit
ab4bc9fd96
47 files changed
+1711
-204
No files matched your search
@@ -0,0 +1,133 @@
|
||||
param(
|
||||
[Parameter(Mandatory)][string]$BasePackage,
|
||||
[Parameter(Mandatory)][string]$CandidatePackage,
|
||||
[string]$DataSource = '',
|
||||
[string]$PreviousPackage = '',
|
||||
[ValidateSet('coa','wildcard','dual','squid','imported')][string]$Mode = 'coa',
|
||||
[switch]$SkipBuild,
|
||||
[string]$ReportFile = '',
|
||||
[string]$Target = (Join-Path $env:RUNNER_TEMP ('coa-schema-fixture-chaos-' + [guid]::NewGuid().ToString('N')))
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$project = Split-Path $PSScriptRoot -Parent
|
||||
$tool = Join-Path $project 'target/debug/coa-release.exe'
|
||||
$test = Join-Path $project 'target/debug/examples/update_acceptance_e2e.exe'
|
||||
if (Test-Path -LiteralPath $Target) { throw 'Use a new disposable fixture directory.' }
|
||||
if ((Split-Path $Target -Leaf) -notlike 'coa-schema-fixture-chaos-*') { throw 'Invalid disposable fixture name.' }
|
||||
if (-not $SkipBuild) {
|
||||
& cargo build --manifest-path "$project/Cargo.toml" -p coa-release -p coa-core --example update_acceptance_e2e --features coa-core/testkit --locked
|
||||
if ($LASTEXITCODE) { throw 'Could not build acceptance tools.' }
|
||||
& cargo build --manifest-path "$project/Cargo.toml" -p coa-release --locked
|
||||
if ($LASTEXITCODE) { throw 'Could not build release tools.' }
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $tool) -or -not (Test-Path -LiteralPath $test)) { throw 'Acceptance tools are missing.' }
|
||||
& $tool extract-schema-base --package $BasePackage --fixture $Target
|
||||
if ($LASTEXITCODE) { throw 'Could not prepare the signed base.' }
|
||||
[IO.File]::WriteAllText((Join-Path $Target '.coa-chaos-fixture'), 'disposable update chaos fixture')
|
||||
# A real independent copy: a junction would allow validation to modify source data.
|
||||
if ($DataSource) {
|
||||
& robocopy $DataSource (Join-Path $Target 'Data') /E /R:1 /W:1 /NFL /NDL /NJH /NJS /NP | Out-Null
|
||||
if ($LASTEXITCODE -ge 8) { throw 'Could not copy isolated game data.' }
|
||||
} else {
|
||||
& $tool extract-game-data --package $BasePackage --fixture $Target
|
||||
if ($LASTEXITCODE) { throw 'Could not extract signed game data.' }
|
||||
}
|
||||
& $test init $Target
|
||||
if ($LASTEXITCODE) { throw 'Could not initialize sentinels.' }
|
||||
& $test seed-players $Target
|
||||
if ($LASTEXITCODE) { throw 'Could not seed real account, character and inventory records.' }
|
||||
if ($PreviousPackage) {
|
||||
& $test baseline-release $Target $PreviousPackage
|
||||
if ($LASTEXITCODE) { throw 'Previous published release could not be established.' }
|
||||
}
|
||||
& $test apply $Target $CandidatePackage
|
||||
if ($LASTEXITCODE) { throw 'Candidate failed acceptance.' }
|
||||
& $test prepare-mode $Target $Mode
|
||||
if ($LASTEXITCODE) { throw "Could not prepare $Mode installation." }
|
||||
if ($PreviousPackage) {
|
||||
# Re-establish the old signed release after mode provisioning, so the actual
|
||||
# upgrade below runs in this mode rather than only in the initial CoA setup.
|
||||
& $test baseline-release $Target $PreviousPackage
|
||||
if ($LASTEXITCODE) { throw "Previous release could not be established in $Mode mode." }
|
||||
}
|
||||
& $test seed-config $Target
|
||||
if ($LASTEXITCODE) { throw 'Could not seed a modified user configuration.' }
|
||||
& $test break-legacy-baseline $Target
|
||||
if ($LASTEXITCODE) { throw 'Could not inject missing-table baseline.' }
|
||||
& $test apply $Target $CandidatePackage
|
||||
if ($LASTEXITCODE) { throw 'Legacy missing-table baseline was not repaired.' }
|
||||
& $test verify $Target
|
||||
if ($LASTEXITCODE) { throw 'Sentinels were lost.' }
|
||||
foreach ($rejection in @('expect-corrupt-package','expect-locked-file','expect-occupied-port')) {
|
||||
& $test $rejection $Target $CandidatePackage
|
||||
if ($LASTEXITCODE) { throw "$rejection did not reject safely." }
|
||||
}
|
||||
$oldPythonFailure = $env:COA_UPDATE_PYTHON_FAILURE
|
||||
try {
|
||||
$env:COA_UPDATE_PYTHON_FAILURE = '1'
|
||||
& $test expect-rejection $Target $CandidatePackage
|
||||
if ($LASTEXITCODE) { throw 'Python failure was not restored.' }
|
||||
} finally { $env:COA_UPDATE_PYTHON_FAILURE = $oldPythonFailure }
|
||||
$oldValidation = $env:COA_UPDATE_VALIDATION
|
||||
try {
|
||||
$env:COA_UPDATE_VALIDATION = '1'
|
||||
& $test start-fixture $Target
|
||||
if ($LASTEXITCODE) { throw 'Original offline fixture could not start.' }
|
||||
$env:COA_UPDATE_PYTHON_FAILURE = '1'
|
||||
& $test expect-rejection $Target $CandidatePackage
|
||||
if ($LASTEXITCODE) { throw 'The originally running server was not restored.' }
|
||||
} finally {
|
||||
$env:COA_UPDATE_PYTHON_FAILURE = $oldPythonFailure
|
||||
& $test stop-fixture $Target
|
||||
$stopResult = $LASTEXITCODE
|
||||
$env:COA_UPDATE_VALIDATION = $oldValidation
|
||||
if ($stopResult) { throw 'The offline running-state fixture could not be stopped.' }
|
||||
}
|
||||
$oldSqlFailure = $env:COA_UPDATE_SQL_FAILURE
|
||||
try {
|
||||
& $test break-legacy-baseline $Target
|
||||
if ($LASTEXITCODE) { throw 'Could not prepare partial-DDL failure.' }
|
||||
$env:COA_UPDATE_SQL_FAILURE = 'manager_repair__20261005_reconcile_wildcard_tables'
|
||||
& $test expect-rejection $Target $CandidatePackage
|
||||
if ($LASTEXITCODE) { throw 'Partial DDL/SQL failure was not restored.' }
|
||||
} finally { $env:COA_UPDATE_SQL_FAILURE = $oldSqlFailure }
|
||||
$oldCrash = $env:COA_UPDATE_CRASH_AT
|
||||
try {
|
||||
$env:COA_UPDATE_CRASH_AT = 'snapshot-recorded'
|
||||
& $test apply $Target $CandidatePackage
|
||||
if ($LASTEXITCODE -ne 91) { throw 'The recorded-snapshot interruption was not exercised.' }
|
||||
$env:COA_UPDATE_CRASH_AT = ''
|
||||
foreach ($corruption in @('expect-corrupt-journal','expect-corrupt-recovery-point')) {
|
||||
& $test $corruption $Target
|
||||
if ($LASTEXITCODE) { throw "Corruption guard $corruption failed." }
|
||||
}
|
||||
& $test rollback $Target
|
||||
if ($LASTEXITCODE) { throw 'Recovery after removing injected corruption failed.' }
|
||||
foreach ($point in @('stopped','snapshot','trial','before-file:0','journal-file:0','written-file:0','completed-file:0','applied','before-migrations','before-sql:manager_repair__20261005_reconcile_wildcard_tables','after-sql:manager_repair__20261005_reconcile_wildcard_tables','recorded-sql:manager_repair__20261005_reconcile_wildcard_tables','migrated','validated','before-commit','commit-metadata')) {
|
||||
$env:COA_UPDATE_CRASH_AT = ''
|
||||
& $test break-legacy-baseline $Target
|
||||
if ($LASTEXITCODE) { throw 'Could not reset isolated baseline.' }
|
||||
& $test dirty-fixture $Target $CandidatePackage
|
||||
if ($LASTEXITCODE) { throw 'Could not arrange a real file replacement.' }
|
||||
$env:COA_UPDATE_CRASH_AT = $point
|
||||
& $test apply $Target $CandidatePackage
|
||||
if ($LASTEXITCODE -ne 91) { throw "Fault point $point was not exercised (exit $LASTEXITCODE)." }
|
||||
foreach ($recoveryPoint in @('restore-stopped','restore-databases','restore-files')) {
|
||||
$env:COA_UPDATE_CRASH_AT = $recoveryPoint
|
||||
& $test rollback $Target
|
||||
# restore-databases may not be reached before any live database changes.
|
||||
if ($LASTEXITCODE -notin @(0,91)) { throw "Recovery fault $recoveryPoint failed." }
|
||||
if ($LASTEXITCODE -eq 0) { break }
|
||||
}
|
||||
$env:COA_UPDATE_CRASH_AT = ''
|
||||
& $test rollback $Target
|
||||
if ($LASTEXITCODE) { throw "Recovery from $point failed." }
|
||||
}
|
||||
} finally { $env:COA_UPDATE_CRASH_AT = $oldCrash }
|
||||
$manifest = Get-Content (Join-Path $CandidatePackage 'manifest.json') -Raw | ConvertFrom-Json
|
||||
$managerSource = (& git -C $project rev-parse HEAD).Trim()
|
||||
if ($LASTEXITCODE -or $managerSource -notmatch '^[0-9a-f]{40}$') { throw 'Cannot identify the tested manager source.' }
|
||||
$report = @{ schema = 1; version = $manifest.version; manifestSha256 = (Get-FileHash (Join-Path $CandidatePackage 'manifest.json') -Algorithm SHA256).Hash.ToLower(); manager = (Get-FileHash $test -Algorithm SHA256).Hash.ToLower(); managerSource = $managerSource; mode = $Mode; baseline = $(if ($PreviousPackage) { (Get-Content (Join-Path $PreviousPackage 'manifest.json') -Raw | ConvertFrom-Json).version } else { 'base' }); result = 'passed' }
|
||||
$report.coverage = @('signed-package-corruption','locked-file','occupied-port','python-startup-failure','partial-ddl-invalid-sql','update-process-crash','recovery-process-crash','modified-config-preservation','running-state-recovery','player-data-preservation','corrupt-journal','corrupt-recovery-point')
|
||||
if (-not $ReportFile) { $ReportFile = Join-Path $CandidatePackage 'acceptance.json' }
|
||||
$report | ConvertTo-Json | Set-Content $ReportFile -Encoding utf8NoBOM
|
||||
@@ -0,0 +1,81 @@
|
||||
param(
|
||||
[Parameter(Mandatory)][string]$BasePackage,
|
||||
[Parameter(Mandatory)][string]$CandidatePackage,
|
||||
[string]$PreviousPackage = '',
|
||||
[string]$DataSource = '',
|
||||
[ValidateRange(1,5)][int]$MaxParallel = 2,
|
||||
[string]$WorkDirectory = (Join-Path $env:RUNNER_TEMP ('coa-acceptance-' + [guid]::NewGuid().ToString('N')))
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$project = Split-Path $PSScriptRoot -Parent
|
||||
& git -C $project diff --quiet HEAD --
|
||||
if ($LASTEXITCODE) { throw 'Release acceptance requires committed manager source; tracked changes are present.' }
|
||||
$untrackedSource = & git -C $project ls-files --others --exclude-standard -- crates src src-tauri tools .github
|
||||
if ($LASTEXITCODE -or $untrackedSource) { throw 'Release acceptance requires committed manager source; untracked source files are present.' }
|
||||
$base = (Resolve-Path -LiteralPath $BasePackage).Path
|
||||
$candidate = (Resolve-Path -LiteralPath $CandidatePackage).Path
|
||||
$previous = if ($PreviousPackage) { (Resolve-Path -LiteralPath $PreviousPackage).Path } else { '' }
|
||||
$data = if ($DataSource) { (Resolve-Path -LiteralPath $DataSource).Path } else { '' }
|
||||
if (Test-Path -LiteralPath $WorkDirectory) { throw 'Use a fresh acceptance work directory.' }
|
||||
New-Item -ItemType Directory -Path $WorkDirectory | Out-Null
|
||||
$work = (Resolve-Path -LiteralPath $WorkDirectory).Path
|
||||
& cargo build --manifest-path "$project/Cargo.toml" -p coa-core --example update_acceptance_e2e --features testkit --locked
|
||||
if ($LASTEXITCODE) { throw 'Could not build the marked-fixture acceptance tool.' }
|
||||
& cargo build --manifest-path "$project/Cargo.toml" -p coa-release --locked
|
||||
if ($LASTEXITCODE) { throw 'Could not build signature verification tools.' }
|
||||
|
||||
$queue = [Collections.Generic.Queue[object]]::new()
|
||||
foreach ($mode in @('coa','wildcard','dual','squid','imported')) {
|
||||
$queue.Enqueue(@{ mode=$mode; baseline='base'; previous='' })
|
||||
if ($previous) { $queue.Enqueue(@{ mode=$mode; baseline='previous'; previous=$previous }) }
|
||||
}
|
||||
$active = [Collections.Generic.List[object]]::new()
|
||||
$completed = [Collections.Generic.List[object]]::new()
|
||||
try {
|
||||
while ($queue.Count -or $active.Count) {
|
||||
while ($queue.Count -and $active.Count -lt $MaxParallel) {
|
||||
$job = $queue.Dequeue()
|
||||
$name = "$($job.mode)-$($job.baseline)"
|
||||
$report = Join-Path $work "$name.json"
|
||||
$target = Join-Path $work "coa-schema-fixture-chaos-$name"
|
||||
$arguments = @('-NoProfile','-File', ('"' + (Join-Path $PSScriptRoot 'update-chaos-gate.ps1') + '"'), '-SkipBuild', '-BasePackage', ('"' + $base + '"'), '-CandidatePackage', ('"' + $candidate + '"'), '-Target', ('"' + $target + '"'), '-Mode', $job.mode, '-ReportFile', ('"' + $report + '"'))
|
||||
if ($job.previous) { $arguments += @('-PreviousPackage', ('"' + $job.previous + '"')) }
|
||||
if ($data) { $arguments += @('-DataSource', ('"' + $data + '"')) }
|
||||
$process = Start-Process -FilePath (Get-Process -Id $PID).Path -ArgumentList $arguments -WindowStyle Hidden -PassThru -RedirectStandardOutput (Join-Path $work "$name.log") -RedirectStandardError (Join-Path $work "$name.errors.log")
|
||||
$active.Add(@{ process=$process; name=$name; report=$report })
|
||||
Write-Output "Started isolated $name acceptance"
|
||||
}
|
||||
foreach ($job in @($active.ToArray())) {
|
||||
$job.process.Refresh()
|
||||
if (-not $job.process.HasExited) { continue }
|
||||
$job.process.WaitForExit()
|
||||
if ($job.process.ExitCode -ne 0 -or -not (Test-Path -LiteralPath $job.report)) {
|
||||
throw "Acceptance $($job.name) failed. Logs and marked copies are preserved at $work."
|
||||
}
|
||||
$completed.Add((Get-Content -LiteralPath $job.report -Raw | ConvertFrom-Json))
|
||||
$active.Remove($job) | Out-Null
|
||||
Write-Output "Passed isolated $($job.name) acceptance"
|
||||
}
|
||||
if ($active.Count) { Start-Sleep -Seconds 1 }
|
||||
}
|
||||
} catch {
|
||||
# Do not kill recovery processes or remove their copies. Each active fixture completes
|
||||
# independently; the parent fails publication immediately.
|
||||
throw
|
||||
}
|
||||
$manifestHash = (Get-FileHash (Join-Path $candidate 'manifest.json')).Hash.ToLower()
|
||||
$manifest = Get-Content (Join-Path $candidate 'manifest.json') -Raw | ConvertFrom-Json
|
||||
foreach ($result in $completed) {
|
||||
if ($result.result -ne 'passed' -or $result.manifestSha256 -ne $manifestHash -or $result.version -ne $manifest.version -or $result.managerSource -ne $completed[0].managerSource) { throw 'Acceptance results refer to different source or package bytes.' }
|
||||
}
|
||||
$expected = if ($previous) { 10 } else { 5 }
|
||||
if ($completed.Count -ne $expected) { throw 'Incomplete update acceptance matrix.' }
|
||||
$requiredCoverage = @('signed-package-corruption','locked-file','occupied-port','python-startup-failure','partial-ddl-invalid-sql','update-process-crash','recovery-process-crash','modified-config-preservation','running-state-recovery','player-data-preservation','disk-exhaustion','write-denial','corrupt-journal','corrupt-recovery-point','database-process-crash','new-server-crash','network-action-containment','all-file-operation-phases')
|
||||
$missingCoverage = @($requiredCoverage | Where-Object {
|
||||
$required = $_
|
||||
@($completed | Where-Object { $required -notin $_.coverage }).Count -gt 0
|
||||
})
|
||||
$combined = @{ schema=1; result=$(if ($missingCoverage.Count) { 'incomplete' } else { 'passed' }); version=$manifest.version; manifestSha256=$manifestHash; manager=$completed[0].manager; managerSource=$completed[0].managerSource; scenarios=$completed.ToArray(); missingCoverage=$missingCoverage }
|
||||
$combined | ConvertTo-Json -Depth 10 | Set-Content (Join-Path $candidate 'acceptance.json') -Encoding utf8NoBOM
|
||||
if ($missingCoverage.Count) { throw "Publication is blocked: release fault coverage is incomplete ($($missingCoverage -join ', ')). Scenario results were preserved." }
|
||||
Write-Output "Passed all $expected update acceptance scenarios"
|
||||
Reference in new issue
Block a user