test(g1/shutdown): exercise real hung region timeout with CI-only injected stall
This commit is contained in:
1 parent
c21dfe044b
commit
b1ec08df95
3 files changed
+69
-11
No files matched your search
@@ -18,6 +18,7 @@ on:
|
||||
- 'doc/NexVerse/KEYFRAME_LEGACY_MIGRATION.md'
|
||||
- 'tools/ci/verify_net10_shutdown.py'
|
||||
- 'tools/ci/smoke_g1_multi_region_shutdown.py'
|
||||
- 'tools/ci/inject_shutdown_hang_ci_only.py'
|
||||
- 'tools/ci/verify_avatar_evacuation.py'
|
||||
- '.github/workflows/ogl-net10-shutdown.yml'
|
||||
workflow_dispatch:
|
||||
@@ -64,3 +65,11 @@ jobs:
|
||||
dotnet run --project tools/ci/Net10ShutdownRegression/Net10ShutdownRegression.csproj -c Release -- /tmp/ogl-keyframe-ci.ogkf
|
||||
- name: Stop a real multi-region .NET 10 simulator using its console
|
||||
run: python3 tools/ci/smoke_g1_multi_region_shutdown.py --regions 12
|
||||
- name: Inject test-only blocked region close in CI checkout
|
||||
env:
|
||||
OGL_CI_INJECT_HANG: '1'
|
||||
run: python3 tools/ci/inject_shutdown_hang_ci_only.py
|
||||
- name: Rebuild the throwaway fault-injected simulator
|
||||
run: dotnet build OpenSim.sln -c Release
|
||||
- name: Verify timeout continues other regions and exits nonzero
|
||||
run: python3 tools/ci/smoke_g1_multi_region_shutdown.py --regions 3 --expect-timeout
|
||||
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python3
|
||||
"""CI-only: inject a deliberately blocked Scene.Close() for shutdown fault testing.
|
||||
|
||||
This rewrites the *ephemeral GitHub Actions checkout only*, AFTER normal smoke.
|
||||
Do not run on a live host. Production source and PR diff contain no hang.
|
||||
"""
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
if os.environ.get("GITHUB_ACTIONS") != "true" or os.environ.get("OGL_CI_INJECT_HANG") != "1":
|
||||
raise SystemExit("Refusing fault injection outside explicit GitHub Actions CI environment")
|
||||
|
||||
source = (Path(__file__).resolve().parents[2] /
|
||||
"OpenSim/Region/Framework/Scenes/Scene.cs")
|
||||
before = source.read_text()
|
||||
target = """ public override void Close()
|
||||
{
|
||||
if (Interlocked.Exchange(ref m_oglCloseStarted, 1) != 0)"""
|
||||
injected = """ public override void Close()
|
||||
{
|
||||
// TEMPORARY CI FAULT INJECTION: not committed to simulator code.
|
||||
if (Name == "OGL Shutdown CI 2")
|
||||
{
|
||||
m_log.Warn("[OGL SHUTDOWN CI]: Deliberately blocking region 2 close");
|
||||
System.Threading.Thread.Sleep(20000);
|
||||
}
|
||||
if (Interlocked.Exchange(ref m_oglCloseStarted, 1) != 0)"""
|
||||
if before.count(target) != 1:
|
||||
raise SystemExit("Scene.Close method signature changed; abort fault injection")
|
||||
source.write_text(before.replace(target, injected))
|
||||
print("PASS: inserted test-only 20-second blocking close for OGL Shutdown CI 2")
|
||||
@@ -24,7 +24,7 @@ COMMON_TEMPLATE = ROOT / "tools/ci/NexLoginPlacement/StandaloneCommon.ini"
|
||||
INI_TEMPLATE = BIN / "OpenSim.NexVerseLoginPlacement.Tests.ini"
|
||||
REGION_TEMPLATE = ROOT / "tools/ci/NexLoginPlacement/Regions/NexVerse-CI.ini"
|
||||
ESTATES = ROOT / "tools/ci/NexLoginPlacement/Estates"
|
||||
def run_smoke(workdir: Path, region_count: int) -> None:
|
||||
def run_smoke(workdir: Path, region_count: int, expect_timeout: bool = False) -> None:
|
||||
names = [f"OGL Shutdown CI {n}" for n in range(1, region_count + 1)]
|
||||
orig_common = COMMON.read_bytes() if COMMON.exists() else None
|
||||
state = workdir / "state"
|
||||
@@ -48,7 +48,8 @@ def run_smoke(workdir: Path, region_count: int) -> None:
|
||||
ini = ini.replace('regionload_estatesdir = "../tools/ci/NexLoginPlacement/Estates"',
|
||||
f'regionload_estatesdir = "{ESTATES}"')
|
||||
ini = ini.replace("19100", "19210").replace("19102", "19212")
|
||||
ini += "\n[OGLShutdown]\nRegionCloseTimeoutSeconds = 30\n"
|
||||
ini += ("\n[OGLShutdown]\nRegionCloseTimeoutSeconds = "
|
||||
+ ("1" if expect_timeout else "30") + "\n")
|
||||
# OpenSim resolves includes relative to its own bin/config directory.
|
||||
config = BIN / "OpenSim.OglShutdownSmoke.Tests.ini"
|
||||
config.write_text(ini)
|
||||
@@ -107,14 +108,27 @@ def run_smoke(workdir: Path, region_count: int) -> None:
|
||||
raise AssertionError(
|
||||
"All region close callbacks may have finished, but OpenSim process did not exit"
|
||||
) from exc
|
||||
if proc.returncode != 0:
|
||||
raise AssertionError(f"Simulator exit status was {proc.returncode}")
|
||||
for name in names:
|
||||
if f"Region {name} closed in" not in logs:
|
||||
raise AssertionError("Missing clean close confirmation for " + name)
|
||||
if f"All {region_count} region close operations completed" not in logs:
|
||||
raise AssertionError("Missing complete shutdown summary")
|
||||
print(f"PASS: {region_count} real regions started, console shutdown completed, exit code 0")
|
||||
if expect_timeout:
|
||||
if proc.returncode == 0:
|
||||
raise AssertionError("Timed-out region incorrectly reported successful shutdown")
|
||||
if "[OGL SHUTDOWN]: TIMEOUT" not in logs or "OGL Shutdown CI 2" not in logs:
|
||||
raise AssertionError("Expected stuck region timeout log not found")
|
||||
if f"Region OGL Shutdown CI 1 closed in" not in logs or (
|
||||
f"Region OGL Shutdown CI 3 closed in" not in logs):
|
||||
raise AssertionError("Other regions did not finish closing after one timeout")
|
||||
if "region close operations failed or timed out" not in logs:
|
||||
raise AssertionError("Nonzero failure summary not found")
|
||||
print("PASS: injected blocked region reported timeout, other regions"
|
||||
" closed, OpenSim exited nonzero")
|
||||
else:
|
||||
if proc.returncode != 0:
|
||||
raise AssertionError(f"Simulator exit status was {proc.returncode}")
|
||||
for name in names:
|
||||
if f"Region {name} closed in" not in logs:
|
||||
raise AssertionError("Missing clean close confirmation for " + name)
|
||||
if f"All {region_count} region close operations completed" not in logs:
|
||||
raise AssertionError("Missing complete shutdown summary")
|
||||
print(f"PASS: {region_count} real regions started, console shutdown completed, exit code 0")
|
||||
except Exception:
|
||||
print("----- Shutdown simulator output (last 160 lines) -----")
|
||||
print("\n".join(logs.splitlines()[-160:]))
|
||||
@@ -139,11 +153,15 @@ def run_smoke(workdir: Path, region_count: int) -> None:
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--regions", type=int, default=3, help="number of test regions (1..42)")
|
||||
parser.add_argument("--expect-timeout", action="store_true",
|
||||
help="expect CI-injected region 2 close hang and nonzero exit")
|
||||
args = parser.parse_args()
|
||||
if args.expect_timeout and args.regions < 3:
|
||||
parser.error("--expect-timeout requires at least three regions")
|
||||
if not (1 <= args.regions <= 42):
|
||||
parser.error("--regions must be between 1 and 42")
|
||||
with tempfile.TemporaryDirectory(prefix="ogl-g1-shutdown-ci-") as path:
|
||||
run_smoke(Path(path), args.regions)
|
||||
run_smoke(Path(path), args.regions, args.expect_timeout)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user