fix integration test

This commit is contained in:
Michael Hudson-Doyle 2022-11-01 11:34:00 +01:00
parent f87b97bbdf
commit 27953f794d
4 changed files with 70 additions and 3 deletions

44
examples/answers-tpm.yaml Normal file
View File

@ -0,0 +1,44 @@
#source-catalog: examples/tpm-sources.yaml
Source:
source: src-prefer-encrypted
Serial:
rich: false
Welcome:
lang: en_US
Refresh:
update: no
Keyboard:
layout: us
Zdev:
accept-default: yes
Network:
accept-default: yes
Proxy:
proxy: ""
Mirror:
country-code: us
Filesystem:
tpm-default: yes
Identity:
realname: Ubuntu
username: ubuntu
hostname: ubuntu-server
# ubuntu
password: '$6$wdAcoXrU039hKYPd$508Qvbe7ObUnxoj15DRCkzC3qO7edjH0VV7BPNRDYK4QR8ofJaEEF2heacn0QgD.f8pO8SNp83XNdWG6tocBM1'
UbuntuPro:
token: ""
SSH:
install_server: true
pwauth: false
authorized_keys:
- |
ssh-rsa AAAAAAAAAAAAAAAAAAAAAAAAA # ssh-import-id lp:subiquity
SnapList:
snaps:
hello:
channel: stable
classic: false
InstallProgress:
reboot: yes
Drivers:
install: no

View File

@ -43,3 +43,14 @@
type: fsimage
variant: server
snapd_system_label: defective
- description:
en: This test source requires TPM backed full disk encryption.
id: src-mandatory
locale_support: none
name:
en: TPM encryption required.
path: foo.squashfs
size: 530485248
type: fsimage
variant: server
snapd_system_label: mandatory

View File

@ -106,7 +106,7 @@ validate () {
exit 1
fi
for f in $tmpdir/var/cache/apt/archives/*.log ; do
if ! [ -s $f ]; then
if ! [ -s $f ]; then
echo "apt failed for package $f"
exit 1
fi
@ -151,9 +151,13 @@ export SUBIQUITY_REPLAY_TIMESCALE=100
for answers in examples/answers*.yaml; do
if echo $answers|grep -vq system-setup; then
config=$(sed -n 's/^#machine-config: \(.*\)/\1/p' $answers || true)
catalog=$(sed -n 's/^#source-catalog: \(.*\)/\1/p' $answers || true)
if [ -z "$config" ]; then
config=examples/simple.json
fi
if [ -z "$catalog" ]; then
catalog=examples/install-sources.yaml
fi
serial=$(sed -n 's/^#serial/x/p' $answers || true)
opts=()
if [ -n "$serial" ]; then
@ -169,8 +173,12 @@ for answers in examples/answers*.yaml; do
--machine-config "$config" \
--bootloader uefi \
--snaps-from-examples \
--source-catalog examples/install-sources.yaml
validate
--source-catalog $catalog
if [ "$answers" = examples/answers-tpm.yaml ]; then
validate skip
else
validate install
fi
grep -q 'finish: subiquity/Install/install/postinstall/run_unattended_upgrades: SUCCESS: downloading and installing security updates' $tmpdir/subiquity-server-debug.log
else
# The OOBE doesn't exist in WSL < 20.04

View File

@ -55,6 +55,7 @@ class FilesystemController(SubiquityTuiController, FilesystemManipulator):
super().__init__(app)
self.model = None
self.answers.setdefault('guided', False)
self.answers.setdefault('tpm-default', False)
self.answers.setdefault('guided-index', 0)
self.answers.setdefault('manual', [])
self.current_view: Optional[BaseView] = None
@ -106,6 +107,9 @@ class FilesystemController(SubiquityTuiController, FilesystemManipulator):
while not isinstance(self.ui.body, GuidedDiskSelectionView):
await asyncio.sleep(0.1)
if self.answers['tpm-default']:
self.ui.body.done(self.ui.body.form)
await self.app.confirm_install()
if self.answers['guided']:
if 'guided-index' in self.answers:
disk = self.ui.body.form.disks[self.answers['guided-index']]