tidy up examples/ directory

Move machine configs, sources, autoinstall files and dry-run configs
into their own subdirectories.
This commit is contained in:
Michael Hudson-Doyle 2023-07-11 12:18:38 +12:00
parent 95e520ddf8
commit 6b35e5e4a1
59 changed files with 127 additions and 113 deletions

View File

@ -6,8 +6,8 @@ PYTHONSRC=$(NAME)
PYTHONPATH=$(shell pwd):$(shell pwd)/probert:$(shell pwd)/curtin PYTHONPATH=$(shell pwd):$(shell pwd)/probert:$(shell pwd)/curtin
PROBERTDIR=./probert PROBERTDIR=./probert
PROBERT_REPO=https://github.com/canonical/probert PROBERT_REPO=https://github.com/canonical/probert
DRYRUN?=--dry-run --bootloader uefi --machine-config examples/simple.json \ DRYRUN?=--dry-run --bootloader uefi --machine-config examples/machines/simple.json \
--source-catalog examples/install-sources.yaml \ --source-catalog examples/sources/install-sources.yaml \
--postinst-hooks-dir examples/postinst.d/ --postinst-hooks-dir examples/postinst.d/
SYSTEM_SETUP_DRYRUN?=--dry-run SYSTEM_SETUP_DRYRUN?=--dry-run
export PYTHONPATH export PYTHONPATH

View File

@ -42,10 +42,10 @@ backend configuration files to /tmp/subiquity-config-\* but it won't attempt to
run any installer commands (which would fail without root privileges). Further, run any installer commands (which would fail without root privileges). Further,
subiquity can load other machine profiles in case you want to test out the subiquity can load other machine profiles in case you want to test out the
installer without having access to the machine. A few sample machine installer without having access to the machine. A few sample machine
profiles are available in the repository at ./examples/ and profiles are available in the repository at ./examples/machines and
can be loaded via the MACHINE make variable: can be loaded via the MACHINE make variable:
`make dryrun MACHINE=examples/simple.json` `make dryrun MACHINE=examples/machines/simple.json`
# Generating machine profiles # Generating machine profiles
Machine profiles are generated from the probert tool. To collect a machine profile: Machine profiles are generated from the probert tool. To collect a machine profile:

View File

@ -1,4 +1,4 @@
#machine-config: examples/imsm.json #machine-config: examples/machines/imsm.json
Source: Source:
source: ubuntu-server source: ubuntu-server
Welcome: Welcome:

View File

@ -1,4 +1,4 @@
#machine-config: examples/existing-partitions.json #machine-config: examples/machines/existing-partitions.json
Source: Source:
source: ubuntu-server source: ubuntu-server
Welcome: Welcome:

View File

@ -1,5 +1,5 @@
#source-catalog: examples/tpm-sources.yaml #source-catalog: examples/sources/tpm-sources.yaml
#dr-config: examples/tpm-dr-config.yaml #dr-config: examples/dry-run-configs/tpm-dr-config.yaml
Source: Source:
source: src-prefer-encrypted source: src-prefer-encrypted
Serial: Serial:

View File

@ -163,16 +163,16 @@ tty=$(tty) || tty=/dev/console
export SUBIQUITY_REPLAY_TIMESCALE=100 export SUBIQUITY_REPLAY_TIMESCALE=100
for answers in examples/answers*.yaml; do for answers in examples/answers/*.yaml; do
if echo $answers|grep -vq system-setup; then if echo $answers|grep -vq system-setup; then
config=$(sed -n 's/^#machine-config: \(.*\)/\1/p' $answers || true) config=$(sed -n 's/^#machine-config: \(.*\)/\1/p' $answers || true)
catalog=$(sed -n 's/^#source-catalog: \(.*\)/\1/p' $answers || true) catalog=$(sed -n 's/^#source-catalog: \(.*\)/\1/p' $answers || true)
dr_config=$(sed -n 's/^#dr-config: \(.*\)/\1/p' "$answers" || true) dr_config=$(sed -n 's/^#dr-config: \(.*\)/\1/p' "$answers" || true)
if [ -z "$config" ]; then if [ -z "$config" ]; then
config=examples/simple.json config=examples/machines/simple.json
fi fi
if [ -z "$catalog" ]; then if [ -z "$catalog" ]; then
catalog=examples/install-sources.yaml catalog=examples/sources/install-sources.yaml
fi fi
serial=$(sed -n 's/^#serial/x/p' $answers || true) serial=$(sed -n 's/^#serial/x/p' $answers || true)
opts=() opts=()
@ -220,12 +220,12 @@ LANG=C.UTF-8 timeout --foreground 60 \
python3 -m subiquity.cmd.tui \ python3 -m subiquity.cmd.tui \
--dry-run \ --dry-run \
--output-base "$tmpdir" \ --output-base "$tmpdir" \
--machine-config examples/existing-partitions.json \ --machine-config examples/machines/existing-partitions.json \
--bootloader bios \ --bootloader bios \
--autoinstall examples/autoinstall.yaml \ --autoinstall examples/autoinstall/autoinstall.yaml \
--dry-run-config examples/dr-config-apt-local-mirror.yaml \ --dry-run-config examples/dry-run-configs/dr-config-apt-local-mirror.yaml \
--kernel-cmdline autoinstall \ --kernel-cmdline autoinstall \
--source-catalog examples/install-sources.yaml --source-catalog examples/sources/install-sources.yaml
validate validate
python3 scripts/check-yaml-fields.py $tmpdir/var/log/installer/subiquity-curtin-apt.conf \ python3 scripts/check-yaml-fields.py $tmpdir/var/log/installer/subiquity-curtin-apt.conf \
apt.disable_components='[non-free, restricted]' \ apt.disable_components='[non-free, restricted]' \
@ -254,10 +254,10 @@ LANG=C.UTF-8 timeout --foreground 60 \
python3 -m subiquity.cmd.tui \ python3 -m subiquity.cmd.tui \
--dry-run \ --dry-run \
--output-base "$tmpdir" \ --output-base "$tmpdir" \
--machine-config examples/simple.json \ --machine-config examples/machines/simple.json \
--autoinstall examples/autoinstall-user-data.yaml \ --autoinstall examples/autoinstall/autoinstall-user-data.yaml \
--kernel-cmdline autoinstall \ --kernel-cmdline autoinstall \
--source-catalog examples/install-sources.yaml --source-catalog examples/sources/install-sources.yaml
validate validate
python3 scripts/check-yaml-fields.py "$tmpdir"/var/log/installer/autoinstall-user-data \ python3 scripts/check-yaml-fields.py "$tmpdir"/var/log/installer/autoinstall-user-data \
'autoinstall.source.id="ubuntu-server-minimal"' 'autoinstall.source.id="ubuntu-server-minimal"'
@ -268,10 +268,10 @@ LANG=C.UTF-8 timeout --foreground 60 \
python3 -m subiquity.cmd.tui \ python3 -m subiquity.cmd.tui \
--dry-run \ --dry-run \
--output-base "$tmpdir" \ --output-base "$tmpdir" \
--machine-config examples/simple.json \ --machine-config examples/machines/simple.json \
--autoinstall examples/autoinstall-reset-only.yaml \ --autoinstall examples/autoinstall/autoinstall-reset-only.yaml \
--kernel-cmdline autoinstall \ --kernel-cmdline autoinstall \
--source-catalog examples/install-sources.yaml --source-catalog examples/sources/install-sources.yaml
validate install reset-only validate install reset-only
# The OOBE doesn't exist in WSL < 20.04 # The OOBE doesn't exist in WSL < 20.04
@ -299,7 +299,7 @@ if [ "${RELEASE%.*}" -ge 20 ]; then
python3 -m system_setup.cmd.tui \ python3 -m system_setup.cmd.tui \
--dry-run \ --dry-run \
--output-base "$tmpdir" \ --output-base "$tmpdir" \
--autoinstall "examples/autoinstall-system-setup${mode}.yaml" --autoinstall "examples/autoinstall/autoinstall-system-setup${mode}.yaml"
validate "system_setup" "autoinstall${mode}" validate "system_setup" "autoinstall${mode}"
done done

View File

@ -121,7 +121,7 @@ class TestSourceModel(unittest.TestCase):
self.assertEqual(model.render(), {}) self.assertEqual(model.render(), {})
def test_canary(self): def test_canary(self):
with open('examples/install-sources-canary.yaml') as fp: with open('examples/sources/install-sources-canary.yaml') as fp:
model = SourceModel() model = SourceModel()
model.load_from_file(fp) model.load_from_file(fp)
self.assertEqual(2, len(model.sources)) self.assertEqual(2, len(model.sources))

View File

@ -130,11 +130,11 @@ class _CurtinCommand:
class _DryRunCurtinCommand(_CurtinCommand): class _DryRunCurtinCommand(_CurtinCommand):
stages_mapping = { stages_mapping = {
tuple(): "examples/curtin-events-initial.json", # no stage tuple(): "curtin-events-initial.json", # no stage
("partitioning",): "examples/curtin-events-partitioning.json", ("partitioning",): "curtin-events-partitioning.json",
("extract",): "examples/curtin-events-extract.json", ("extract",): "curtin-events-extract.json",
("curthooks",): "examples/curtin-events-curthooks.json", ("curthooks",): "curtin-events-curthooks.json",
("swap",): "examples/curtin-events-curthooks.json", # hack ("swap",): "curtin-events-curthooks.json", # hack
} }
def make_command(self, command, *args, config=None): def make_command(self, command, *args, config=None):
@ -161,9 +161,10 @@ class _DryRunCurtinCommand(_CurtinCommand):
] ]
if config: if config:
cmd.extend(['--config', config]) cmd.extend(['--config', config])
event_log_filename = self.stages_mapping[tuple(stages)]
cmd.extend([ cmd.extend([
"--", "--",
self.stages_mapping[tuple(stages)], f"examples/curtin-events/{event_log_filename}",
]) ])
return cmd return cmd
else: else:
@ -174,7 +175,7 @@ class _FailingDryRunCurtinCommand(_DryRunCurtinCommand):
stages_mapping = { stages_mapping = {
**_DryRunCurtinCommand.stages_mapping, **_DryRunCurtinCommand.stages_mapping,
**{("extract",): "examples/curtin-events-fail.json"} **{("extract",): "curtin-events-fail.json"}
} }

View File

@ -37,7 +37,7 @@ class TestAutoinstallLoad(SubiTestCase):
opts = Mock() opts = Mock()
opts.dry_run = True opts.dry_run = True
opts.output_base = self.tempdir opts.output_base = self.tempdir
opts.machine_config = 'examples/simple.json' opts.machine_config = 'examples/machines/simple.json'
opts.kernel_cmdline = {} opts.kernel_cmdline = {}
opts.autoinstall = None opts.autoinstall = None
self.server = SubiquityServer(opts, None) self.server = SubiquityServer(opts, None)
@ -164,7 +164,7 @@ class TestDefaultUser(SubiTestCase):
opts = Mock() opts = Mock()
opts.dry_run = True opts.dry_run = True
opts.output_base = self.tmp_dir() opts.output_base = self.tmp_dir()
opts.machine_config = 'examples/simple.json' opts.machine_config = 'examples/machines/simple.json'
server = SubiquityServer(opts, None) server = SubiquityServer(opts, None)
server.cloud = Mock() server.cloud = Mock()
server._user_has_password = Mock( server._user_has_password = Mock(

View File

@ -302,13 +302,13 @@ async def connect_server(*args, **kwargs):
class TestBitlocker(TestAPI): class TestBitlocker(TestAPI):
@timeout() @timeout()
async def test_has_bitlocker(self): async def test_has_bitlocker(self):
async with start_server('examples/win10.json') as inst: async with start_server('examples/machines/win10.json') as inst:
resp = await inst.get('/storage/has_bitlocker') resp = await inst.get('/storage/has_bitlocker')
self.assertEqual(1, len(resp)) self.assertEqual(1, len(resp))
@timeout() @timeout()
async def test_not_bitlocker(self): async def test_not_bitlocker(self):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
resp = await inst.get('/storage/has_bitlocker') resp = await inst.get('/storage/has_bitlocker')
self.assertEqual(0, len(resp)) self.assertEqual(0, len(resp))
@ -316,7 +316,7 @@ class TestBitlocker(TestAPI):
class TestFlow(TestAPI): class TestFlow(TestAPI):
@timeout(2) @timeout(2)
async def test_serverish_flow(self): async def test_serverish_flow(self):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
await inst.post('/locale', 'en_US.UTF-8') await inst.post('/locale', 'en_US.UTF-8')
keyboard = { keyboard = {
'layout': 'us', 'layout': 'us',
@ -369,7 +369,7 @@ class TestFlow(TestAPI):
@timeout() @timeout()
async def test_v2_flow(self): async def test_v2_flow(self):
async with start_server('examples/win10.json') as inst: async with start_server('examples/machines/win10.json') as inst:
disk_id = 'disk-sda' disk_id = 'disk-sda'
orig_resp = await inst.get('/storage/v2') orig_resp = await inst.get('/storage/v2')
[sda] = match(orig_resp['disks'], id=disk_id) [sda] = match(orig_resp['disks'], id=disk_id)
@ -440,7 +440,7 @@ class TestFlow(TestAPI):
class TestGuided(TestAPI): class TestGuided(TestAPI):
@timeout() @timeout()
async def test_guided_v2_reformat(self): async def test_guided_v2_reformat(self):
cfg = 'examples/win10-along-ubuntu.json' cfg = 'examples/machines/win10-along-ubuntu.json'
async with start_server(cfg) as inst: async with start_server(cfg) as inst:
resp = await inst.get('/storage/v2/guided') resp = await inst.get('/storage/v2/guided')
[reformat] = match(resp['targets'], [reformat] = match(resp['targets'],
@ -482,7 +482,7 @@ class TestGuided(TestAPI):
@timeout() @timeout()
async def test_guided_v2_resize(self): async def test_guided_v2_resize(self):
cfg = 'examples/win10-along-ubuntu.json' cfg = 'examples/machines/win10-along-ubuntu.json'
extra = ['--storage-version', '2'] extra = ['--storage-version', '2']
async with start_server(cfg, extra_args=extra) as inst: async with start_server(cfg, extra_args=extra) as inst:
orig_resp = await inst.get('/storage/v2') orig_resp = await inst.get('/storage/v2')
@ -524,7 +524,7 @@ class TestGuided(TestAPI):
@timeout() @timeout()
async def test_guided_v2_use_gap(self): async def test_guided_v2_use_gap(self):
cfg = self.machineConfig('examples/win10-along-ubuntu.json') cfg = self.machineConfig('examples/machines/win10-along-ubuntu.json')
with cfg.edit() as data: with cfg.edit() as data:
pt = data['storage']['blockdev']['/dev/sda']['partitiontable'] pt = data['storage']['blockdev']['/dev/sda']['partitiontable']
[node] = match(pt['partitions'], node='/dev/sda5') [node] = match(pt['partitions'], node='/dev/sda5')
@ -571,7 +571,7 @@ class TestGuided(TestAPI):
@timeout() @timeout()
async def test_guided_v2_resize_logical(self): async def test_guided_v2_resize_logical(self):
cfg = 'examples/threebuntu-on-msdos.json' cfg = 'examples/machines/threebuntu-on-msdos.json'
extra = ['--storage-version', '2'] extra = ['--storage-version', '2']
async with start_server(cfg, extra_args=extra) as inst: async with start_server(cfg, extra_args=extra) as inst:
resp = await inst.get('/storage/v2/guided') resp = await inst.get('/storage/v2/guided')
@ -590,7 +590,7 @@ class TestGuided(TestAPI):
class TestCore(TestAPI): class TestCore(TestAPI):
@timeout() @timeout()
async def test_basic_core_boot(self): async def test_basic_core_boot(self):
cfg = self.machineConfig('examples/simple.json') cfg = self.machineConfig('examples/machines/simple.json')
with cfg.edit() as data: with cfg.edit() as data:
attrs = data['storage']['blockdev']['/dev/sda']['attrs'] attrs = data['storage']['blockdev']['/dev/sda']['attrs']
attrs['size'] = str(25 << 30) attrs['size'] = str(25 << 30)
@ -598,8 +598,10 @@ class TestCore(TestAPI):
bootloader='uefi', bootloader='uefi',
extra_args=[ extra_args=[
'--storage-version', '2', '--storage-version', '2',
'--source-catalog', 'examples/install-sources-canary.yaml', '--source-catalog',
'--dry-run-config', 'examples/tpm-dr-config.yaml', 'examples/sources/install-sources-canary.yaml',
'--dry-run-config',
'examples/dry-run-configs/tpm-dr-config.yaml',
] ]
) )
async with start_server(cfg, **kw) as inst: async with start_server(cfg, **kw) as inst:
@ -627,7 +629,7 @@ class TestCore(TestAPI):
class TestAdd(TestAPI): class TestAdd(TestAPI):
@timeout() @timeout()
async def test_v2_add_boot_partition(self): async def test_v2_add_boot_partition(self):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
disk_id = 'disk-sda' disk_id = 'disk-sda'
resp = await inst.post('/storage/v2') resp = await inst.post('/storage/v2')
@ -678,7 +680,7 @@ class TestAdd(TestAPI):
@timeout() @timeout()
async def test_v2_deny_multiple_add_boot_partition(self): async def test_v2_deny_multiple_add_boot_partition(self):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
disk_id = 'disk-sda' disk_id = 'disk-sda'
await inst.post('/storage/v2/add_boot_partition', disk_id=disk_id) await inst.post('/storage/v2/add_boot_partition', disk_id=disk_id)
with self.assertRaises(ClientResponseError): with self.assertRaises(ClientResponseError):
@ -687,7 +689,8 @@ class TestAdd(TestAPI):
@timeout() @timeout()
async def test_v2_deny_multiple_add_boot_partition_BIOS(self): async def test_v2_deny_multiple_add_boot_partition_BIOS(self):
async with start_server('examples/simple.json', 'bios') as inst: cfg = 'examples/machines/simple.json'
async with start_server(cfg, 'bios') as inst:
disk_id = 'disk-sda' disk_id = 'disk-sda'
await inst.post('/storage/v2/add_boot_partition', disk_id=disk_id) await inst.post('/storage/v2/add_boot_partition', disk_id=disk_id)
with self.assertRaises(ClientResponseError): with self.assertRaises(ClientResponseError):
@ -697,7 +700,7 @@ class TestAdd(TestAPI):
@timeout() @timeout()
async def test_add_format_required(self): async def test_add_format_required(self):
disk_id = 'disk-sda' disk_id = 'disk-sda'
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
bad_partitions = [ bad_partitions = [
{}, {},
{'mount': '/'}, {'mount': '/'},
@ -710,7 +713,7 @@ class TestAdd(TestAPI):
@timeout() @timeout()
async def test_add_default_size_handling(self): async def test_add_default_size_handling(self):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
disk_id = 'disk-sda' disk_id = 'disk-sda'
resp = await inst.get('/storage/v2') resp = await inst.get('/storage/v2')
[sda] = match(resp['disks'], id=disk_id) [sda] = match(resp['disks'], id=disk_id)
@ -731,7 +734,8 @@ class TestAdd(TestAPI):
@timeout() @timeout()
async def test_v2_add_boot_BIOS(self): async def test_v2_add_boot_BIOS(self):
async with start_server('examples/simple.json', 'bios') as inst: cfg = 'examples/machines/simple.json'
async with start_server(cfg, 'bios') as inst:
disk_id = 'disk-sda' disk_id = 'disk-sda'
resp = await inst.post('/storage/v2/add_boot_partition', resp = await inst.post('/storage/v2/add_boot_partition',
disk_id=disk_id) disk_id=disk_id)
@ -742,7 +746,8 @@ class TestAdd(TestAPI):
@timeout() @timeout()
async def test_v2_blank_is_not_boot(self): async def test_v2_blank_is_not_boot(self):
async with start_server('examples/simple.json', 'bios') as inst: cfg = 'examples/machines/simple.json'
async with start_server(cfg, 'bios') as inst:
disk_id = 'disk-sda' disk_id = 'disk-sda'
resp = await inst.get('/storage/v2') resp = await inst.get('/storage/v2')
[sda] = match(resp['disks'], id=disk_id) [sda] = match(resp['disks'], id=disk_id)
@ -750,7 +755,8 @@ class TestAdd(TestAPI):
@timeout() @timeout()
async def test_v2_multi_disk_multi_boot(self): async def test_v2_multi_disk_multi_boot(self):
async with start_server('examples/many-nics-and-disks.json') as inst: cfg = 'examples/machines/many-nics-and-disks.json'
async with start_server(cfg) as inst:
resp = await inst.get('/storage/v2') resp = await inst.get('/storage/v2')
[d1] = match(resp['disks'], id='disk-vda') [d1] = match(resp['disks'], id='disk-vda')
[d2] = match(resp['disks'], id='disk-vdb') [d2] = match(resp['disks'], id='disk-vdb')
@ -764,7 +770,7 @@ class TestAdd(TestAPI):
class TestDelete(TestAPI): class TestDelete(TestAPI):
@timeout() @timeout()
async def test_v2_delete_without_reformat(self): async def test_v2_delete_without_reformat(self):
cfg = 'examples/win10.json' cfg = 'examples/machines/win10.json'
extra = ['--storage-version', '1'] extra = ['--storage-version', '1']
async with start_server(cfg, extra_args=extra) as inst: async with start_server(cfg, extra_args=extra) as inst:
data = { data = {
@ -776,7 +782,7 @@ class TestDelete(TestAPI):
@timeout() @timeout()
async def test_v2_delete_without_reformat_is_ok_with_sv2(self): async def test_v2_delete_without_reformat_is_ok_with_sv2(self):
cfg = 'examples/win10.json' cfg = 'examples/machines/win10.json'
extra = ['--storage-version', '2'] extra = ['--storage-version', '2']
async with start_server(cfg, extra_args=extra) as inst: async with start_server(cfg, extra_args=extra) as inst:
data = { data = {
@ -787,7 +793,7 @@ class TestDelete(TestAPI):
@timeout() @timeout()
async def test_v2_delete_with_reformat(self): async def test_v2_delete_with_reformat(self):
async with start_server('examples/win10.json') as inst: async with start_server('examples/machines/win10.json') as inst:
disk_id = 'disk-sda' disk_id = 'disk-sda'
resp = await inst.post('/storage/v2/reformat_disk', resp = await inst.post('/storage/v2/reformat_disk',
{'disk_id': disk_id}) {'disk_id': disk_id})
@ -810,7 +816,7 @@ class TestDelete(TestAPI):
@timeout() @timeout()
async def test_delete_nonexistant(self): async def test_delete_nonexistant(self):
async with start_server('examples/win10.json') as inst: async with start_server('examples/machines/win10.json') as inst:
disk_id = 'disk-sda' disk_id = 'disk-sda'
await inst.post('/storage/v2/reformat_disk', {'disk_id': disk_id}) await inst.post('/storage/v2/reformat_disk', {'disk_id': disk_id})
data = { data = {
@ -824,7 +830,7 @@ class TestDelete(TestAPI):
class TestEdit(TestAPI): class TestEdit(TestAPI):
@timeout() @timeout()
async def test_edit_no_change_size(self): async def test_edit_no_change_size(self):
async with start_server('examples/win10.json') as inst: async with start_server('examples/machines/win10.json') as inst:
disk_id = 'disk-sda' disk_id = 'disk-sda'
resp = await inst.get('/storage/v2') resp = await inst.get('/storage/v2')
@ -842,7 +848,7 @@ class TestEdit(TestAPI):
@timeout() @timeout()
async def test_edit_no_change_grub(self): async def test_edit_no_change_grub(self):
async with start_server('examples/win10.json') as inst: async with start_server('examples/machines/win10.json') as inst:
disk_id = 'disk-sda' disk_id = 'disk-sda'
data = { data = {
'disk_id': disk_id, 'disk_id': disk_id,
@ -856,7 +862,7 @@ class TestEdit(TestAPI):
@timeout() @timeout()
async def test_edit_format(self): async def test_edit_format(self):
async with start_server('examples/win10.json') as inst: async with start_server('examples/machines/win10.json') as inst:
disk_id = 'disk-sda' disk_id = 'disk-sda'
data = { data = {
'disk_id': disk_id, 'disk_id': disk_id,
@ -874,7 +880,7 @@ class TestEdit(TestAPI):
@timeout() @timeout()
async def test_edit_mount(self): async def test_edit_mount(self):
async with start_server('examples/win10.json') as inst: async with start_server('examples/machines/win10.json') as inst:
disk_id = 'disk-sda' disk_id = 'disk-sda'
data = { data = {
'disk_id': disk_id, 'disk_id': disk_id,
@ -891,7 +897,7 @@ class TestEdit(TestAPI):
@timeout() @timeout()
async def test_edit_format_and_mount(self): async def test_edit_format_and_mount(self):
async with start_server('examples/win10.json') as inst: async with start_server('examples/machines/win10.json') as inst:
disk_id = 'disk-sda' disk_id = 'disk-sda'
data = { data = {
'disk_id': disk_id, 'disk_id': disk_id,
@ -911,7 +917,7 @@ class TestEdit(TestAPI):
@timeout() @timeout()
async def test_v2_reuse(self): async def test_v2_reuse(self):
async with start_server('examples/win10.json') as inst: async with start_server('examples/machines/win10.json') as inst:
disk_id = 'disk-sda' disk_id = 'disk-sda'
resp = await inst.get('/storage/v2') resp = await inst.get('/storage/v2')
[orig_sda] = match(resp['disks'], id=disk_id) [orig_sda] = match(resp['disks'], id=disk_id)
@ -947,7 +953,7 @@ class TestEdit(TestAPI):
class TestReformat(TestAPI): class TestReformat(TestAPI):
@timeout() @timeout()
async def test_reformat_msdos(self): async def test_reformat_msdos(self):
cfg = 'examples/simple.json' cfg = 'examples/machines/simple.json'
async with start_server(cfg) as inst: async with start_server(cfg) as inst:
data = { data = {
'disk_id': 'disk-sda', 'disk_id': 'disk-sda',
@ -961,21 +967,22 @@ class TestReformat(TestAPI):
class TestPartitionTableTypes(TestAPI): class TestPartitionTableTypes(TestAPI):
@timeout() @timeout()
async def test_ptable_gpt(self): async def test_ptable_gpt(self):
async with start_server('examples/win10.json') as inst: async with start_server('examples/machines/win10.json') as inst:
resp = await inst.get('/storage/v2') resp = await inst.get('/storage/v2')
[sda] = match(resp['disks'], id='disk-sda') [sda] = match(resp['disks'], id='disk-sda')
self.assertEqual('gpt', sda['ptable']) self.assertEqual('gpt', sda['ptable'])
@timeout() @timeout()
async def test_ptable_msdos(self): async def test_ptable_msdos(self):
async with start_server('examples/many-nics-and-disks.json') as inst: cfg = 'examples/machines/many-nics-and-disks.json'
async with start_server(cfg) as inst:
resp = await inst.get('/storage/v2') resp = await inst.get('/storage/v2')
[sda] = match(resp['disks'], id='disk-sda') [sda] = match(resp['disks'], id='disk-sda')
self.assertEqual('msdos', sda['ptable']) self.assertEqual('msdos', sda['ptable'])
@timeout() @timeout()
async def test_ptable_none(self): async def test_ptable_none(self):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
resp = await inst.get('/storage/v2') resp = await inst.get('/storage/v2')
[sda] = match(resp['disks'], id='disk-sda') [sda] = match(resp['disks'], id='disk-sda')
self.assertEqual(None, sda['ptable']) self.assertEqual(None, sda['ptable'])
@ -984,7 +991,7 @@ class TestPartitionTableTypes(TestAPI):
class TestTodos(TestAPI): # server indicators of required client actions class TestTodos(TestAPI): # server indicators of required client actions
@timeout() @timeout()
async def test_todos_simple(self): async def test_todos_simple(self):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
disk_id = 'disk-sda' disk_id = 'disk-sda'
resp = await inst.post('/storage/v2/reformat_disk', resp = await inst.post('/storage/v2/reformat_disk',
{'disk_id': disk_id}) {'disk_id': disk_id})
@ -1007,7 +1014,7 @@ class TestTodos(TestAPI): # server indicators of required client actions
@timeout() @timeout()
async def test_todos_manual(self): async def test_todos_manual(self):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
disk_id = 'disk-sda' disk_id = 'disk-sda'
resp = await inst.post('/storage/v2/reformat_disk', resp = await inst.post('/storage/v2/reformat_disk',
{'disk_id': disk_id}) {'disk_id': disk_id})
@ -1035,7 +1042,7 @@ class TestTodos(TestAPI): # server indicators of required client actions
@timeout() @timeout()
async def test_todos_guided(self): async def test_todos_guided(self):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
resp = await inst.post('/storage/v2/reformat_disk', resp = await inst.post('/storage/v2/reformat_disk',
{'disk_id': 'disk-sda'}) {'disk_id': 'disk-sda'})
self.assertTrue(resp['need_root']) self.assertTrue(resp['need_root'])
@ -1056,7 +1063,7 @@ class TestTodos(TestAPI): # server indicators of required client actions
class TestInfo(TestAPI): class TestInfo(TestAPI):
@timeout() @timeout()
async def test_path(self): async def test_path(self):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
disk_id = 'disk-sda' disk_id = 'disk-sda'
resp = await inst.get('/storage/v2') resp = await inst.get('/storage/v2')
[sda] = match(resp['disks'], id=disk_id) [sda] = match(resp['disks'], id=disk_id)
@ -1064,7 +1071,7 @@ class TestInfo(TestAPI):
@timeout() @timeout()
async def test_model_and_vendor(self): async def test_model_and_vendor(self):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
disk_id = 'disk-sda' disk_id = 'disk-sda'
resp = await inst.get('/storage/v2') resp = await inst.get('/storage/v2')
[sda] = match(resp['disks'], id=disk_id) [sda] = match(resp['disks'], id=disk_id)
@ -1073,7 +1080,8 @@ class TestInfo(TestAPI):
@timeout() @timeout()
async def test_no_vendor(self): async def test_no_vendor(self):
async with start_server('examples/many-nics-and-disks.json') as inst: cfg = 'examples/machines/many-nics-and-disks.json'
async with start_server(cfg) as inst:
disk_id = 'disk-sda' disk_id = 'disk-sda'
resp = await inst.get('/storage/v2') resp = await inst.get('/storage/v2')
[sda] = match(resp['disks'], id=disk_id) [sda] = match(resp['disks'], id=disk_id)
@ -1084,7 +1092,7 @@ class TestInfo(TestAPI):
class TestFree(TestAPI): class TestFree(TestAPI):
@timeout() @timeout()
async def test_free_only(self): async def test_free_only(self):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
await inst.post('/meta/free_only', enable=True) await inst.post('/meta/free_only', enable=True)
components = await inst.get('/mirror/disable_components') components = await inst.get('/mirror/disable_components')
components.sort() components.sort()
@ -1092,7 +1100,7 @@ class TestFree(TestAPI):
@timeout() @timeout()
async def test_not_free_only(self): async def test_not_free_only(self):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
comps = ['universe', 'multiverse'] comps = ['universe', 'multiverse']
await inst.post('/mirror/disable_components', comps) await inst.post('/mirror/disable_components', comps)
await inst.post('/meta/free_only', enable=False) await inst.post('/meta/free_only', enable=False)
@ -1103,7 +1111,7 @@ class TestFree(TestAPI):
class TestOSProbe(TestAPI): class TestOSProbe(TestAPI):
@timeout() @timeout()
async def test_win10(self): async def test_win10(self):
async with start_server('examples/win10.json') as inst: async with start_server('examples/machines/win10.json') as inst:
resp = await inst.get('/storage/v2') resp = await inst.get('/storage/v2')
[sda] = match(resp['disks'], id='disk-sda') [sda] = match(resp['disks'], id='disk-sda')
[sda1] = match(sda['partitions'], number=1) [sda1] = match(sda['partitions'], number=1)
@ -1121,7 +1129,7 @@ class TestOSProbe(TestAPI):
class TestPartitionTableEditing(TestAPI): class TestPartitionTableEditing(TestAPI):
@timeout() @timeout()
async def test_use_free_space_after_existing(self): async def test_use_free_space_after_existing(self):
cfg = 'examples/ubuntu-and-free-space.json' cfg = 'examples/machines/ubuntu-and-free-space.json'
extra = ['--storage-version', '2'] extra = ['--storage-version', '2']
async with start_server(cfg, extra_args=extra) as inst: async with start_server(cfg, extra_args=extra) as inst:
# Disk has 3 existing partitions and free space. Add one to end. # Disk has 3 existing partitions and free space. Add one to end.
@ -1159,7 +1167,8 @@ class TestPartitionTableEditing(TestAPI):
@timeout() @timeout()
async def test_resize(self): async def test_resize(self):
cfg = self.machineConfig('examples/ubuntu-and-free-space.json') cfg = self.machineConfig(
'examples/machines/ubuntu-and-free-space.json')
with cfg.edit() as data: with cfg.edit() as data:
blockdev = data['storage']['blockdev'] blockdev = data['storage']['blockdev']
sizes = {k: int(v['attrs']['size']) for k, v in blockdev.items()} sizes = {k: int(v['attrs']['size']) for k, v in blockdev.items()}
@ -1221,7 +1230,7 @@ class TestPartitionTableEditing(TestAPI):
@timeout() @timeout()
async def test_est_min_size(self): async def test_est_min_size(self):
cfg = self.machineConfig('examples/win10-along-ubuntu.json') cfg = self.machineConfig('examples/machines/win10-along-ubuntu.json')
with cfg.edit() as data: with cfg.edit() as data:
fs = data['storage']['filesystem'] fs = data['storage']['filesystem']
fs['/dev/sda1']['ESTIMATED_MIN_SIZE'] = 0 fs['/dev/sda1']['ESTIMATED_MIN_SIZE'] = 0
@ -1240,7 +1249,7 @@ class TestPartitionTableEditing(TestAPI):
@timeout() @timeout()
async def test_v2_orig_config(self): async def test_v2_orig_config(self):
cfg = 'examples/win10-along-ubuntu.json' cfg = 'examples/machines/win10-along-ubuntu.json'
extra = ['--storage-version', '2'] extra = ['--storage-version', '2']
async with start_server(cfg, extra_args=extra) as inst: async with start_server(cfg, extra_args=extra) as inst:
start_resp = await inst.get('/storage/v2') start_resp = await inst.get('/storage/v2')
@ -1262,7 +1271,7 @@ class TestPartitionTableEditing(TestAPI):
class TestGap(TestAPI): class TestGap(TestAPI):
@timeout() @timeout()
async def test_blank_disk_is_one_big_gap(self): async def test_blank_disk_is_one_big_gap(self):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
resp = await inst.get('/storage/v2') resp = await inst.get('/storage/v2')
[sda] = match(resp['disks'], id='disk-sda') [sda] = match(resp['disks'], id='disk-sda')
gap = sda['partitions'][0] gap = sda['partitions'][0]
@ -1272,7 +1281,7 @@ class TestGap(TestAPI):
@timeout() @timeout()
async def test_gap_at_end(self): async def test_gap_at_end(self):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
resp = await inst.get('/storage/v2') resp = await inst.get('/storage/v2')
[sda] = resp['disks'] [sda] = resp['disks']
[gap] = match(sda['partitions'], _type='Gap') [gap] = match(sda['partitions'], _type='Gap')
@ -1295,7 +1304,7 @@ class TestGap(TestAPI):
@timeout() @timeout()
async def SKIP_test_two_gaps(self): async def SKIP_test_two_gaps(self):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
disk_id = 'disk-sda' disk_id = 'disk-sda'
resp = await inst.post('/storage/v2/add_boot_partition', resp = await inst.post('/storage/v2/add_boot_partition',
disk_id=disk_id) disk_id=disk_id)
@ -1336,7 +1345,7 @@ class TestGap(TestAPI):
class TestRegression(TestAPI): class TestRegression(TestAPI):
@timeout() @timeout()
async def test_edit_not_trigger_boot_device(self): async def test_edit_not_trigger_boot_device(self):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
disk_id = 'disk-sda' disk_id = 'disk-sda'
resp = await inst.get('/storage/v2') resp = await inst.get('/storage/v2')
[sda] = resp['disks'] [sda] = resp['disks']
@ -1364,7 +1373,7 @@ class TestRegression(TestAPI):
@timeout() @timeout()
async def test_osprober_knames(self): async def test_osprober_knames(self):
cfg = 'examples/lp-1986676-missing-osprober.json' cfg = 'examples/machines/lp-1986676-missing-osprober.json'
async with start_server(cfg) as inst: async with start_server(cfg) as inst:
resp = await inst.get('/storage/v2') resp = await inst.get('/storage/v2')
[nvme] = match(resp['disks'], id='disk-nvme0n1') [nvme] = match(resp['disks'], id='disk-nvme0n1')
@ -1384,7 +1393,8 @@ class TestRegression(TestAPI):
# The old way this worked was to use changes to the 'format' value to # The old way this worked was to use changes to the 'format' value to
# decide if a wipe was happening or not, and now the client chooses so # decide if a wipe was happening or not, and now the client chooses so
# explicitly. # explicitly.
async with start_server('examples/win10-along-ubuntu.json') as inst: cfg = 'examples/machines/win10-along-ubuntu.json'
async with start_server(cfg) as inst:
resp = await inst.get('/storage/v2') resp = await inst.get('/storage/v2')
[d1] = resp['disks'] [d1] = resp['disks']
[p5] = match(d1['partitions'], number=5) [p5] = match(d1['partitions'], number=5)
@ -1415,7 +1425,8 @@ class TestRegression(TestAPI):
@timeout() @timeout()
async def test_edit_should_leave_other_values_alone(self): async def test_edit_should_leave_other_values_alone(self):
async with start_server('examples/win10-along-ubuntu.json') as inst: cfg = 'examples/machines/win10-along-ubuntu.json'
async with start_server(cfg) as inst:
async def check_preserve(): async def check_preserve():
v1resp = await inst.get('/storage') v1resp = await inst.get('/storage')
[c_p5] = match(v1resp['config'], number=5) [c_p5] = match(v1resp['config'], number=5)
@ -1457,7 +1468,7 @@ class TestRegression(TestAPI):
@timeout() @timeout()
async def test_no_change_edit(self): async def test_no_change_edit(self):
cfg = 'examples/simple.json' cfg = 'examples/machines/simple.json'
extra = ['--storage-version', '2'] extra = ['--storage-version', '2']
async with start_server(cfg, extra_args=extra) as inst: async with start_server(cfg, extra_args=extra) as inst:
resp = await inst.get('/storage/v2') resp = await inst.get('/storage/v2')
@ -1488,7 +1499,7 @@ class TestRegression(TestAPI):
> Exception: Filesystem(fstype='swap', ...) is already mounted > Exception: Filesystem(fstype='swap', ...) is already mounted
Make sure editing the partition is ok now. Make sure editing the partition is ok now.
''' '''
cfg = 'examples/simple.json' cfg = 'examples/machines/simple.json'
extra = ['--storage-version', '2'] extra = ['--storage-version', '2']
async with start_server(cfg, extra_args=extra) as inst: async with start_server(cfg, extra_args=extra) as inst:
resp = await inst.get('/storage/v2') resp = await inst.get('/storage/v2')
@ -1518,7 +1529,7 @@ class TestRegression(TestAPI):
'''We want to offer the same list of fstypes for Subiquity and U-D-I, '''We want to offer the same list of fstypes for Subiquity and U-D-I,
but the list is different today. Verify that unformatted partitions but the list is different today. Verify that unformatted partitions
may be created.''' may be created.'''
cfg = 'examples/simple.json' cfg = 'examples/machines/simple.json'
extra = ['--storage-version', '2'] extra = ['--storage-version', '2']
async with start_server(cfg, extra_args=extra) as inst: async with start_server(cfg, extra_args=extra) as inst:
resp = await inst.get('/storage/v2') resp = await inst.get('/storage/v2')
@ -1544,7 +1555,7 @@ class TestRegression(TestAPI):
logical partition was resized to allow creation of more partitions, but logical partition was resized to allow creation of more partitions, but
the 1MiB space was not left between the newly created partition and the the 1MiB space was not left between the newly created partition and the
physically last partition.''' physically last partition.'''
cfg = 'examples/threebuntu-on-msdos.json' cfg = 'examples/machines/threebuntu-on-msdos.json'
extra = ['--storage-version', '2'] extra = ['--storage-version', '2']
async with start_server(cfg, extra_args=extra) as inst: async with start_server(cfg, extra_args=extra) as inst:
resp = await inst.get('/storage/v2/guided') resp = await inst.get('/storage/v2/guided')
@ -1579,7 +1590,7 @@ class TestRegression(TestAPI):
tries to edit the previously created partition. The edit operation tries to edit the previously created partition. The edit operation
would fail in earlier versions because the new partition would have would fail in earlier versions because the new partition would have
been discarded. ''' been discarded. '''
cfg = 'examples/simple.json' cfg = 'examples/machines/simple.json'
extra = ['--storage-version', '2'] extra = ['--storage-version', '2']
async with start_server(cfg, extra_args=extra) as inst: async with start_server(cfg, extra_args=extra) as inst:
names = ['locale', 'keyboard', 'source', 'network', 'proxy', names = ['locale', 'keyboard', 'source', 'network', 'proxy',
@ -1618,7 +1629,7 @@ class TestCancel(TestAPI):
@timeout() @timeout()
async def test_cancel_drivers(self): async def test_cancel_drivers(self):
with patch.dict(os.environ, {'SUBIQUITY_DEBUG': 'has-drivers'}): with patch.dict(os.environ, {'SUBIQUITY_DEBUG': 'has-drivers'}):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
await inst.post('/source', source_id="placeholder", await inst.post('/source', source_id="placeholder",
search_drivers=True) search_drivers=True)
# /drivers?wait=true is expected to block until APT is # /drivers?wait=true is expected to block until APT is
@ -1642,8 +1653,8 @@ class TestCancel(TestAPI):
class TestDrivers(TestAPI): class TestDrivers(TestAPI):
async def _test_source(self, source_id, expected_driver): async def _test_source(self, source_id, expected_driver):
with patch.dict(os.environ, {'SUBIQUITY_DEBUG': 'has-drivers'}): with patch.dict(os.environ, {'SUBIQUITY_DEBUG': 'has-drivers'}):
cfg = 'examples/simple.json' cfg = 'examples/machines/simple.json'
extra = ['--source-catalog', 'examples/mixed-sources.yaml'] extra = ['--source-catalog', 'examples/sources/mixed-sources.yaml']
async with start_server(cfg, extra_args=extra) as inst: async with start_server(cfg, extra_args=extra) as inst:
await inst.post('/source', source_id=source_id, await inst.post('/source', source_id=source_id,
search_drivers=True) search_drivers=True)
@ -1671,7 +1682,7 @@ class TestDrivers(TestAPI):
async def test_listing_ongoing(self): async def test_listing_ongoing(self):
''' Ensure that the list of drivers returned by /drivers is null while ''' Ensure that the list of drivers returned by /drivers is null while
the list has not been retrieved. ''' the list has not been retrieved. '''
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
resp = await inst.get('/drivers', wait=False) resp = await inst.get('/drivers', wait=False)
self.assertIsNone(resp['drivers']) self.assertIsNone(resp['drivers'])
@ -1688,14 +1699,14 @@ class TestOEM(TestAPI):
async def test_listing_ongoing(self): async def test_listing_ongoing(self):
''' Ensure that the list of OEM metapackages returned by /oem is ''' Ensure that the list of OEM metapackages returned by /oem is
null while the list has not been retrieved. ''' null while the list has not been retrieved. '''
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
resp = await inst.get('/oem', wait=False) resp = await inst.get('/oem', wait=False)
self.assertIsNone(resp['metapackages']) self.assertIsNone(resp['metapackages'])
async def test_listing_empty(self): async def test_listing_empty(self):
expected_pkgs = [] expected_pkgs = []
with patch.dict(os.environ, {'SUBIQUITY_DEBUG': 'no-drivers'}): with patch.dict(os.environ, {'SUBIQUITY_DEBUG': 'no-drivers'}):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
await inst.post('/source', source_id='ubuntu-server') await inst.post('/source', source_id='ubuntu-server')
names = ['locale', 'keyboard', 'source', 'network', 'proxy', names = ['locale', 'keyboard', 'source', 'network', 'proxy',
'mirror', 'storage'] 'mirror', 'storage']
@ -1710,8 +1721,8 @@ class TestOEM(TestAPI):
async def _test_listing_certified(self, source_id: str, async def _test_listing_certified(self, source_id: str,
expected: List[str]): expected: List[str]):
with patch.dict(os.environ, {'SUBIQUITY_DEBUG': 'has-drivers'}): with patch.dict(os.environ, {'SUBIQUITY_DEBUG': 'has-drivers'}):
args = ['--source-catalog', 'examples/mixed-sources.yaml'] args = ['--source-catalog', 'examples/sources/mixed-sources.yaml']
config = 'examples/simple.json' config = 'examples/machines/simple.json'
async with start_server(config, extra_args=args) as inst: async with start_server(config, extra_args=args) as inst:
await inst.post('/source', source_id=source_id) await inst.post('/source', source_id=source_id)
names = ['locale', 'keyboard', 'source', 'network', 'proxy', names = ['locale', 'keyboard', 'source', 'network', 'proxy',
@ -1740,7 +1751,7 @@ class TestOEM(TestAPI):
class TestSource(TestAPI): class TestSource(TestAPI):
@timeout() @timeout()
async def test_optional_search_drivers(self): async def test_optional_search_drivers(self):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
await inst.post('/source', source_id='ubuntu-server') await inst.post('/source', source_id='ubuntu-server')
resp = await inst.get('/source') resp = await inst.get('/source')
self.assertFalse(resp['search_drivers']) self.assertFalse(resp['search_drivers'])
@ -1759,7 +1770,7 @@ class TestSource(TestAPI):
class TestIdentityValidation(TestAPI): class TestIdentityValidation(TestAPI):
@timeout() @timeout()
async def test_username_validation(self): async def test_username_validation(self):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
resp = await inst.get('/identity/validate_username', resp = await inst.get('/identity/validate_username',
username='plugdev') username='plugdev')
self.assertEqual(resp, 'SYSTEM_RESERVED') self.assertEqual(resp, 'SYSTEM_RESERVED')
@ -1784,7 +1795,7 @@ class TestIdentityValidation(TestAPI):
class TestManyPrimaries(TestAPI): class TestManyPrimaries(TestAPI):
@timeout() @timeout()
async def test_create_primaries(self): async def test_create_primaries(self):
cfg = 'examples/simple.json' cfg = 'examples/machines/simple.json'
extra = ['--storage-version', '2'] extra = ['--storage-version', '2']
async with start_server(cfg, extra_args=extra) as inst: async with start_server(cfg, extra_args=extra) as inst:
resp = await inst.get('/storage/v2') resp = await inst.get('/storage/v2')
@ -1824,7 +1835,7 @@ class TestManyPrimaries(TestAPI):
class TestKeyboard(TestAPI): class TestKeyboard(TestAPI):
@timeout() @timeout()
async def test_input_source(self): async def test_input_source(self):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
data = {'layout': 'fr', 'variant': 'latin9'} data = {'layout': 'fr', 'variant': 'latin9'}
await inst.post('/keyboard/input_source', data, user='foo') await inst.post('/keyboard/input_source', data, user='foo')
@ -1832,7 +1843,7 @@ class TestKeyboard(TestAPI):
class TestUbuntuProContractSelection(TestAPI): class TestUbuntuProContractSelection(TestAPI):
@timeout() @timeout()
async def test_upcs_flow(self): async def test_upcs_flow(self):
async with start_server('examples/simple.json') as inst: async with start_server('examples/machines/simple.json') as inst:
# Wait should fail if no initiate first. # Wait should fail if no initiate first.
with self.assertRaises(Exception): with self.assertRaises(Exception):
await inst.get('/ubuntu_pro/contract_selection/wait') await inst.get('/ubuntu_pro/contract_selection/wait')
@ -1860,10 +1871,10 @@ class TestUbuntuProContractSelection(TestAPI):
class TestAutoinstallServer(TestAPI): class TestAutoinstallServer(TestAPI):
@timeout(2) @timeout(2)
async def test_make_view_requests(self): async def test_make_view_requests(self):
cfg = 'examples/simple.json' cfg = 'examples/machines/simple.json'
extra = [ extra = [
'--autoinstall', 'examples/autoinstall-short.yaml', '--autoinstall', 'examples/autoinstall/autoinstall-short.yaml',
'--source-catalog', 'examples/install-sources.yaml', '--source-catalog', 'examples/sources/install-sources.yaml',
] ]
async with start_server(cfg, extra_args=extra, async with start_server(cfg, extra_args=extra,
set_first_source=False) as inst: set_first_source=False) as inst:
@ -1889,7 +1900,7 @@ class TestAutoinstallServer(TestAPI):
@timeout() @timeout()
async def test_interactive(self): async def test_interactive(self):
cfg = 'examples/simple.json' cfg = 'examples/machines/simple.json'
with tempfile.NamedTemporaryFile(mode='w') as tf: with tempfile.NamedTemporaryFile(mode='w') as tf:
tf.write(''' tf.write('''
version: 1 version: 1
@ -1911,7 +1922,8 @@ class TestAutoinstallServer(TestAPI):
class TestWSLSetupOptions(TestAPI): class TestWSLSetupOptions(TestAPI):
@timeout() @timeout()
async def test_wslsetupoptions(self): async def test_wslsetupoptions(self):
async with start_system_setup_server('examples/simple.json') as inst: cfg = 'examples/machines/simple.json'
async with start_system_setup_server(cfg) as inst:
await inst.post('/meta/client_variant', variant='wsl_setup') await inst.post('/meta/client_variant', variant='wsl_setup')
payload = {'install_language_support_packages': False} payload = {'install_language_support_packages': False}
@ -1929,7 +1941,8 @@ class TestActiveDirectory(TestAPI):
async def test_ad(self): async def test_ad(self):
# Few tests to assert that the controller is properly wired. # Few tests to assert that the controller is properly wired.
# Exhaustive validation test cases are in the unit tests. # Exhaustive validation test cases are in the unit tests.
async with start_server('examples/simple.json') as instance: cfg = 'examples/machines/simple.json'
async with start_server(cfg) as instance:
endpoint = '/active_directory' endpoint = '/active_directory'
ad_dict = await instance.get(endpoint) ad_dict = await instance.get(endpoint)
# Starts with the detected domain. # Starts with the detected domain.
@ -2024,10 +2037,10 @@ class TestActiveDirectory(TestAPI):
@timeout() @timeout()
async def test_ad_autoinstall(self): async def test_ad_autoinstall(self):
cfg = 'examples/simple.json' cfg = 'examples/machines/simple.json'
extra = [ extra = [
'--autoinstall', 'examples/autoinstall-ad.yaml', '--autoinstall', 'examples/autoinstall/autoinstall-ad.yaml',
'--source-catalog', 'examples/mixed-sources.yaml', '--source-catalog', 'examples/sources/mixed-sources.yaml',
'--kernel-cmdline', 'autoinstall', '--kernel-cmdline', 'autoinstall',
] ]
try: try:

View File

@ -20,7 +20,7 @@ from subiquitycore.prober import Prober
class TestProber(SubiTestCase): class TestProber(SubiTestCase):
async def test_none_and_defaults_equal(self): async def test_none_and_defaults_equal(self):
with open('examples/simple.json', 'r') as fp: with open('examples/machines/simple.json', 'r') as fp:
prober = Prober(machine_config=fp, debug_flags=()) prober = Prober(machine_config=fp, debug_flags=())
none_storage = await prober.get_storage(probe_types=None) none_storage = await prober.get_storage(probe_types=None)
defaults_storage = await prober.get_storage(probe_types={'defaults'}) defaults_storage = await prober.get_storage(probe_types={'defaults'})