Skip to content

Commit 2e707da

Browse files
committed
install: add "restore" test using 8.3 ISO
1 parent bf55e15 commit 2e707da

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
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: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ def test_install(self, request, firmware, iso_remaster, create_vms, iso_version)
130130
"83b2",
131131
#"83b2-83b2", # 8.3b2 disabled the upgrade from 8.3
132132
"821.1-83b2",
133+
"821.1-83b2-83b2",
133134
"821.1",
134135
"821.1-821.1",
135136
))
@@ -140,6 +141,7 @@ def test_install(self, request, firmware, iso_remaster, create_vms, iso_version)
140141
{
141142
1: "test_install",
142143
2: "test_upgrade",
144+
3: "test_restore",
143145
}[len(params.split("-"))]
144146
)))],
145147
param_mapping={"params": "mode", "firmware": "firmware"})
@@ -341,3 +343,102 @@ def test_upgrade(self, firmware, iso_remaster, create_vms, orig_version, iso_ver
341343
# wait_for(lambda: False, 'Wait "forever"', timeout_secs=100*60)
342344
host_vm.shutdown(force=True)
343345
raise
346+
347+
@pytest.mark.usefixtures("xcpng_chained")
348+
@pytest.mark.parametrize(("orig_version", "iso_version"), [
349+
("821.1-83b2", "83b2"),
350+
])
351+
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
352+
@pytest.mark.continuation_of(lambda firmware, params: [dict(
353+
vm="vm1",
354+
image_test=f"TestNested::test_firstboot[{firmware}-{params}]")],
355+
param_mapping={"params": "orig_version", "firmware": "firmware"})
356+
@pytest.mark.installer_iso(
357+
lambda version: {
358+
"821.1": "xcpng-8.2.1-2023",
359+
"83b2": "xcpng-8.3-beta2",
360+
}[version],
361+
param_mapping={"version": "iso_version"})
362+
@pytest.mark.answerfile(lambda firmware: {
363+
"base": "RESTORE",
364+
"backup-disk": {"text": {"uefi": "nvme0n1",
365+
"bios": "sda"}[firmware]
366+
},
367+
},
368+
param_mapping={"firmware": "firmware"})
369+
def test_restore(self, request, firmware, orig_version, iso_version, iso_remaster, create_vms):
370+
host_vm = create_vms[0]
371+
vif = host_vm.vifs()[0]
372+
mac_address = vif.param_get('MAC')
373+
logging.info("Host VM has MAC %s", mac_address)
374+
375+
host_vm.insert_cd(iso_remaster)
376+
377+
try:
378+
host_vm.start()
379+
wait_for(host_vm.is_running, "Wait for host VM running")
380+
381+
# catch host-vm IP address
382+
wait_for(lambda: pxe.arp_addresses_for(mac_address),
383+
"Wait for DHCP server to see Host VM in ARP tables",
384+
timeout_secs=10*60)
385+
ips = pxe.arp_addresses_for(mac_address)
386+
logging.info("Host VM has IPs %s", ips)
387+
assert len(ips) == 1
388+
host_vm.ip = ips[0]
389+
390+
# wait for "yum install" phase to start
391+
wait_for(lambda: host_vm.ssh(["grep",
392+
"'Restoring backup'",
393+
"/tmp/install-log"],
394+
check=False, simple_output=False,
395+
).returncode == 0,
396+
"Wait for data restoration to start",
397+
timeout_secs=40*60) # FIXME too big
398+
399+
# wait for "yum install" phase to finish
400+
wait_for(lambda: host_vm.ssh(["grep",
401+
"'Data restoration complete. About to re-install bootloader.'",
402+
"/tmp/install-log"],
403+
check=False, simple_output=False,
404+
).returncode == 0,
405+
"Wait for data restoration to complete",
406+
timeout_secs=40*60) # FIXME too big
407+
408+
# The installer will not terminate in restore mode, it
409+
# requires human interaction and does not even log it, so
410+
# wait for last known action log (tested with 8.3b2)
411+
wait_for(lambda: host_vm.ssh(["grep",
412+
"'ran .*swaplabel.*rc 0'",
413+
"/tmp/install-log"],
414+
check=False, simple_output=False,
415+
).returncode == 0,
416+
"Wait for installer to hopefully finish",
417+
timeout_secs=40*60) # FIXME too big
418+
419+
# "wait a bit to be extra sure". Yuck.
420+
time.sleep(30)
421+
422+
logging.info("Shutting down Host VM after successful restore")
423+
try:
424+
host_vm.ssh(["poweroff"])
425+
except commands.SSHCommandFailed as e:
426+
# ignore connection closed by reboot
427+
if e.returncode == 255 and "closed by remote host" in e.stdout:
428+
logging.info("sshd closed the connection")
429+
pass
430+
else:
431+
raise
432+
wait_for(host_vm.is_halted, "Wait for host VM halted")
433+
host_vm.eject_cd()
434+
435+
except Exception as e:
436+
logging.critical("caught exception %s", e)
437+
# wait_for(lambda: False, 'Wait "forever"', timeout_secs=100*60)
438+
host_vm.shutdown(force=True)
439+
raise
440+
except KeyboardInterrupt:
441+
logging.warning("keyboard interrupt")
442+
# wait_for(lambda: False, 'Wait "forever"', timeout_secs=100*60)
443+
host_vm.shutdown(force=True)
444+
raise

0 commit comments

Comments
 (0)