add integration test for reset-partition-only

This requires some tweaks to make the test machinery accept an
autoinstall that doesn't do most of the things we usually expect.  Also
set the .target attribute to None when reset-partition-only is true to
catch more issues in the dry-run environment.
This commit is contained in:
Michael Hudson-Doyle 2023-06-28 12:21:09 +12:00
parent 94172698f5
commit 283e07a615
4 changed files with 46 additions and 9 deletions

View File

@ -0,0 +1,11 @@
version: 1
identity:
realname: ''
username: ubuntu
password: '$6$wdAcoXrU039hKYPd$508Qvbe7ObUnxoj15DRCkzC3qO7edjH0VV7BPNRDYK4QR8ofJaEEF2heacn0QgD.f8pO8SNp83XNdWG6tocBM1'
hostname: ubuntu
storage:
layout:
name: direct
reset-partition: yes
reset-partition-only: yes

View File

@ -31,16 +31,25 @@ validate () {
cfgs+=("$cfg") cfgs+=("$cfg")
fi fi
done done
python3 scripts/validate-yaml.py "${cfgs[@]}"
if [ ! -e $tmpdir/subiquity-client-debug.log ] || [ ! -e $tmpdir/subiquity-server-debug.log ]; then
echo "log file not created"
exit 1
fi
python3 scripts/validate-autoinstall-user-data.py < $tmpdir/var/log/installer/autoinstall-user-data
if grep passw0rd $tmpdir/subiquity-client-debug.log $tmpdir/subiquity-server-debug.log | grep -v "Loaded answers" | grep -v "answers_action"; then if grep passw0rd $tmpdir/subiquity-client-debug.log $tmpdir/subiquity-server-debug.log | grep -v "Loaded answers" | grep -v "answers_action"; then
echo "password leaked into log file" echo "password leaked into log file"
exit 1 exit 1
fi fi
opt=
[ $# -gt 1 ] && opt="$2"
if [ $opt = reset-only ]; then
python3 scripts/validate-yaml.py --no-root-mount "${cfgs[@]}"
else
python3 scripts/validate-yaml.py "${cfgs[@]}"
fi
if [ ! -e $tmpdir/subiquity-client-debug.log ] || [ ! -e $tmpdir/subiquity-server-debug.log ]; then
echo "log file not created"
exit 1
fi
if [ $opt = reset-only ]; then
return
fi
python3 scripts/validate-autoinstall-user-data.py < $tmpdir/var/log/installer/autoinstall-user-data
netplan generate --root $tmpdir netplan generate --root $tmpdir
elif [ "${mode}" = "system_setup" ]; then elif [ "${mode}" = "system_setup" ]; then
setup_mode="$2" setup_mode="$2"
@ -254,6 +263,17 @@ 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/simple.json \
--autoinstall examples/autoinstall-reset-only.yaml \
--kernel-cmdline autoinstall \
--source-catalog examples/install-sources.yaml
validate install reset-only
# The OOBE doesn't exist in WSL < 20.04 # The OOBE doesn't exist in WSL < 20.04
if [ "${RELEASE%.*}" -ge 20 ]; then if [ "${RELEASE%.*}" -ge 20 ]; then
# Test TCP connectivity (system_setup only) # Test TCP connectivity (system_setup only)

View File

@ -75,11 +75,15 @@ class StorageChecker:
assert '/' in self.path_to_mount assert '/' in self.path_to_mount
def main(): def main():
storage_checker = StorageChecker() storage_checker = StorageChecker()
final_checks = True
if sys.argv[1:2] == ['--no-root-mount']:
final_checks = False
sys.argv.pop(1)
actions = [] actions = []
for path in sys.argv[1:]: for path in sys.argv[1:]:
config = yaml.safe_load(open(path)) config = yaml.safe_load(open(path))
@ -92,6 +96,7 @@ def main():
print('checking {} failed'.format(action)) print('checking {} failed'.format(action))
raise raise
if final_checks:
storage_checker.final_checks() storage_checker.final_checks()

View File

@ -576,6 +576,7 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
if reset_partition_only: if reset_partition_only:
for mount in self.model._all(type='mount'): for mount in self.model._all(type='mount'):
self.delete_mount(mount) self.delete_mount(mount)
self.model.target = self.app.base_model.target = None
return return
if choice.capability.is_lvm(): if choice.capability.is_lvm():