Skip to content

Commit

Permalink
add core integration test and fix some races
Browse files Browse the repository at this point in the history
  • Loading branch information
mwhudson committed Jul 6, 2023
1 parent cca3014 commit 8708036
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 6 deletions.
24 changes: 24 additions & 0 deletions examples/answers-core.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#source-catalog: examples/core-sources.yaml
Source:
source: ubuntu-core
Welcome:
lang: en_US
Refresh:
update: no
Keyboard:
layout: us
Zdev:
accept-default: yes
Network:
accept-default: yes
Proxy:
proxy: ""
Filesystem:
guided: yes
guided-index: 0
UbuntuPro:
token: ""
InstallProgress:
reboot: yes
Drivers:
install: yes
10 changes: 10 additions & 0 deletions examples/core-sources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- description:
en: This test source provides a "Ubuntu Core" base install
id: ubuntu-core
locale_support: none
name:
en: Ubuntu Server
path: ubuntu-core.squashfs
size: 530485248
type: fsimage
variant: core
10 changes: 7 additions & 3 deletions scripts/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ validate () {
fi
opt=
[ $# -gt 1 ] && opt="$2"
if [ $opt = reset-only ]; then
if [ "$opt" = reset-only ]; then
python3 scripts/validate-yaml.py --no-root-mount "${cfgs[@]}"
else
python3 scripts/validate-yaml.py "${cfgs[@]}"
Expand All @@ -49,7 +49,9 @@ validate () {
if [ $opt = reset-only ]; then
return
fi
python3 scripts/validate-autoinstall-user-data.py < $tmpdir/var/log/installer/autoinstall-user-data
if [ $answers != examples/answers-core.yaml ]; then
python3 scripts/validate-autoinstall-user-data.py < $tmpdir/var/log/installer/autoinstall-user-data
fi
netplan generate --root $tmpdir
elif [ "${mode}" = "system_setup" ]; then
setup_mode="$2"
Expand Down Expand Up @@ -194,7 +196,9 @@ for answers in examples/answers*.yaml; do
--snaps-from-examples \
--source-catalog $catalog
validate install
grep -q 'finish: subiquity/Install/install/postinstall/run_unattended_upgrades: SUCCESS: downloading and installing security updates' $tmpdir/subiquity-server-debug.log
if [ $answers != examples/answers-core.yaml ]; then
grep -q 'finish: subiquity/Install/install/postinstall/run_unattended_upgrades: SUCCESS: downloading and installing security updates' $tmpdir/subiquity-server-debug.log
fi
else
# The OOBE doesn't exist in WSL < 20.04
if [ "${RELEASE%.*}" -ge 20 ]; then
Expand Down
1 change: 1 addition & 0 deletions subiquity/models/oem.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(self):
self.install_on = {
"server": False,
"desktop": True,
"core": False,
}

def make_autoinstall(self) -> Dict[str, Union[str, bool]]:
Expand Down
2 changes: 1 addition & 1 deletion subiquity/models/subiquity.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ async def wait_confirmation(self):
except asyncio.CancelledError:
return False
else:
await self.hub.abroadcast(InstallerChannels.INSTALL_CONFIRMED)
return True
finally:
self._confirmation_task = None
Expand All @@ -297,7 +298,6 @@ def is_postinstall_only(self, model_name):

def confirm(self):
self._confirmation.set()
self.hub.broadcast(InstallerChannels.INSTALL_CONFIRMED)

def validate_cloudconfig_schema(self, data: dict, data_source: str):
"""Validate data config adheres to strict cloud-config schema
Expand Down
11 changes: 9 additions & 2 deletions subiquity/server/controllers/oem.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ def __init__(self, app) -> None:
self.kernel_configured_event = asyncio.Event()

def start(self) -> None:
self._wait_confirmation = asyncio.Event()
self.app.hub.subscribe(
InstallerChannels.INSTALL_CONFIRMED,
self._wait_confirmation.set)
self._wait_apt = asyncio.Event()
self.app.hub.subscribe(
InstallerChannels.APT_CONFIGURED,
Expand Down Expand Up @@ -121,8 +125,8 @@ async def wants_oem_kernel(self, pkgname: str,

@with_context()
async def load_metapackages_list(self, context) -> None:
with context.child("wait_apt"):
await self._wait_apt.wait()
with context.child("wait_confirmation"):
await self._wait_confirmation.wait()

# Only look for OEM meta-packages on supported variants and if we are
# not running core boot.
Expand All @@ -138,6 +142,9 @@ async def load_metapackages_list(self, context) -> None:
self.model.metapkgs = []
return

with context.child("wait_apt"):
await self._wait_apt.wait()

apt = self.app.controllers.Mirror.final_apt_configurer
try:
async with apt.overlay() as d:
Expand Down
3 changes: 3 additions & 0 deletions subiquity/server/controllers/shutdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ async def copy_logs_to_target(self, context):
raise PermissionError()
if self.app.controllers.Filesystem.reset_partition_only:
return
if self.app.base_model.source.current.variant == 'core':
# Possibly should copy logs somewhere else in this case?
return
target_logs = os.path.join(
self.app.base_model.target, 'var/log/installer')
if self.opts.dry_run:
Expand Down

0 comments on commit 8708036

Please sign in to comment.