Skip to content

parity: add LCOW document permutation tests#2631

Open
shreyanshjain7174 wants to merge 1 commit intomicrosoft:mainfrom
shreyanshjain7174:parity/lcow-permutations
Open

parity: add LCOW document permutation tests#2631
shreyanshjain7174 wants to merge 1 commit intomicrosoft:mainfrom
shreyanshjain7174:parity/lcow-permutations

Conversation

@shreyanshjain7174
Copy link
Copy Markdown
Contributor

@shreyanshjain7174 shreyanshjain7174 commented Mar 16, 2026

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 normalizeKernelCmdLine and isOnlyKernelCmdLineWhitespaceDiff helpers. 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.

func isOnlyKernelCmdLineWhitespaceDiff(legacy, v2 *hcsschema.ComputeSystem) bool {
legacyCopy := *legacy
v2Copy := *v2
if legacyCopy.VirtualMachine != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this could've been a helper, that returns a copy. also, can't we just json marshal/unmarshal?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@shreyanshjain7174 shreyanshjain7174 force-pushed the parity/lcow-permutations branch 3 times, most recently from 8e06a52 to e0a8f7b Compare April 27, 2026 09:43
…, 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>
@shreyanshjain7174 shreyanshjain7174 force-pushed the parity/lcow-permutations branch from e0a8f7b to aeb3a2d Compare April 29, 2026 05:23
Copy link
Copy Markdown
Contributor

@rawahars rawahars left a comment

Choose a reason for hiding this comment

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

Overall looks good. Some nits.

// ─── Regression coverage for previously-known gaps now resolved ───

{
// Previously legacy emitted CpuGroup=nil while v2 emitted &{Id:""}.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove this comment please

},
},

// ─── Regression coverage for previously-known gaps now resolved ───
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove this comment and additional new lines too

},
},
{
// Previously legacy emitted StorageQoS=nil while v2 emitted &{}.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This comment should be rectified too

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.

4 participants