parity: add LCOW document permutation tests#2631
parity: add LCOW document permutation tests#2631shreyanshjain7174 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
6a7f064 to
917d728
Compare
917d728 to
c24edac
Compare
f71836c to
412dd22
Compare
4d1c035 to
a72d5b1
Compare
a72d5b1 to
f31ad7d
Compare
| func isOnlyKernelCmdLineWhitespaceDiff(legacy, v2 *hcsschema.ComputeSystem) bool { | ||
| legacyCopy := *legacy | ||
| v2Copy := *v2 | ||
| if legacyCopy.VirtualMachine != nil { |
There was a problem hiding this comment.
this could've been a helper, that returns a copy. also, can't we just json marshal/unmarshal?
There was a problem hiding this comment.
The normalizeKernelCmdLine and isOnlyKernelCmdLineWhitespaceDiff helpers (where the shallow-copy pattern lived) were dropped in the e0a8f7b rewrite ΓÇö the underlying kernel-cmdline whitespace quirk only manifested with vPMem boot, and vPMem support has since been removed from the v2 builder (see da11cd2). The current parity tests don't shallow-copy schema documents anywhere; they use maps.Clone for annotation maps and let the builders produce fresh documents from inputs, so the json-marshal/unmarshal helper isn't needed today. Will keep your suggestion on file as the recommended approach if any future test does need a deep struct copy.
8e06a52 to
e0a8f7b
Compare
…, and error paths
Add lcow_doc_permutations_test.go with three new test functions that build
on the existing TestLCOWDocumentParity / TestLCOWSandboxOptionsFieldParity
scaffolding:
* TestLCOWDocumentParityPermutations exercises 26 annotation and option
permutations covering CPU partials, memory edge cases (overcommit,
cold discard, deferred commit, non-256-aligned size), boot modes
(UEFI vs kernel direct, initrd vs VHD), feature flags (scratch
encryption, writable shares, policy-based routing, writable overlay),
HvSocket extra ports, kernel arg combinations (VPCI, time sync,
process dump, dump dir), shim option overrides, and regression cases
for previously-known nil-vs-empty struct gaps in CpuGroup and
StorageQoS.
* TestLCOWErrorPathParity asserts that both pipelines fail (or both
succeed) on invalid boot files paths and on the deferred commit +
physically backed memory conflict.
* TestLCOWSandboxOptionsFieldParityNonDefault verifies SandboxOptions
field parity (NoWritableFileShares, EnableScratchEncryption,
PolicyBasedRouting, FullyPhysicallyBacked, VPMEMMultiMapping) when
callers opt into non-default values, complementing the existing
default-config test.
All cases force VPMemCount=0 on the legacy side because the v2 builder
rejects vPMem entirely (commit da11cd2), so the documents are directly
comparable. vPMem-specific permutations and inverted-assertion gap tests
from earlier revisions of this PR are dropped.
Signed-off-by: Shreyansh Sancheti <shsancheti@microsoft.com>
e0a8f7b to
aeb3a2d
Compare
rawahars
left a comment
There was a problem hiding this comment.
Overall looks good. Some nits.
| // ─── Regression coverage for previously-known gaps now resolved ─── | ||
|
|
||
| { | ||
| // Previously legacy emitted CpuGroup=nil while v2 emitted &{Id:""}. |
There was a problem hiding this comment.
Remove this comment please
| }, | ||
| }, | ||
|
|
||
| // ─── Regression coverage for previously-known gaps now resolved ─── |
There was a problem hiding this comment.
Remove this comment and additional new lines too
| }, | ||
| }, | ||
| { | ||
| // Previously legacy emitted StorageQoS=nil while v2 emitted &{}. |
There was a problem hiding this comment.
This comment should be rectified too
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.
19 permutation tests covering: CPU partial combinations (count-only, limit-only, weight-only), memory (overcommit disabled, cold discard hint), boot mode (kernel direct + VHD rootfs), feature flags (scratch encryption + disabled writable shares, writable overlay dirs), device interactions (VPMem disabled triggers 4 SCSI controllers), cross-group (physically backed + VPMem disabled + scratch encryption, full CPU + memory + MMIO + QoS + cold discard + VHD boot), shim option overrides (annotation CPU/memory overriding shim option values), kernel args (VPCIEnabled + custom boot options, time sync + process dump + writable overlay, initrd boot whitespace quirk).
3 gap tests documenting known v2 builder differences using inverted assertions — they expect a diff and fail only if documents unexpectedly match: nil vs empty CpuGroup, nil vs empty StorageQoS, VPMem controller allocation on initrd boot.
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, we warn instead of failing.