From e233dbc6dadf83376963cf261800597781ca2ec8 Mon Sep 17 00:00:00 2001 From: Richard Alpe Date: Tue, 30 Jun 2026 17:19:07 +0200 Subject: [PATCH] test: reboot at end of factory config test to restore Reboot at end of factory config test to restore test config. Signed-off-by: Richard Alpe --- test/case/system/factory_config/test.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/case/system/factory_config/test.py b/test/case/system/factory_config/test.py index 98830eb6..8d5a7ac3 100755 --- a/test/case/system/factory_config/test.py +++ b/test/case/system/factory_config/test.py @@ -21,6 +21,13 @@ def factory_hostname(tgtssh): cfg = json.loads(tgtssh.runsh(f"cat {FACTORY}").stdout) return cfg.get("ietf-system:system", {}).get("hostname") +def cleanup(env): + """Restore the rig to the clean per-test baseline for the next test.""" + print("Restoring device to clean test baseline") + target = env.attach("target", "mgmt", "netconf") + target.reboot() + if not wait_boot(target, env): + test.fail("Device did not come back while restoring baseline") with infamy.Test() as test: with test.step("Set up topology and attach to target DUT"): @@ -43,6 +50,7 @@ with infamy.Test() as test: target.reboot() if not wait_boot(target, env): test.fail("Device did not boot from factory config") + test.push_test_cleanup(lambda: cleanup(env)) with test.step("Verify device is usable and not in failure-config"): target = env.attach("target", "mgmt", test_reset=False)