fix autoinstalling core boot classic and add integration and unit tests
This commit is contained in:
parent
5a4686fd01
commit
f08830cd71
|
@ -0,0 +1,10 @@
|
||||||
|
version: 1
|
||||||
|
source:
|
||||||
|
id: src-mandatory
|
||||||
|
storage:
|
||||||
|
layout:
|
||||||
|
name: hybrid
|
||||||
|
identity:
|
||||||
|
hostname: ai-test
|
||||||
|
password: "$y$j9T$UdY22v4Kexn/AZcIzBSUc0$2DnuvWDSwoDCFPlbk1ghZeT2qFrEBKY1bpFQoexHdw7"
|
||||||
|
username: ubuntu
|
|
@ -267,6 +267,19 @@ python3 scripts/check-yaml-fields.py "$tmpdir"/var/log/installer/autoinstall-use
|
||||||
'autoinstall.source.id="ubuntu-server-minimal"'
|
'autoinstall.source.id="ubuntu-server-minimal"'
|
||||||
grep -q 'finish: subiquity/Install/install/postinstall/run_unattended_upgrades: SUCCESS: downloading and installing security updates' $tmpdir/subiquity-server-debug.log
|
grep -q 'finish: subiquity/Install/install/postinstall/run_unattended_upgrades: SUCCESS: downloading and installing security updates' $tmpdir/subiquity-server-debug.log
|
||||||
|
|
||||||
|
clean
|
||||||
|
LANG=C.UTF-8 timeout --foreground 60 \
|
||||||
|
python3 -m subiquity.cmd.tui \
|
||||||
|
--dry-run \
|
||||||
|
--output-base "$tmpdir" \
|
||||||
|
--machine-config examples/machines/simple.json \
|
||||||
|
--autoinstall examples/autoinstall/hybrid.yaml \
|
||||||
|
--dry-run-config examples/dry-run-configs/tpm.yaml \
|
||||||
|
--bootloader uefi \
|
||||||
|
--kernel-cmdline autoinstall \
|
||||||
|
--source-catalog examples/sources/tpm.yaml
|
||||||
|
validate
|
||||||
|
|
||||||
clean
|
clean
|
||||||
LANG=C.UTF-8 timeout --foreground 60 \
|
LANG=C.UTF-8 timeout --foreground 60 \
|
||||||
python3 -m subiquity.cmd.tui \
|
python3 -m subiquity.cmd.tui \
|
||||||
|
|
|
@ -1145,12 +1145,13 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
|
||||||
if name == 'hybrid':
|
if name == 'hybrid':
|
||||||
# this check is conceptually unnecessary but results in a
|
# this check is conceptually unnecessary but results in a
|
||||||
# much cleaner error message...
|
# much cleaner error message...
|
||||||
|
core_boot_caps = set()
|
||||||
for variation in self._variation_info.values():
|
for variation in self._variation_info.values():
|
||||||
if not variation.is_valid():
|
if not variation.is_valid():
|
||||||
continue
|
continue
|
||||||
if variation.is_core_boot_classic():
|
if variation.is_core_boot_classic():
|
||||||
break
|
core_boot_caps.update(variation.capability_info.allowed)
|
||||||
else:
|
if not core_boot_caps:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
"can only use name: hybrid when installing core boot "
|
"can only use name: hybrid when installing core boot "
|
||||||
"classic")
|
"classic")
|
||||||
|
@ -1160,15 +1161,15 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
|
||||||
encrypted = layout.get('encrypted', None)
|
encrypted = layout.get('encrypted', None)
|
||||||
GC = GuidedCapability
|
GC = GuidedCapability
|
||||||
if encrypted is None:
|
if encrypted is None:
|
||||||
if GC.CORE_BOOT_ENCRYPTED in self._info.capabilities or \
|
if GC.CORE_BOOT_ENCRYPTED in core_boot_caps or \
|
||||||
GC.CORE_BOOT_PREFER_ENCRYPTED in self._info.capabilities:
|
GC.CORE_BOOT_PREFER_ENCRYPTED in core_boot_caps:
|
||||||
capability = GC.CORE_BOOT_ENCRYPTED
|
capability = GC.CORE_BOOT_ENCRYPTED
|
||||||
else:
|
else:
|
||||||
capability = GC.CORE_BOOT_UNENCRYPTED
|
capability = GC.CORE_BOOT_UNENCRYPTED
|
||||||
elif encrypted:
|
elif encrypted:
|
||||||
capability = GC.CORE_BOOT_ENCRYPTED
|
capability = GC.CORE_BOOT_ENCRYPTED
|
||||||
else:
|
else:
|
||||||
if self._info.capabilities == {
|
if core_boot_caps == {
|
||||||
GuidedCapability.CORE_BOOT_ENCRYPTED} and \
|
GuidedCapability.CORE_BOOT_ENCRYPTED} and \
|
||||||
not encrypted:
|
not encrypted:
|
||||||
raise Exception("cannot install this model unencrypted")
|
raise Exception("cannot install this model unencrypted")
|
||||||
|
|
|
@ -1226,6 +1226,35 @@ class TestCoreBootInstallMethods(IsolatedAsyncioTestCase):
|
||||||
self.assertEqual(request.action, snapdapi.SystemAction.INSTALL)
|
self.assertEqual(request.action, snapdapi.SystemAction.INSTALL)
|
||||||
self.assertEqual(request.step, snapdapi.SystemActionStep.FINISH)
|
self.assertEqual(request.step, snapdapi.SystemActionStep.FINISH)
|
||||||
|
|
||||||
|
async def test_from_sample_data_autoinstall(self):
|
||||||
|
# calling this a unit test is definitely questionable. but it
|
||||||
|
# runs much more quickly than the integration test!
|
||||||
|
self.fsc.model = model = make_model(Bootloader.UEFI)
|
||||||
|
disk = make_disk(model)
|
||||||
|
self.app.base_model.source.current.variations = {
|
||||||
|
'default': CatalogEntryVariation(
|
||||||
|
path='', size=1, snapd_system_label='prefer-encrypted'),
|
||||||
|
}
|
||||||
|
|
||||||
|
self.app.dr_cfg.systems_dir_exists = True
|
||||||
|
|
||||||
|
await self.fsc._examine_systems_task.start()
|
||||||
|
await self.fsc._examine_systems_task.wait()
|
||||||
|
self.fsc.start()
|
||||||
|
|
||||||
|
await self.fsc.run_autoinstall_guided({'name': 'hybrid'})
|
||||||
|
|
||||||
|
self.assertEqual(model.storage_version, 2)
|
||||||
|
|
||||||
|
partition_count = len([
|
||||||
|
structure
|
||||||
|
for structure in self.fsc._info.system.volumes['pc'].structure
|
||||||
|
if structure.role != snapdapi.Role.MBR
|
||||||
|
])
|
||||||
|
self.assertEqual(
|
||||||
|
partition_count,
|
||||||
|
len(disk.partitions()))
|
||||||
|
|
||||||
async def test_from_sample_data_defective(self):
|
async def test_from_sample_data_defective(self):
|
||||||
self.fsc.model = model = make_model(Bootloader.UEFI)
|
self.fsc.model = model = make_model(Bootloader.UEFI)
|
||||||
make_disk(model)
|
make_disk(model)
|
||||||
|
|
Loading…
Reference in New Issue