Skip to content

Add Ubuntu functional tests for customize#579

Open
vinceaperri wants to merge 37 commits intomainfrom
user/vinceaperri/ubuntu-fts
Open

Add Ubuntu functional tests for customize#579
vinceaperri wants to merge 37 commits intomainfrom
user/vinceaperri/ubuntu-fts

Conversation

@vinceaperri
Copy link
Contributor

Extend the functional test suite to validate image customizer operations on Ubuntu 22.04 and 24.04 cloud images. This covers services, kernel modules, scripts, and image history customization scenarios.

  • Add CI workflow support: Ubuntu image download script and workflow integration
  • Add Ubuntu base image test infrastructure (flags, mount points, helpers)
  • Add functional tests for Ubuntu: services, kernel modules, run scripts, image history

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the functional test suite to support Ubuntu 22.04 and 24.04 cloud images as base images for the image customizer. It adds comprehensive test coverage for Ubuntu-specific customization scenarios including services management, kernel modules, script execution, and image history tracking.

Changes:

  • Added CI workflow integration for downloading and converting Ubuntu cloud images to raw format
  • Renamed Azure Linux-specific test helpers and split base image lists by distro
  • Added Ubuntu-specific test infrastructure (mount points, connection helpers, preview feature mapping)
  • Added functional tests validating Ubuntu customization for services, kernel modules, run scripts, and image history

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated no comments.

Show a summary per file
File Description
.github/workflows/scripts/download-ubuntu-image.sh New script to download Ubuntu cloud images and convert from qcow2 to raw format
.github/workflows/tests-functional.yml Updated CI workflow to download Ubuntu base images and pass them to tests
toolkit/tools/pkg/imagecustomizerlib/main_test.go Added Ubuntu base image constants, flags, and test info structures; split base image lists by distro
toolkit/tools/pkg/imagecustomizerlib/imagecustomizer_test.go Added Ubuntu mount points, connection helper, and four comprehensive Ubuntu functional tests
toolkit/tools/pkg/imagecustomizerlib/*_test.go (multiple files) Renamed connectToCoreEfiImage to connectToAzureLinuxCoreEfiImage and updated tests to use baseImageAzureLinuxAll instead of baseImageAll

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vinceaperri vinceaperri force-pushed the user/vinceaperri/ubuntu-fts branch from 802e63c to 3c3c59d Compare February 10, 2026 23:49
verifyFstabEntries(t, imageConnection, coreLegacyMountPoints, partitions)
verifyFstabEntries(t, imageConnection, azureLinuxBaremetalMountPoints, partitions)
verifyBootGrubCfg(t, imageConnection, "",
partitions[coreLegacyMountPoints[0].PartitionNum],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was coreLegacyMountPoints renamed to azureLinuxBaremetalMountPoints?

Copy link
Contributor Author

@vinceaperri vinceaperri Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To better tie it to testBaseImageAzl*BareMetal structs, where it's used, and which gets their names from baseImageAzureLinuxVariantBareMetal="bare-metal" and the params base-image-bare-metal-*. This azl variant is called core legacy in other places in the codebase, so it would be worth aligning one way or the other. I'm not partial to either name, just noticed the inconsistency in main_test.go.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are misreading the code. coreLegacyMountPoints is used for the BIOS boot partition layout, not for the bare-metal variant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the disconnect. Renaming the variable from the context of verifyLegacyBootImage does seem odd.

My previous comment was referring to the changes I've made in main_test.go, where three image variants are defined: azl core-efi, azl bare-metal, and ubuntu azure-cloud. I added the MountPoints field to testBaseImageInfo, and azl bare-metal needed the mount points under discussion. Let me know if those changes in main_test.go make sense. I went ahead and renamed to azureLinuxCoreLegacyMountPoints to prevent reader's confusion in this function.

return imagecustomizerapi.SELinuxModeDefault, err
}

imageSELinuxMode, err := bootCustomizer.GetSELinuxMode(buildDir, imageChroot)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of interest, what is the behavior of bootCustomizer.GetSELinuxMode on Ubuntu? Ideally, it should return SELinuxModeDisabled if SELinux isn't installed on the system.

Copy link
Contributor Author

@vinceaperri vinceaperri Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's an example error message when I comment out lines 43-51 in customizeselinux.go (the distroHandler.SupportsSELinux check):

    customizefiles_test.go:247: 
                Error Trace:    .../azure-linux-image-tools/toolkit/tools/pkg/imagecustomizerlib/customizefiles_test.go:247
                                                        .../azure-linux-image-tools/toolkit/tools/pkg/imagecustomizerlib/customizefiles_test.go:224
                Error:          Received unexpected error:
                                failed to customize OS:
                                failed to get current SELinux mode:
                                failed to find SELinux args in grub file (/etc/default/grub):
                                failed to find any of the specified GRUB variables in /etc/default/grub: [GRUB_CMDLINE_LINUX_DEFAULT GRUB_CMDLINE_LINUX]
                Test:           TestCustomizeImageAdditionalDirs/Ubuntu2404AzureCloud

So it returns return imagecustomizerapi.SELinuxModeDefault, err

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's probably a bug. If the variables (GRUB_CMDLINE_LINUX_DEFAULT and GRUB_CMDLINE_LINUX) don't exist, then we should assume there are empty.

…nd baseImageVariantBareMetal -> baseImageAzureLinuxVariantBareMetal
…acyMountPoints -> azureLinuxCoreLegacyMountPoints
- New flags: --base-image-azure-cloud-ubuntu2204 and --base-image-azure-cloud-ubuntu2404
- New functions: findFirstAvailableImage, for code reuse, and checkSkipForCustomizeDefaultImages, returning one default image for each distro, skipping on no availability.
- New constants: paramBaseImageCoreEfiAzl2, paramBaseImageCoreEfiAzl3, paramBaseImageBareMetalAzl2, paramBaseImageBareMetalAzl3, paramBaseImageAzureCloudUbuntu2204, paramBaseImageAzureCloudUbuntu2404, paramLogLevel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants