Commit 72ac4ca
Shreyansh Sancheti
service: add unit tests for LCOW v2 shim service layer
Add unit tests for the sandbox, shimdiag, and task service methods in
cmd/containerd-shim-lcow-v2/service/. Tests exercise the public TTRPC
methods directly — including the instrumentation layer — with a mocked
vm.Controller injected via export_test.go.
The mock is generated from the vm.Controller interface using mockgen and
lives at internal/controller/vm/mock/mock_vm.go. A go:generate directive
is added to internal/controller/vm/interface.go.
14 test functions, 57 subtests covering: sandbox ID mismatch guards across
7 methods, duplicate sandbox rejection, missing config.json, StartVM
success and failure, platform state gating, StopSandbox terminate paths,
WaitSandbox exit code mapping (clean vs ERROR_INTERNAL_ERROR) and Wait/
ExitStatus failures, SandboxStatus for all 5 VM states plus ExitStatus
error, ShutdownSandbox terminate-error-swallowing, SandboxMetrics marshal
roundtrip, DiagExecInHost delegation, DiagPid, and ErrNotImplemented
coverage for all 20 stub methods.
Not covered: the full CreateSandbox -> BuildSandboxConfig -> CreateVM path
(BuildSandboxConfig has its own tests in internal/builder/vm/lcow/) and
the confidential StartSandbox path (reads boot files from disk — belongs
in functional tests).
All tests run without admin privileges or HCS.
Signed-off-by: Shreyansh Sancheti <shsancheti@microsoft.com>1 parent 372f3f6 commit 72ac4ca
6 files changed
Lines changed: 1034 additions & 0 deletions
File tree
- cmd/containerd-shim-lcow-v2/service
- internal/controller/vm
- mock
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
0 commit comments