parity: add LCOW HCS document parity tests between legacy and v2 builders#2629
parity: add LCOW HCS document parity tests between legacy and v2 builders#2629shreyanshjain7174 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
rawahars
left a comment
There was a problem hiding this comment.
Left comments.
Also, please ensure that the comments are verbose and easy to understand.
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>
44a4cea to
b6a131c
Compare
|
Thanks for the thorough review @rawahars — really appreciate the detailed feedback. Pushed a full restructure addressing all 26 comments: Source changes:
Test restructure:
Key finding during testing: The v2 builder unconditionally initializes |
| func TestLCOWSandboxOptionsFieldParity(t *testing.T) { | ||
| bootDir := setupBootFiles(t) | ||
|
|
||
| tests := []struct { |
There was a problem hiding this comment.
In order to test the fields which are part of SandboxOptions, do you need runhcsoptions too?
There was a problem hiding this comment.
Yes — both pipelines require runhcsopts.Options to function. The legacy path needs it for oci.UpdateSpecFromOptions and boot file resolution, the v2 path needs it as a required parameter to BuildSandboxConfig (reads SandboxPlatform and BootFilesRootPath). The SandboxOptions fields themselves come from annotations, but the pipeline that produces them won't run without shimOpts.
test/parity/vm/lcow_doc_test.go
Outdated
| t.Fatalf("failed to build v2 LCOW document: %v", err) | ||
| } | ||
|
|
||
| checks := []struct { |
There was a problem hiding this comment.
nit: Maybe define this outside the inner t.Run. It becomes confusing inside the loop.
Also, I imagine you would need to test other fields too including Confidential Options.
- Rename package from 'vm' to 'vmparity' for clarity - Rename hcs_document_creator_test.go to hcs_lcow_document_creator_test.go to distinguish LCOW-specific helpers from future WCOW - Revert MakeLCOWSecurityDoc back to unexported (not used in tests) - Simplify doc.go to match codebase convention (minimal, no file layout) - Update NewUtilityVMForDoc comment explaining why it must stay in uvm package (UtilityVM fields are unexported) Signed-off-by: Shreyansh Sancheti <shsancheti@microsoft.com>
99c900d to
3f1b638
Compare
Signed-off-by: Shreyansh Sancheti <shsancheti@microsoft.com>
3f1b638 to
72d9362
Compare
Summary
Adds parity tests that compare the HCS ComputeSystem documents produced by the
legacy shim pipeline and the new v2 LCOW builder (
lcow.BuildSandboxConfig).Both paths receive the same inputs — annotations, shim options, and devices —
so the resulting documents should be structurally identical.
How it works
Each test case feeds identical inputs to both pipelines:
Changes
internal/uvm/create_lcow.go: Export
MakeLCOWDocandVerifyOptionsforuse in parity tests. These generate the HCS document and validate options
without creating a VM or calling HCS.
internal/uvm/types.go: Add
NewUtilityVMForDocconstructor — creates aminimal
UtilityVMwith the fields needed byMakeLCOWDoc. Must live in theuvmpackage because allUtilityVMfields are unexported.internal/uvm/create.go, internal/uvm/create_wcow.go: Rename
verifyOptions→VerifyOptions(exported)..github/workflows/ci.yml: Include
test/parity/vm/in the non-functionaltest step.
test/parity/vm/ (new
vmparitypackage):doc.go— package documentationhcs_lcow_document_creator_test.go— helper functions that wire the legacyand v2 pipelines:
buildLegacyLCOWDocument,buildV2LCOWDocument,setupBootFiles,jsonToStringlcow_doc_test.go— 3 document parity tests, 5 sandbox option field checks,and a
checkSandboxOptionsParityhelper for extensibilityTest cases
Results
All 8 tests pass (3 document + 5 field).
More permutations (boot modes, VPCI devices, VPMem sizes, NUMA topology) will
be added in follow-up PRs once this foundation is reviewed and merged.