fix: add strict deb version match in VHD containerd content test#8960
fix: add strict deb version match in VHD containerd content test#8960abigailliang-aks-sig-node wants to merge 11 commits into
Conversation
6af5478 to
f541322
Compare
| @@ -0,0 +1,96 @@ | |||
| #!/bin/bash | |||
There was a problem hiding this comment.
This script file is not called or referenced by anyone, right?
There was a problem hiding this comment.
this a local test file starting as test_....
I originally planned to add a ShellSpec test, but ces_hepler.sh does not work well in the ShellSpec Docker environment. As a temporary solution, I’m keeping this as a local test script for manual validation.
And one of the follow-up is to figure out a way to unit test vhdbuilder/packer/test/linux-vhd-content-test.sh in ci
There was a problem hiding this comment.
If it's not added any CI, or local test bundle (like make generate). I am afraid that a few weeks later you will be the only one who knows this presence of this test script😅 and it will become dangling. Why did you say cse_helper.sh doesn't work well? There is an existing cse_helper_spec.sh.
There was a problem hiding this comment.
Agreed, i think it would be best to add as a shellspec. If not possible, i honestly don't think its necessary since its a test for a test, not super vital if we don't have it since the vhd content test will catch it
There was a problem hiding this comment.
The reason I initially thought integrating cse_helpers.sh with ShellSpec would be tricky was that I was trying to use source to load the script, which failed in the Docker environment due to missing system dependencies like lsb_release. So I left it as a local-only test script and planned to figure out the CI integration in a follow-up PR.
but your concerns here make sense. i could figure out a way to run a shell spec as the sample you mentioned here. thx.
also one thing i dont fully understand here. make generate doesn't corelated to this change —you mean we have an cse_helpers_spec.sh file can run the cse_helpers.sh
There was a problem hiding this comment.
Update: I removed the ShellSpec test since it had become redundant. It was only comparing hardcoded strings, and now that the package mapping lives directly in the content test cases, there isn't much left for it to test.
Thanks for the big-picture perspective—that was really helpful! 🙏 @Devinwong and @lilypan26
There was a problem hiding this comment.
Thanks for making the changes!
But as Lily suggested, it's rare to see unit testing a test-only function.
IMO, we generally just test production codes. Although it's no harm to test a test-only function, however if one day your spec/vhdbuilder/packer/test/assert_package_version_spec.sh fails, you will need to check 2 places (your test codes and the production codes). You can have local test to make sure your test-only function is valid. But once it's confirmed, we will trust it's always reliable.
So I will just remove the spec/vhdbuilder/packer/test/assert_package_version_spec.sh if that makes sense to you.
Per review feedback, replace renovateTag parsing with hardcoded package name mapping. renovateTag is metadata for Renovate bot and its format is not guaranteed stable — parsing it makes the test fragile to unrelated changes. Also remove the shellspec test since the mapping is now trivially explicit and doesn't warrant a separate unit test.
3c89aac to
7b302f9
Compare
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…est.sh and remove redundant test files
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
vhdbuilder/packer/test/linux-vhd-content-test.sh:321
testPackagesInstalledresolves containerd’s installed package name based only on$AZURELINUX_OS_NAME, butgetCurrentPackageTestOScan set OS to$AZURELINUX_KATA_OS_NAME(AzureLinux kata). In that case this falls through tomoby-containerd, causing the strict package-version check to query the wrong package name and fail on kata images.
case "$OS" in
"$AZURELINUX_OS_NAME")
pkgName="containerd2"
;;
*)
vhdbuilder/packer/test/linux-vhd-content-test.sh:36
- The PR description says
err()call signatures were updated to the 2-argument format, but this script still has multiple 1-argument call sites (e.g. around lines ~1754, ~1764, ~1955, ~2245, ~2333). With the currenterr()implementation, those emit malformed output like<message>:Error:with an empty message. Either update remaining call sites or makeerr()tolerant of being called with a single argument.
err() {
echo "$1:Error: $2" >>/dev/stderr
}
# assertPackageVersion verifies that the installed deb/rpm package version matches
| local crictl_version | ||
| crictl_version=$(crictl --version) | ||
| # the output of crictl_version looks like this "crictl version 1.32.0", need to extract the version number. | ||
| crictl_version=$(echo $crictl_version | cut -d' ' -f3) |
Summary
Add strict full-version matching in the VHD content test for containerd and cri-tools, catching version drift at VHD build time rather than in e2e.
Problem
The VHD content test (
testContainerd/testCriCtl) previously only comparedmajor.minor.patch(stripping the hotfix suffix viacut -d- -f1). This meant:components.jsonsays2.3.2-ubuntu24.04u12.3.2-ubuntu24.04u2(due to apt wildcardmoby-containerd=2.3.2*)2.3.2==2.3.2)Changes
assertPackageVersionhelper (inline inlinux-vhd-content-test.sh): usesdpkg-query(deb) orrpm(RPM-based) to compare the full installed version against components.jsonkubernetes-cri-tools→kubernetes-cri-tools(same across all OS)containerd→moby-containerd(Ubuntu/Mariner) orcontainerd2(Azure Linux 3.0+)err()call signatures to match the two-argument format ($1=test name,$2=message)debPackageName→installedPackageNamesince the check now covers both deb and rpmFollow-up items
testPackagesInstalledcurrently skips entirely on ARM64 (line 209), meaning ARM64 VHDs have no package version validation. Opening this up to ARM64 would require verifying that all packages incomponents.jsonhave correct ARM64 entries and that the download/install paths work for arm64.Test plan
u99:components.jsonversion passes content test (will be verified once CI runs with correct version)