Skip to content

Commit 8079b73

Browse files
committed
Added VM tests for full-os initramfs.
1 parent 3c4e1d9 commit 8079b73

5 files changed

Lines changed: 51 additions & 14 deletions

File tree

test/vmtests/vmtests/test_min_change.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def test_min_change_efi_azl2_iso_output(
283283
close_list: List[Closeable],
284284
) -> None:
285285
azl_release = 2
286-
config_path = TEST_CONFIGS_DIR.joinpath("iso-os-vm-config.yaml")
286+
config_path = TEST_CONFIGS_DIR.joinpath("iso-bootstrap-vm.yaml")
287287
output_format = "iso"
288288

289289
run_min_change_test(
@@ -314,7 +314,7 @@ def test_min_change_efi_azl3_iso_output(
314314
close_list: List[Closeable],
315315
) -> None:
316316
azl_release = 3
317-
config_path = TEST_CONFIGS_DIR.joinpath("iso-os-vm-config.yaml")
317+
config_path = TEST_CONFIGS_DIR.joinpath("iso-bootstrap-vm.yaml")
318318
output_format = "iso"
319319

320320
run_min_change_test(
@@ -332,6 +332,23 @@ def test_min_change_efi_azl3_iso_output(
332332
close_list,
333333
)
334334

335+
config_path = TEST_CONFIGS_DIR.joinpath("iso-full-os-vm.yaml")
336+
337+
run_min_change_test(
338+
docker_client,
339+
image_customizer_container_url,
340+
core_efi_azl3,
341+
azl_release,
342+
config_path,
343+
output_format,
344+
ssh_key,
345+
test_temp_dir,
346+
test_instance_name,
347+
logs_dir,
348+
libvirt_conn,
349+
close_list,
350+
)
351+
335352

336353
@pytest.mark.skipif(platform.machine() != 'x86_64', reason="arm64 is not supported for this combination")
337354
def test_min_change_legacy_azl2_iso_output(
@@ -346,7 +363,7 @@ def test_min_change_legacy_azl2_iso_output(
346363
close_list: List[Closeable],
347364
) -> None:
348365
azl_release = 2
349-
config_path = TEST_CONFIGS_DIR.joinpath("iso-os-vm-config.yaml")
366+
config_path = TEST_CONFIGS_DIR.joinpath("iso-bootstrap-vm.yaml")
350367
output_format = "iso"
351368

352369
run_min_change_test(
@@ -378,7 +395,7 @@ def test_min_change_legacy_azl3_iso_output(
378395
close_list: List[Closeable],
379396
) -> None:
380397
azl_release = 3
381-
config_path = TEST_CONFIGS_DIR.joinpath("iso-os-vm-config.yaml")
398+
config_path = TEST_CONFIGS_DIR.joinpath("iso-bootstrap-vm.yaml")
382399
output_format = "iso"
383400

384401
run_min_change_test(

toolkit/tools/pkg/imagecustomizerlib/liveosisobuilder_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313

1414
"github.com/microsoft/azurelinux/toolkit/tools/imagecustomizerapi"
1515
"github.com/microsoft/azurelinux/toolkit/tools/internal/file"
16-
"github.com/microsoft/azurelinux/toolkit/tools/internal/logger"
1716
"github.com/microsoft/azurelinux/toolkit/tools/internal/initrdutils"
17+
"github.com/microsoft/azurelinux/toolkit/tools/internal/logger"
1818
"github.com/microsoft/azurelinux/toolkit/tools/internal/safeloopback"
1919
"github.com/microsoft/azurelinux/toolkit/tools/internal/safemount"
2020
"github.com/microsoft/azurelinux/toolkit/tools/internal/tarutils"
@@ -184,15 +184,15 @@ func VerifyFullOSContents(t *testing.T, testTempDir, artifactsPath, outputFormat
184184
return
185185
}
186186
defer isoImageLoopDevice.Close()
187-
187+
188188
isoMountDir := filepath.Join(testTempDir, "bootstrap-iso-mount")
189189
isoImageMount, err := safemount.NewMount(isoImageLoopDevice.DevicePath(), isoMountDir,
190190
"iso9660" /*fstype*/, unix.MS_RDONLY /*flags*/, "" /*data*/, true /*makeAndDelete*/)
191191
if !assert.NoError(t, err) {
192192
return
193193
}
194194
defer isoImageMount.Close()
195-
195+
196196
fullOSImagePath = filepath.Join(isoMountDir, liveOSDir, liveOSImage)
197197
}
198198

@@ -208,16 +208,16 @@ func VerifyFullOSContents(t *testing.T, testTempDir, artifactsPath, outputFormat
208208
if !assert.NoError(t, err) {
209209
return
210210
}
211-
defer squashfsMount.Close()
211+
defer squashfsMount.Close()
212212
case imagecustomizerapi.InitramfsImageTypeFullOS:
213213
fullOSImagePath := filepath.Join(artifactsPath, "boot/initrd.img")
214214
// Expand initrd to a folder
215215
err := initrdutils.CreateFolderFromInitrdImage(fullOSImagePath, fullOsDir)
216216
if !assert.NoError(t, err) {
217217
return
218218
}
219-
defer os.RemoveAll(fullOsDir)
220-
}
219+
defer os.RemoveAll(fullOsDir)
220+
}
221221

222222
// Check that each file is in the root file system.
223223
for _, additionalFile := range osConfig.AdditionalFiles {
@@ -382,7 +382,7 @@ func TestCustomizeImageLiveOSInitramfs2(t *testing.T) {
382382
if !assert.NoError(t, err) {
383383
return
384384
}
385-
385+
386386
ValidateIsoContent(t, configB, testTempDir, imagecustomizerapi.InitramfsImageTypeFullOS, outImageFilePath)
387387

388388
// - ISO {full-os} to ISO {bootstrap}, with selinux enforcing
@@ -395,7 +395,7 @@ func TestCustomizeImageLiveOSInitramfs2(t *testing.T) {
395395
return
396396
}
397397

398-
ValidateIsoContent(t, configC, testTempDir, imagecustomizerapi.InitramfsImageTypeBootstrap, outImageFilePath)
398+
ValidateIsoContent(t, configC, testTempDir, imagecustomizerapi.InitramfsImageTypeBootstrap, outImageFilePath)
399399
}
400400

401401
// Tests:

toolkit/tools/pkg/imagecustomizerlib/liveosisoutils.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ const (
3232
isoGrubCfg = "grub.cfg"
3333
isoGrubCfgPath = grubCfgDir + "/" + isoGrubCfg
3434

35-
pxeGrubCfg = "grub-pxe.cfg"
36-
3735
isoBootDir = "boot"
3836
initrdImage = "initrd.img"
3937

toolkit/tools/pkg/imagecustomizerlib/testdata/iso-os-vm-config.yaml renamed to toolkit/tools/pkg/imagecustomizerlib/testdata/iso-bootstrap-vm.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
iso:
2+
initramfsType: full-os
13
os:
24
selinux:
35
mode: disabled
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
iso:
2+
initramfsType: bootstrap
3+
os:
4+
selinux:
5+
mode: disabled
6+
kernelCommandLine:
7+
extraCommandLine:
8+
- "selinux=0"
9+
packages:
10+
install:
11+
# iso required packages
12+
- squashfs-tools
13+
- tar
14+
- device-mapper
15+
- curl
16+
17+
additionalFiles:
18+
# Enable DHCP client on all of the physical NICs.
19+
- source: files/89-ethernet.network
20+
destination: /etc/systemd/network/89-ethernet.network

0 commit comments

Comments
 (0)