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"'
|
||||
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
|
||||
LANG=C.UTF-8 timeout --foreground 60 \
|
||||
python3 -m subiquity.cmd.tui \
|
||||
|
|
|
@ -1145,12 +1145,13 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
|
|||
if name == 'hybrid':
|
||||
# this check is conceptually unnecessary but results in a
|
||||
# much cleaner error message...
|
||||
core_boot_caps = set()
|
||||
for variation in self._variation_info.values():
|
||||
if not variation.is_valid():
|
||||
continue
|
||||
if variation.is_core_boot_classic():
|
||||
break
|
||||
else:
|
||||
core_boot_caps.update(variation.capability_info.allowed)
|
||||
if not core_boot_caps:
|
||||
raise Exception(
|
||||
"can only use name: hybrid when installing core boot "
|
||||
"classic")
|
||||
|
@ -1160,15 +1161,15 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
|
|||
encrypted = layout.get('encrypted', None)
|
||||
GC = GuidedCapability
|
||||
if encrypted is None:
|
||||
if GC.CORE_BOOT_ENCRYPTED in self._info.capabilities or \
|
||||
GC.CORE_BOOT_PREFER_ENCRYPTED in self._info.capabilities:
|
||||
if GC.CORE_BOOT_ENCRYPTED in core_boot_caps or \
|
||||
GC.CORE_BOOT_PREFER_ENCRYPTED in core_boot_caps:
|
||||
capability = GC.CORE_BOOT_ENCRYPTED
|
||||
else:
|
||||
capability = GC.CORE_BOOT_UNENCRYPTED
|
||||
elif encrypted:
|
||||
capability = GC.CORE_BOOT_ENCRYPTED
|
||||
else:
|
||||
if self._info.capabilities == {
|
||||
if core_boot_caps == {
|
||||
GuidedCapability.CORE_BOOT_ENCRYPTED} and \
|
||||
not encrypted:
|
||||
raise Exception("cannot install this model unencrypted")
|
||||
|
|
|
@ -1226,6 +1226,35 @@ class TestCoreBootInstallMethods(IsolatedAsyncioTestCase):
|
|||
self.assertEqual(request.action, snapdapi.SystemAction.INSTALL)
|
||||
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):
|
||||
self.fsc.model = model = make_model(Bootloader.UEFI)
|
||||
make_disk(model)
|
||||
|
|
Loading…
Reference in New Issue