parity: add LCOW document permutation tests#2631
Open
shreyanshjain7174 wants to merge 2 commits intomicrosoft:mainfrom
Open
parity: add LCOW document permutation tests#2631shreyanshjain7174 wants to merge 2 commits intomicrosoft:mainfrom
shreyanshjain7174 wants to merge 2 commits intomicrosoft:mainfrom
Conversation
Address review feedback from PR microsoft#2629. Major changes: Source changes (internal/uvm/): - Export VerifyOptions, MakeLCOWDoc, MakeLCOWSecurityDoc as public functions so they can be called directly from the test package. - Remove MakeLCOWDocument composite wrapper — test assembles the pipeline itself using the exported primitives. - Add NewUtilityVMForDoc constructor in types.go. This is needed because MakeLCOWDoc takes a *UtilityVM parameter and reads its unexported fields (scsiControllerCount, vpmemMaxCount, etc). The test cannot set these fields directly from outside the package, so NewUtilityVMForDoc creates a minimal UtilityVM with only the fields needed for document generation. - Original source code comments preserved — only function names changed from lowercase to uppercase. Test changes (test/parity/vm/): - Moved from test/parity/ to test/parity/vm/ for future WCOW support. - Removed functional build tag — these are not functional tests. - Removed all normalization (nil-vs-empty, map sorting, owner zeroing). cmp.Diff handles maps natively. Real differences are not masked. - Merged pipeline helpers into hcs_document_creator_test.go. - Removed helpers_test.go — setupBootFiles and jsonToString moved inline. - Generic doc.go that covers both LCOW and future WCOW. - All test cases explicitly populate every field (CPU, memory, MMIO, QoS, CPUGroupID) so comparison always checks populated values, not defaults. - Use maps.Clone for annotation copying. - Use testing.Verbose() to gate debug logging. - Descriptive error messages throughout. All 8 tests pass (3 document parity + 5 field parity). Signed-off-by: Shreyansh Sancheti <shsancheti@microsoft.com>
6a7f064 to
917d728
Compare
Add TestLCOWDocumentParityPermutations to exercise annotation and option combinations that trigger different document construction branches in the legacy and v2 LCOW pipelines. Each test sets all required fields so comparisons check real values rather than defaults. Permutation categories: - CPU partial combinations (count, limit, weight) - Memory (overcommit disabled, cold discard hint) - Boot mode (kernel direct + VHD rootfs) - Feature flags (scratch encryption, writable overlay) - Device interactions (VPMem disabled → 4 SCSI controllers) - Cross-group (physically backed + VPMem + encryption) - Shim option overrides (annotation CPU/memory priority) - Kernel args (VPCIEnabled, time sync, process dump, initrd boot) Gap tests document three known v2 builder differences: - No CPUGroupID: legacy nil vs v2 empty CpuGroup struct - No StorageQoS: legacy nil vs v2 empty StorageQoS struct - Initrd boot: legacy VPMem controller vs v2 nil VirtualPMem Gap tests use inverted assertions — they expect a diff and only fail if documents unexpectedly match, signaling the v2 bug was fixed. Also adds normalizeKernelCmdLine and isOnlyKernelCmdLineWhitespaceDiff helpers to handle a known legacy quirk where initrd+KernelDirect boot produces a leading space in kernel command lines that v2 correctly omits. Signed-off-by: Shreyansh Sancheti <shsancheti@microsoft.com>
917d728 to
c24edac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR extends the LCOW parity test infrastructure from #2629 with permutation tests that exercise annotation and option combinations triggering different document construction branches in the legacy and v2 pipelines.
Changes
Permutation tests (
TestLCOWDocumentParityPermutations)19 test cases covering:
Gap tests
3 tests documenting known v2 builder differences using inverted assertions (they expect a diff and only fail if the documents unexpectedly match):
CpuGroup = nilCpuGroup = &{Id:""}StorageQoS = nilStorageQoS = &{}VirtualPMem = nilThese are tracked for fixes in the v2 builder (see #2630).
Kernel cmdline whitespace handling
Added
normalizeKernelCmdLineandisOnlyKernelCmdLineWhitespaceDiffhelpers. The legacy builder produces a leading space in kernel command lines for initrd+KernelDirect boot that the v2 builder correctly omits. Since HCS trims whitespace, this difference is harmless and we warn instead of failing.Testing
Requires admin PowerShell + Hyper-V enabled (tests call
processorinfo.HostProcessorInfovia HCS).Depends on