Skip to content

Commit c8eb926

Browse files
committed
install: add "restore" test using 8.3 ISO
1 parent 52d34ce commit c8eb926

File tree

2 files changed

+124
-3
lines changed

2 files changed

+124
-3
lines changed

data.py-dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ BASE_ANSWERFILES = dict(
131131
UPGRADE={
132132
"root": {"tag": "installation", "mode": "upgrade"},
133133
},
134+
RESTORE={
135+
"root": {"tag": "restore"},
136+
},
134137
)
135138

136139
# compatibility settings for older tests

tests/install/test.py

Lines changed: 121 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,18 @@ def test_install(self, request, firmware, iso_version, iso_remaster, create_vms)
141141
"83b2",
142142
"821.1-83b2",
143143
#"83b2-83b2", # 8.3b2 disabled the upgrade from 8.3
144+
"821.1-83b2-83b2",
144145
])
145146
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
146147
@pytest.mark.continuation_of(
147148
lambda params, firmware: [dict(vm="vm 1",
148-
test=(f"TestNested::test_upgrade[{firmware}-{params}]"
149-
if "-" in params else
150-
f"TestNested::test_install[{firmware}-{params}]"))],
149+
test=(f"TestNested::{{}}[{firmware}-{params}]".format(
150+
{
151+
1: "test_install",
152+
2: "test_upgrade",
153+
3: "test_restore",
154+
}[len(params.split("-"))]
155+
)))],
151156
param_mapping={"params": "mode", "firmware": "firmware"})
152157
def test_firstboot(self, firmware, request, create_vms, mode):
153158
host_vm = create_vms[0]
@@ -359,3 +364,116 @@ def test_upgrade(self, request, firmware, orig_version, iso_version, iso_remaste
359364
xva_name = shortened_nodeid(request.node.nodeid) + ".xva"
360365
host_vm.host.ssh(["rm -f", xva_name])
361366
host_vm.export(xva_name, "zstd", use_cache=CACHE_IMPORTED_VM)
367+
368+
@pytest.mark.usefixtures("xcpng_chained")
369+
@pytest.mark.parametrize(("orig_version", "iso_version"), [
370+
("821.1-83b2", "83b2"),
371+
])
372+
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
373+
@pytest.mark.continuation_of(
374+
lambda firmware, params: [dict(vm="vm 1",
375+
test=f"TestNested::test_firstboot[{firmware}-{params}]")],
376+
param_mapping={"params": "orig_version", "firmware": "firmware"},
377+
)
378+
@pytest.mark.answerfile(lambda firmware: {
379+
"base": "RESTORE",
380+
"backup-disk": {"text": {"uefi": "nvme0n1",
381+
"bios": "sda"}[firmware]
382+
},
383+
},
384+
param_mapping={"firmware": "firmware"})
385+
@pytest.mark.installer_iso(lambda version: {"821.1": "xcpng-8.2.1-2023",
386+
"83b2": "xcpng-8.3-beta2"}[version],
387+
param_mapping={"version": "iso_version"})
388+
def test_restore(self, request, firmware, orig_version, iso_version, iso_remaster, create_vms):
389+
host_vm = create_vms[0]
390+
vif = host_vm.vifs()[0]
391+
mac_address = vif.param_get('MAC')
392+
logging.info("Host VM has MAC %s", mac_address)
393+
394+
host_vm.insert_cd(iso_remaster)
395+
396+
try:
397+
host_vm.start()
398+
wait_for(host_vm.is_running, "Wait for host VM running")
399+
400+
# catch host-vm IP address
401+
wait_for(lambda: pxe.arp_addresses_for(mac_address),
402+
"Wait for DHCP server to see Host VM in ARP tables",
403+
timeout_secs=10*60)
404+
ips = pxe.arp_addresses_for(mac_address)
405+
logging.info("Host VM has IPs %s", ips)
406+
assert len(ips) == 1
407+
host_vm.ip = ips[0]
408+
409+
# wait for "yum install" phase to start
410+
wait_for(lambda: host_vm.ssh(["grep",
411+
"'Restoring backup'",
412+
"/tmp/install-log"],
413+
check=False, simple_output=False,
414+
).returncode == 0,
415+
"Wait for data restoration to start",
416+
timeout_secs=40*60) # FIXME too big
417+
418+
# wait for "yum install" phase to finish
419+
wait_for(lambda: host_vm.ssh(["grep",
420+
"'Data restoration complete. About to re-install bootloader.'",
421+
"/tmp/install-log"],
422+
check=False, simple_output=False,
423+
).returncode == 0,
424+
"Wait for data restoration to complete",
425+
timeout_secs=40*60) # FIXME too big
426+
427+
# wait for install to finish
428+
wait_for(lambda: host_vm.ssh(["grep",
429+
"'Installation finished. No error reported.'",
430+
"/tmp/install-log"],
431+
check=False, simple_output=False,
432+
).returncode == 0,
433+
"Wait for system restoration to succeed",
434+
timeout_secs=40*60) # FIXME too big
435+
436+
# The installer will not terminate in restore mode, it
437+
# requires human interaction and does not even log it, so
438+
# wait for last known action log (tested with 8.3b2)
439+
wait_for(lambda: host_vm.ssh(["grep",
440+
"'ran .*swaplabel.*rc 0'",
441+
"/tmp/install-log"],
442+
check=False, simple_output=False,
443+
).returncode == 0,
444+
"Wait for installer to hopefully finish",
445+
timeout_secs=30)
446+
447+
# "wait a bit to be extra sure". Yuck.
448+
time.sleep(30)
449+
450+
logging.info("Shutting down Host VM after successful restore")
451+
try:
452+
host_vm.ssh(["poweroff"])
453+
except commands.SSHCommandFailed as e:
454+
# ignore connection closed by reboot
455+
if e.returncode == 255 and "closed by remote host" in e.stdout:
456+
logging.info("sshd closed the connection")
457+
pass
458+
else:
459+
raise
460+
wait_for(host_vm.is_halted, "Wait for host VM halted")
461+
host_vm.eject_cd()
462+
463+
except Exception as e:
464+
logging.critical("caught exception %s", e)
465+
# wait_for(lambda: False, 'Wait "forever"', timeout_secs=100*60)
466+
host_vm.shutdown(force=True)
467+
raise
468+
except KeyboardInterrupt:
469+
logging.warning("keyboard interrupt")
470+
# wait_for(lambda: False, 'Wait "forever"', timeout_secs=100*60)
471+
host_vm.shutdown(force=True)
472+
raise
473+
474+
# record this state
475+
# FIXME move to fixture
476+
# FIXME where to store?
477+
xva_name = shortened_nodeid(request.node.nodeid) + ".xva"
478+
host_vm.host.ssh(["rm -f", xva_name])
479+
host_vm.export(xva_name, "zstd", use_cache=CACHE_IMPORTED_VM)

0 commit comments

Comments
 (0)