add integration-style test for reusing an existing partitions

This commit is contained in:
Michael Hudson-Doyle 2020-04-14 09:40:21 +12:00
parent ce55e8320f
commit 96a6dfd010
4 changed files with 49 additions and 1 deletions

View File

@ -0,0 +1,40 @@
#machine-config: examples/existing-partitions.json
Welcome:
lang: en_US
Refresh:
update: no
Keyboard:
layout: us
Network:
accept-default: yes
Proxy:
proxy: ""
Mirror:
mirror: "http://us.archive.ubuntu.com"
Filesystem:
manual:
- obj: [disk serial serial1, part 5]
action: EDIT
data:
fstype: ext4
mount: /
- action: done
Identity:
realname: Ubuntu
username: ubuntu
hostname: ubuntu-server
# ubuntu
password: '$6$wdAcoXrU039hKYPd$508Qvbe7ObUnxoj15DRCkzC3qO7edjH0VV7BPNRDYK4QR8ofJaEEF2heacn0QgD.f8pO8SNp83XNdWG6tocBM1'
SSH:
install_server: true
pwauth: false
authorized_keys:
- |
ssh-rsa AAAAAAAAAAAAAAAAAAAAAAAAA # ssh-import-id lp:subiquity
SnapList:
snaps:
hello:
channel: stable
is_classic: false
InstallProgress:
reboot: yes

View File

@ -6,8 +6,12 @@ for answers in examples/answers*.yaml; do
rm -f .subiquity/subiquity-curtin-install.conf
rm -f .subiquity/subiquity-debug.log
rm -f .subiquity/run/subiquity/updating
config=$(sed -n 's/^#machine-config: \(.*\)/\1/p' $answers || true)
if [ -z "$config" ]; then
config=examples/simple.json
fi
# The --foreground is important to avoid subiquity getting SIGTTOU-ed.
timeout --foreground 60 sh -c "LANG=C.UTF-8 python3 -m subiquity.cmd.tui --answers $answers --dry-run --snaps-from-examples --machine-config examples/simple.json"
timeout --foreground 60 sh -c "LANG=C.UTF-8 python3 -m subiquity.cmd.tui --answers $answers --dry-run --snaps-from-examples --machine-config $config"
python3 scripts/validate-yaml.py .subiquity/subiquity-curtin-install.conf
if [ ! -e .subiquity/subiquity-debug.log ]; then
echo "log file not created"

View File

@ -18,6 +18,8 @@ class StorageChecker:
assert 'ptable' in self.actions[action['device']]
if action['flag'] in ('boot', 'bios_grub', 'prep'):
assert self.actions[action['device']]['type'] == 'disk'
if action.get('preserve', True):
assert 'number' in action
def _check_format(self, action):
assert 'volume' in action

View File

@ -260,6 +260,8 @@ class FilesystemController(SubiquityController):
if dev_spec[0] == "disk":
if dev_spec[1] == "index":
dev = self.model.all_disks()[int(dev_spec[2])]
elif dev_spec[1] == "serial":
dev = self.model._one(type='disk', serial=dev_spec[2])
elif dev_spec[0] == "raid":
if dev_spec[1] == "name":
for r in self.model.all_raids():