test: add podvm test suite #3361
CodeQL / Use of insecure HostKeyCallback implementation
Configuring SSH ClientConfig with insecure HostKeyCallback implementation from [this source](1).
fixed, caching the host key not
The documented RUN_TESTS=TestPodVM/SystemdServices/AttestationAgent command filters out SSHReady, but a filtered t.Run still returns true. This leaves client nil, so the selected test and cleanup panic. Initialize SSH in the parent test, outside the filterable subtest, so every selected test receives a connected client.
Neither NewSession nor CombinedOutput observes a context, and sshClient clears the connection's handshake deadline. If the guest stops responding, a service check can remain blocked here after both its five-second attempt timeout and ten-second overall timeout expire. The global test timeout can then abort the run without normal VM cleanup. Pass bounded contexts through this helper and its callers, make session creation and execution interruptible, and bound diagnostic commands too.
Two successful is-active checks do not establish that the service stayed running between samples. A service can crash, restart, and be active again at the second check, so this can report a flapping service as stable. Capture InvocationID with each active check and retry when the ID changes during the two-second interval.
<!-- ccr-overview-v2 -->
Copilot review overview
🟡 Changes recommended
Test initialization, service stability checks, and SSH timeout handling have unresolved correctness issues.
Review effort: Balanced
Findings: 1 <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.png" alt="High severity" width="62" height="18" align="texttop"></picture> · 2 <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture>
<details open>
<summary><strong>Open (3)</strong></summary>
</details>
<details>
<summary><strong>What changed in this PR</strong></summary>
Adds a standalone QEMU-based PodVM test suite to shorten development feedback without requiring Kubernetes or a CAA deployment.
Changes:
| File | Description |
| ---- | ----------- |
| src/cloud-api-adaptor/test/podvm/systemd.go | Service readiness checks and diagnostics. |
| src/cloud-api-adaptor/test/podvm/ssh.go | SSH command helper. |
| src/cloud-api-adaptor/test/podvm/README.md | Requirements and test instructions. |
| src/cloud-api-adaptor/test/podvm/qemu.go | VM startup, SSH connectivity, and cleanup. |
| src/cloud-api-adaptor/test/podvm/podvm_test.go | PodVM integration tests and fixtures. |
| src/cloud-api-adaptor/test/podvm/config_drive.go | User-data ISO generation. |
| src/cloud-api-adaptor/Makefile | Configurable test-podvm target. |
| src/cloud-api-adaptor/go.sum | Checksums for new dependencies. |
| src/cloud-api-adaptor/go.mod | Direct test dependencies and socket support. |
</details>
---
💡 <a href="/confidential-containers/cloud-api-adaptor/new/main?filename=.github/skills/code-review/SKILL.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add a code-review agent skill</a> or configure MCP servers for context-aware, tailored reviews. <a href="https://docs.github.com/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review?tool=webui#mcp-servers-and-agent-skills" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn more in the docs.</a>
I'm not sure it's particularly harmful, but I wondered if there was a reason for ssh.go and systemd.go not having:
//go:build linux && amd64
like the others as I'm not sure they are worth compiling on other platforms currently?
nit: Not a massive deal, but it looks like the base test name and some of the tests have been changes since the commit message was written, so it's a bit stale.
Is there an issue with this defer? IIUC this with run once startQEMU returns, but I think we want to keep the logFile open for the duration of the tests, so maybe it needs to be stored in qemuVM and then called in close()?
This is just my vibes, but 500ms feels like a short timeout, which could lead to lots of repeated attempts (which probably isn't a big deal). Do you have any data on how quickly it "normally" is ready, in case it's ~30s and then we could make the ticker larger?
Bob suggests this:
defer cancelBoot()
client, err := vm.waitForSSH(bootCtx, signer)
is more idiomatic and the defer covers more cases of (admitedly esoteric) failures.
It does seem to match the official doc on this.
I do wonder if we can do any caching, or check if this build is available as it will take longer than the tests, but that's for future and not needed here.
This looks great, but I have a few comments, also, the first time I tried this it failed, but it passed on re-run which is maybe a combination of a timeout being a little low on a slow machine and the ssh client close issue mentioned below?
sudo env "PATH=$PATH" "MKOSI_VERSION=$MKOSI_VERSION" make test-podvm TEST_PODVM_IMAGE=podvm/build/podvm-ubuntu-amd64.qcow2
go: downloading github.com/spf13/cobra v1.10.0
go: downloading github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.14.1
go: downloading github.com/Azure/azure-sdk-for-go/sdk/azcore v1.23.1
go: downloading github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v4 v4.2.1
go: downloading github.com/google/uuid v1.6.0
go: downloading k8s.io/api v0.35.2
go: downloading k8s.io/apimachinery v0.35.2
go: downloading k8s.io/client-go v0.35.2
go: downloading github.com/containerd/ttrpc v1.2.7
go: downloading github.com/kata-containers/kata-containers/src/runtime v0.0.0-20260915102810-c7351e797eff
go: downloading github.com/avast/retry-go/v4 v4.6.1
go: downloading google.golang.org/protobuf v1.36.11
go: downloading google.golang.org/grpc v1.83.2
go: downloading github.com/containerd/containerd v1.7.36
go: downloading github.com/pelletier/go-toml/v2 v2.1.0
go: downloading github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f
go: downloading golang.org/x/sys v0.48.0
go: downloading github.com/fenglyu/go-dmidecode v0.0.0-20220417074508-03f52eb45fe9
go: downloading github.com/klauspost/cpuid/v2 v2.3.0
go: downloading github.com/coreos/go-iptables v0.6.0
go: downloading github.com/moby/sys/mountinfo v0.7.2
go: downloading github.com/opencontainers/runtime-spec v1.2.1
go: downloading github.com/vishvananda/netlink v1.3.1
go: downloading github.com/vishvananda/netns v0.0.5
go: downloading golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f
go: downloading k8s.io/component-base v0.35.2
go: downloading golang.org/x/crypto v0.57.0
go: downloading github.com/Azure/azure-sdk-for-go/sdk/internal v1.12.0
go: downloading github.com/AzureAD/microsoft-authentication-library-for-go v1.8.0
go: downloading github.com/spf13/pflag v1.0.9
go: downloading sigs.k8s.io/controller-runtime v0.23.1
go: downloading k8s.io/utils v0.0.0-20251002143259-bc988d571ff4
go: downloading sigs.k8s.io/randfill v1.0.0
go: downloading k8s.io/klog/v2 v2.130.1
go: downloading github.com/containerd/log v0.1.0
go: downloading google.golang.org/genproto/googleapis/rpc v0.0.0-20260803160001-6ac0973c030d
go: downloading github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822
go: downloading google.golang.org/genproto v0.0.0-20260319201613-d00831a3d3e7
go: downloading golang.org/x/net v0.59.0
go: downloading github.com/pkg/sftp v1.13.9
go: downloading k8s.io/cri-api v0.33.0
go: downloading github.com/digitalocean/go-smbios v0.0.0-20180907143718-390a4f403a8e
go: downloading github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
go: downloading github.com/kylelemons/godebug v1.1.0
go: downloading k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912
go: downloading sigs.k8s.io/structured-merge-diff/v6 v6.3.2-0.20260122202528-d9cc6641c482
go: downloading gopkg.in/inf.v0 v0.9.1
go: downloading sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730
go: downloading github.com/google/gnostic-models v0.7.0
go: downloading golang.org/x/time v0.15.0
go: downloading github.com/go-logr/logr v1.4.4
go: downloading github.com/sirupsen/logrus v1.9.4
go: downloading github.com/fxamacker/cbor/v2 v2.9.0
go: downloading golang.org/x/term v0.46.0
go: downloading golang.org/x/oauth2 v0.36.0
go: downloading github.com/containerd/continuity v0.4.4
go: downloading github.com/containerd/platforms v0.2.1
go: downloading github.com/moby/sys/user v0.4.0
go: downloading github.com/moby/sys/userns v0.1.0
go: downloading github.com/opencontainers/image-spec v1.1.1
go: downloading github.com/containerd/cgroups/v3 v3.0.5
go: downloading github.com/opencontainers/selinux v1.13.1
go: downloading tags.cncf.io/container-device-interface v1.0.1
go: downloading github.com/kr/fs v0.1.0
go: downloading github.com/gogo/protobuf v1.3.2
go: downloading golang.org/x/sync v0.23.0
go: downloading github.com/golang-jwt/jwt/v5 v5.3.1
go: downloading github.com/json-iterator/go v1.1.12
go: downloading go.yaml.in/yaml/v2 v2.4.4
go: downloading go.yaml.in/yaml/v3 v3.0.5
go: downloading sigs.k8s.io/yaml v1.6.0
go: downloading github.com/x448/float16 v0.8.4
go: downloading github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
go: downloading github.com/containerd/typeurl/v2 v2.2.3
go: downloading github.com/opencontainers/go-digest v1.0.0
go: downloading github.com/containerd/containerd/api v1.9.0
go: downloading github.com/containerd/fifo v1.1.0
go: downloading github.com/containerd/errdefs v1.0.0
go: downloading github.com/moby/sys/symlink v0.2.0
go: downloading github.com/moby/sys/signal v0.7.0
go: downloading github.com/fsnotify/fsnotify v1.9.0
go: downloading github.com/opencontainers/runtime-tools v0.9.1-0.20250303011046-260e151b8552
go: downloading tags.cncf.io/container-device-interface/specs-go v1.0.0
go: downloading golang.org/x/text v0.42.0
go: downloading github.com/go-openapi/swag v0.23.1
go: downloading github.com/go-openapi/jsonreference v0.21.0
go: downloading gopkg.in/evanphx/json-patch.v4 v4.13.0
go: downloading github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
go: downloading github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee
go: downloading github.com/klauspost/compress v1.18.7
go: downloading github.com/distribution/reference v0.6.0
go: downloading github.com/google/go-cmp v0.7.0
go: downloading github.com/moby/locker v1.0.1
go: downloading go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.67.0
go: downloading go.opentelemetry.io/otel v1.45.0
go: downloading go.opentelemetry.io/otel/trace v1.45.0
go: downloading github.com/cyphar/filepath-securejoin v0.6.0
go: downloading golang.org/x/mod v0.41.0
go: downloading github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
go: downloading github.com/emicklei/go-restful/v3 v3.12.2
go: downloading github.com/mailru/easyjson v0.9.0
go: downloading github.com/go-openapi/jsonpointer v0.21.1
go: downloading github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c
go: downloading github.com/felixge/httpsnoop v1.0.4
go: downloading go.opentelemetry.io/otel/metric v1.45.0
go: downloading github.com/josharian/intern v1.0.0
go: downloading github.com/go-logr/stdr v1.2.2
go: downloading go.opentelemetry.io/auto/sdk v1.2.1
go: downloading github.com/cespare/xxhash/v2 v2.3.0
TEST_PODVM_IMAGE=/root/go/src/github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/podvm/build/podvm-ubuntu-amd64.qcow2 go test -v -timeout 5m -count=1 -run '' ./test/podvm
go: downloading github.com/kdomanski/iso9660 v0.4.0
go: downloading github.com/mdlayher/vsock v1.3.0
go: downloading github.com/stretchr/testify v1.12.1
go: downloading github.com/mdlayher/socket v0.6.0
=== RUN TestDebugPodVM
=== RUN TestDebugPodVM/ExecuteCommandOverVSock
=== RUN TestDebugPodVM/ProvisionUserData
podvm_test.go:116:
Error Trace: /root/go/src/github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/podvm/podvm_test.go:116
Error: Received unexpected error:
wait for provisioned user data: context deadline exceeded (last error: run SSH command: context deadline exceeded)
Test: TestDebugPodVM/ProvisionUserData
=== RUN TestDebugPodVM/SystemdServices
=== RUN TestDebugPodVM/SystemdServices/ProcessUserData
=== PAUSE TestDebugPodVM/SystemdServices/ProcessUserData
=== RUN TestDebugPodVM/SystemdServices/AttestationAgent
=== PAUSE TestDebugPodVM/SystemdServices/AttestationAgent
=== RUN TestDebugPodVM/SystemdServices/ConfidentialDataHub
=== PAUSE TestDebugPodVM/SystemdServices/ConfidentialDataHub
=== RUN TestDebugPodVM/SystemdServices/APIServerREST
=== PAUSE TestDebugPodVM/SystemdServices/APIServerREST
=== RUN TestDebugPodVM/SystemdServices/KataAgent
=== PAUSE TestDebugPodVM/SystemdServices/KataAgent
=== CONT TestDebugPodVM/SystemdServices/ProcessUserData
=== CONT TestDebugPodVM/SystemdServices/APIServerREST
=== CONT TestDebugPodVM/SystemdServices/ConfidentialDataHub
=== CONT TestDebugPodVM/SystemdServices/AttestationAgent
=== NAME TestDebugPodVM/SystemdServices/ProcessUserData
podvm_test.go:139:
Error Trace: /root/go/src/github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/podvm/podvm_test.go:139
Error: Received unexpected error:
wait for process-user-data.service: context deadline exceeded (last error: read vsock vm(4294967295):1996731343->vm(3):22: use of closed network connection)
==> systemd state <==
failed to collect diagnostics: read vsock vm(4294967295):1996731343->vm(3):22: use of closed network connection
Test: TestDebugPodVM/SystemdServices/ProcessUserData
=== NAME TestDebugPodVM/SystemdServices/ConfidentialDataHub
podvm_test.go:139:
Error Trace: /root/go/src/github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/podvm/podvm_test.go:139
Error: Received unexpected error:
wait for confidential-data-hub.service: context deadline exceeded (last error: read vsock vm(4294967295):1996731343->vm(3):22: use of closed network connection)
==> systemd state <==
failed to collect diagnostics: read vsock vm(4294967295):1996731343->vm(3):22: use of closed network connection
Test: TestDebugPodVM/SystemdServices/ConfidentialDataHub
=== CONT TestDebugPodVM/SystemdServices/KataAgent
=== NAME TestDebugPodVM/SystemdServices/AttestationAgent
podvm_test.go:139:
Error Trace: /root/go/src/github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/podvm/podvm_test.go:139
Error: Received unexpected error:
wait for attestation-agent.service: context deadline exceeded (last error: read vsock vm(4294967295):1996731343->vm(3):22: use of closed network connection)
==> systemd state <==
failed to collect diagnostics: read vsock vm(4294967295):1996731343->vm(3):22: use of closed network connection
Test: TestDebugPodVM/SystemdServices/AttestationAgent
=== NAME TestDebugPodVM/SystemdServices/APIServerREST
podvm_test.go:139:
Error Trace: /root/go/src/github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/podvm/podvm_test.go:139
Error: Received unexpected error:
wait for api-server-rest.service: context deadline exceeded (last error: read vsock vm(4294967295):1996731343->vm(3):22: use of closed network connection)
==> systemd state <==
failed to collect diagnostics: read vsock vm(4294967295):1996731343->vm(3):22: use of closed network connection
Test: TestDebugPodVM/SystemdServices/APIServerREST
=== NAME TestDebugPodVM/SystemdServices/KataAgent
podvm_test.go:139:
Error Trace: /root/go/src/github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/podvm/podvm_test.go:139
Error: Received unexpected error:
wait for kata-agent.service: context deadline exceeded (last error: read vsock vm(4294967295):1996731343->vm(3):22: use of closed network connection)
==> systemd state <==
failed to collect diagnostics: read vsock vm(4294967295):1996731343->vm(3):22: use of closed network connection
Test: TestDebugPodVM/SystemdServices/KataAgent
=== RUN TestDebugPodVM/ForwarderMutualTLS
podvm_test.go:147:
Error Trace: /root/go/src/github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/podvm/podvm_test.go:147
Error: Received unexpected error:
wait for agent protocol forwarder TLS: context deadline exceeded (last error: dial tcp 127.0.0.1:44333: i/o timeout)
Test: TestDebugPodVM/ForwarderMutualTLS
=== RUN TestDebugPodVM/KataAgentHealth
podvm_test.go:153:
Error Trace: /root/go/src/github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/podvm/podvm_test.go:153
Error: Received unexpected error:
wait for kata agent health: context deadline exceeded (last error: dial tcp 127.0.0.1:44333: i/o timeout)
Test: TestDebugPodVM/KataAgentHealth
=== RUN TestDebugPodVM/SandboxLifecycle
podvm_test.go:161:
Error Trace: /root/go/src/github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/podvm/podvm_test.go:161
Error: Received unexpected error:
read tcp 127.0.0.1:53428->127.0.0.1:44333: read: connection reset by peer
Test: TestDebugPodVM/SandboxLifecycle
--- FAIL: TestDebugPodVM (85.83s)
--- PASS: TestDebugPodVM/ExecuteCommandOverVSock (0.04s)
--- FAIL: TestDebugPodVM/ProvisionUserData (10.00s)
--- FAIL: TestDebugPodVM/SystemdServices (0.00s)
--- FAIL: TestDebugPodVM/SystemdServices/ProcessUserData (10.00s)
--- FAIL: TestDebugPodVM/SystemdServices/ConfidentialDataHub (10.00s)
--- FAIL: TestDebugPodVM/SystemdServices/AttestationAgent (10.00s)
--- FAIL: TestDebugPodVM/SystemdServices/APIServerREST (10.00s)
--- FAIL: TestDebugPodVM/SystemdServices/KataAgent (10.00s)
--- FAIL: TestDebugPodVM/ForwarderMutualTLS (10.00s)
--- FAIL: TestDebugPodVM/KataAgentHealth (10.00s)
--- FAIL: TestDebugPodVM/SandboxLifecycle (0.00s)
FAIL
FAIL github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/podvm 85.862s
FAIL
make: *** [Makefile:119: test-podvm] Error 1
root@sh-dev1:~/go/src/github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor# sudo env "PATH=$PATH" "MKOSI_VERSION=$MKOSI_VERSION" make test-podvm TEST_PODVM_IMAGE=podvm/build/podvm-ubuntu-amd64.qcow2
TEST_PODVM_IMAGE=/root/go/src/github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/podvm/build/podvm-ubuntu-amd64.qcow2 go test -v -timeout 5m -count=1 -run '' ./test/podvm
=== RUN TestDebugPodVM
=== RUN TestDebugPodVM/ExecuteCommandOverVSock
=== RUN TestDebugPodVM/ProvisionUserData
=== RUN TestDebugPodVM/SystemdServices
=== RUN TestDebugPodVM/SystemdServices/ProcessUserData
=== PAUSE TestDebugPodVM/SystemdServices/ProcessUserData
=== RUN TestDebugPodVM/SystemdServices/AttestationAgent
=== PAUSE TestDebugPodVM/SystemdServices/AttestationAgent
=== RUN TestDebugPodVM/SystemdServices/ConfidentialDataHub
=== PAUSE TestDebugPodVM/SystemdServices/ConfidentialDataHub
=== RUN TestDebugPodVM/SystemdServices/APIServerREST
=== PAUSE TestDebugPodVM/SystemdServices/APIServerREST
=== RUN TestDebugPodVM/SystemdServices/KataAgent
=== PAUSE TestDebugPodVM/SystemdServices/KataAgent
=== CONT TestDebugPodVM/SystemdServices/ProcessUserData
=== CONT TestDebugPodVM/SystemdServices/KataAgent
=== CONT TestDebugPodVM/SystemdServices/APIServerREST
=== CONT TestDebugPodVM/SystemdServices/ConfidentialDataHub
=== CONT TestDebugPodVM/SystemdServices/AttestationAgent
=== RUN TestDebugPodVM/ForwarderMutualTLS
=== RUN TestDebugPodVM/KataAgentHealth
=== RUN TestDebugPodVM/SandboxLifecycle
=== RUN TestDebugPodVM/SandboxLifecycle/LaunchContainers
=== RUN TestDebugPodVM/SandboxLifecycle/LaunchContainers/Message
=== RUN TestDebugPodVM/SandboxLifecycle/LaunchContainers/GetEvidence
--- PASS: TestDebugPodVM (45.11s)
--- PASS: TestDebugPodVM/ExecuteCommandOverVSock (0.02s)
--- PASS: TestDebugPodVM/ProvisionUserData (0.07s)
--- PASS: TestDebugPodVM/SystemdServices (0.00s)
--- PASS: TestDebugPodVM/SystemdServices/ProcessUserData (2.39s)
--- PASS: TestDebugPodVM/SystemdServices/ConfidentialDataHub (2.55s)
--- PASS: TestDebugPodVM/SystemdServices/APIServerREST (2.56s)
--- PASS: TestDebugPodVM/SystemdServices/KataAgent (2.57s)
--- PASS: TestDebugPodVM/SystemdServices/AttestationAgent (2.07s)
--- PASS: TestDebugPodVM/ForwarderMutualTLS (0.04s)
--- PASS: TestDebugPodVM/KataAgentHealth (0.03s)
--- PASS: TestDebugPodVM/SandboxLifecycle (3.98s)
--- PASS: TestDebugPodVM/SandboxLifecycle/LaunchContainers (3.92s)
--- PASS: TestDebugPodVM/SandboxLifecycle/LaunchContainers/Message (2.66s)
--- PASS: TestDebugPodVM/SandboxLifecycle/LaunchContainers/GetEvidence (1.26s)
PASS
ok github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/podvm 45.129s
you mean for re-running? we could decouple it into build/test jobs. otherwise, I think a rebuild of the image is intended, no? generally, I would hope that this test is very reliable b/c it has so little dependencies
it wouldn't hurt to bump it to 1s
that's sort of the case by assigning it to cmd.Stdout/Err, the logs should be open for writing by the qemu process while it runs
yeah, the idea was to disable for platforms w/o kvm. we can add it in each file of this package
I just mean in general as we will build the image a few times in our workflows I think and if it's a test only change we could try and grab an old build like we do in kata - that is admittedly fairly complex, so maybe it's not worth it yet.
This looks great, but I have a few comments, also, the first time I tried this it failed, but it passed on re-run which is maybe a combination of a timeout being a little low on a slow machine and the ssh client close issue mentioned below?
thanks for testing,. 45s is certainly longer than what I am seeing locally (~20s) and on the CI (~17s).
I think you might have ran into a race condition in the podvm with mounting config disks, which makes the provisioning test fail, but this failing test also tears down the ssh client for every other test. the latter is bug in the test code, I'll have to fix that.
> This looks great, but I have a few comments, also, the first time I tried this it failed, but it passed on re-run which is maybe a combination of a timeout being a little low on a slow machine and the ssh client close issue mentioned below?
> thanks for testing,. 45s is certainly longer than what I am seeing locally (~20s) and on the CI (~17s).
> I think you might have ran into a race condition in the podvm with mounting config disks, which makes the provisioning test fail, but this failing test also tears down the ssh client for every other test. the latter is bug in the test code, I'll have to fix that.
ok, now it's using a dedicated ssh connection for each test and I bumped the timeout for the provisioning test to 15s, but we probably shouldn't increase it more. that really points to something being borked if provisioning is not done 15s after ssh is up.
hmm yeah, for just changing test code that could make sense. but not sure it's worth it, either. the podvm build is pretty fast. If tests are developed I would run this locally
good, now there is a test run on the CI that reproduces the problem and isolated it more clearly: SSH is up, services are up, but it the PodVM is misconfigured because the config-drive is not available in time.
I am trying to address this in another PR, it's hairy.
> > This looks great, but I have a few comments, also, the first time I tried this it failed, but it passed on re-run which is maybe a combination of a timeout being a little low on a slow machine and the ssh client close issue mentioned below?
>
>
> thanks for testing,. 45s is certainly longer than what I am seeing locally (~20s) and on the CI (~17s).
> I think you might have ran into a race condition in the podvm with mounting config disks, which makes the provisioning test fail, but this failing test also tears down the ssh client for every other test. the latter is bug in the test code, I'll have to fix that.
> ok, now it's using a dedicated ssh connection for each test and I bumped the timeout for the provisioning test to 15s, but we probably shouldn't increase it more. that really points to something being borked if provisioning is not done 15s after ssh is up.
For reference I ran it on a 4 vCPU, 8GB RAM VM. I've updating to the latest code and re-ran twice and got passing first time, failing second:
sudo env "PATH=$PATH" "MKOSI_VERSION=$MKOSI_VERSION" make test-podvm TEST_PODVM_IMAGE=podvm/build/podvm-ubuntu-amd64.qcow2
TEST_PODVM_IMAGE=/root/go/src/github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/podvm/build/podvm-ubuntu-amd64.qcow2 go test -v -timeout 5m -count=1 -run '' ./test/podvm
=== RUN TestDebugPodVM
=== RUN TestDebugPodVM/ExecuteCommandOverVSock
=== RUN TestDebugPodVM/ProvisionUserData
=== RUN TestDebugPodVM/SystemdServices
=== RUN TestDebugPodVM/SystemdServices/ProcessUserData
=== PAUSE TestDebugPodVM/SystemdServices/ProcessUserData
=== RUN TestDebugPodVM/SystemdServices/AttestationAgent
=== PAUSE TestDebugPodVM/SystemdServices/AttestationAgent
=== RUN TestDebugPodVM/SystemdServices/ConfidentialDataHub
=== PAUSE TestDebugPodVM/SystemdServices/ConfidentialDataHub
=== RUN TestDebugPodVM/SystemdServices/APIServerREST
=== PAUSE TestDebugPodVM/SystemdServices/APIServerREST
=== RUN TestDebugPodVM/SystemdServices/KataAgent
=== PAUSE TestDebugPodVM/SystemdServices/KataAgent
=== CONT TestDebugPodVM/SystemdServices/ProcessUserData
=== CONT TestDebugPodVM/SystemdServices/KataAgent
=== CONT TestDebugPodVM/SystemdServices/APIServerREST
=== CONT TestDebugPodVM/SystemdServices/ConfidentialDataHub
=== CONT TestDebugPodVM/SystemdServices/AttestationAgent
=== RUN TestDebugPodVM/ForwarderMutualTLS
=== RUN TestDebugPodVM/KataAgentHealth
=== RUN TestDebugPodVM/SandboxLifecycle
=== RUN TestDebugPodVM/SandboxLifecycle/LaunchContainers
=== RUN TestDebugPodVM/SandboxLifecycle/LaunchContainers/Message
=== RUN TestDebugPodVM/SandboxLifecycle/LaunchContainers/GetEvidence
--- PASS: TestDebugPodVM (46.74s)
--- PASS: TestDebugPodVM/ExecuteCommandOverVSock (0.27s)
--- PASS: TestDebugPodVM/ProvisionUserData (0.49s)
--- PASS: TestDebugPodVM/SystemdServices (0.00s)
--- PASS: TestDebugPodVM/SystemdServices/ProcessUserData (3.08s)
--- PASS: TestDebugPodVM/SystemdServices/APIServerREST (3.13s)
--- PASS: TestDebugPodVM/SystemdServices/ConfidentialDataHub (3.16s)
--- PASS: TestDebugPodVM/SystemdServices/KataAgent (3.19s)
--- PASS: TestDebugPodVM/SystemdServices/AttestationAgent (2.30s)
--- PASS: TestDebugPodVM/ForwarderMutualTLS (0.04s)
--- PASS: TestDebugPodVM/KataAgentHealth (0.03s)
--- PASS: TestDebugPodVM/SandboxLifecycle (3.50s)
--- PASS: TestDebugPodVM/SandboxLifecycle/LaunchContainers (3.43s)
--- PASS: TestDebugPodVM/SandboxLifecycle/LaunchContainers/Message (2.22s)
--- PASS: TestDebugPodVM/SandboxLifecycle/LaunchContainers/GetEvidence (1.22s)
PASS
ok github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/podvm 46.765s
root@sh-dev1:~/go/src/github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor# free
total used free shared buff/cache available
Mem: 8131792 1818872 3192632 2652 3436376 6312920
Swap: 2097148 36640 2060508
root@sh-dev1:~/go/src/github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor# sudo env "PATH=$PATH" "MKOSI_VERSION=$MKOSI_VERSION" make test-podvm TEST_PODVM_IMAGE=podvm/build/podvm-ubuntu-amd64.qcow2
TEST_PODVM_IMAGE=/root/go/src/github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/podvm/build/podvm-ubuntu-amd64.qcow2 go test -v -timeout 5m -count=1 -run '' ./test/podvm
=== RUN TestDebugPodVM
=== RUN TestDebugPodVM/ExecuteCommandOverVSock
=== RUN TestDebugPodVM/ProvisionUserData
podvm_test.go:116:
Error Trace: /root/go/src/github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/podvm/podvm_test.go:116
Error: Received unexpected error:
wait for provisioned user data: context deadline exceeded (last error: run SSH command: context deadline exceeded)
Test: TestDebugPodVM/ProvisionUserData
=== RUN TestDebugPodVM/SystemdServices
=== RUN TestDebugPodVM/SystemdServices/ProcessUserData
=== PAUSE TestDebugPodVM/SystemdServices/ProcessUserData
=== RUN TestDebugPodVM/SystemdServices/AttestationAgent
=== PAUSE TestDebugPodVM/SystemdServices/AttestationAgent
=== RUN TestDebugPodVM/SystemdServices/ConfidentialDataHub
=== PAUSE TestDebugPodVM/SystemdServices/ConfidentialDataHub
=== RUN TestDebugPodVM/SystemdServices/APIServerREST
=== PAUSE TestDebugPodVM/SystemdServices/APIServerREST
=== RUN TestDebugPodVM/SystemdServices/KataAgent
=== PAUSE TestDebugPodVM/SystemdServices/KataAgent
=== CONT TestDebugPodVM/SystemdServices/ProcessUserData
=== CONT TestDebugPodVM/SystemdServices/APIServerREST
=== CONT TestDebugPodVM/SystemdServices/ConfidentialDataHub
=== CONT TestDebugPodVM/SystemdServices/AttestationAgent
=== CONT TestDebugPodVM/SystemdServices/KataAgent
=== RUN TestDebugPodVM/ForwarderMutualTLS
podvm_test.go:147:
Error Trace: /root/go/src/github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/podvm/podvm_test.go:147
Error: Received unexpected error:
wait for agent protocol forwarder TLS: context deadline exceeded (last error: read tcp 127.0.0.1:39302->127.0.0.1:44195: read: connection reset by peer)
Test: TestDebugPodVM/ForwarderMutualTLS
=== RUN TestDebugPodVM/KataAgentHealth
podvm_test.go:153:
Error Trace: /root/go/src/github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/podvm/podvm_test.go:153
Error: Received unexpected error:
wait for kata agent health: context deadline exceeded (last error: dial tcp 127.0.0.1:44195: i/o timeout)
Test: TestDebugPodVM/KataAgentHealth
=== RUN TestDebugPodVM/SandboxLifecycle
podvm_test.go:161:
Error Trace: /root/go/src/github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/podvm/podvm_test.go:161
Error: Received unexpected error:
read tcp 127.0.0.1:49408->127.0.0.1:44195: read: connection reset by peer
Test: TestDebugPodVM/SandboxLifecycle
--- FAIL: TestDebugPodVM (76.92s)
--- PASS: TestDebugPodVM/ExecuteCommandOverVSock (0.42s)
--- FAIL: TestDebugPodVM/ProvisionUserData (15.10s)
--- PASS: TestDebugPodVM/SystemdServices (0.00s)
--- PASS: TestDebugPodVM/SystemdServices/APIServerREST (2.47s)
--- PASS: TestDebugPodVM/SystemdServices/ProcessUserData (2.49s)
--- PASS: TestDebugPodVM/SystemdServices/AttestationAgent (2.56s)
--- PASS: TestDebugPodVM/SystemdServices/ConfidentialDataHub (2.56s)
--- PASS: TestDebugPodVM/SystemdServices/KataAgent (2.31s)
--- FAIL: TestDebugPodVM/ForwarderMutualTLS (10.00s)
--- FAIL: TestDebugPodVM/KataAgentHealth (10.00s)
--- FAIL: TestDebugPodVM/SandboxLifecycle (0.00s)
FAIL
FAIL github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/podvm 76.947s
FAIL
If I don't meet the system requirements with this VM then I don't want to block this, but shared it in case it's helpful
For reference I ran it on a 4 vCPU, 8GB RAM VM. I've updating to the latest code and re-ran twice and got passing first time, failing second:
> If I don't meet the system requirements with this VM then I don't want to block this, but shared it in case it's helpful
no, it's good, I suspect low specs surface a race that we have with the config disk in general. (it should not allow to continue if it fails to mount the config disk). I cannot reproduce it reliably locally and I have only seen it once on the CI either, maybe I should limit the specs for a repro.
The tests seem to run reliable now (configured to run 20 times), so I'm somewhat confident that issues are either identified or addressed.
putting this back to draft for now until at least #3367 is resolved, there is also an ttrpc issue on shutdown that already bit us elsewhere, but we can ignore it for now I think.
mkulke
This adds a programmatic test suite, like the e2e test suite, but scoped to testing the PodVM surface. It doesn't require a K8S or CAA deployment and its goal is to improve the debug cycle for development on PodVM features and to avoid runnign costly full e2e-suite runs. A successful run should take less than 30s.
The current test will use ssh-over-vsock and thus require a debug image for testing. An SSH key is injected via systemd+SMBIOS and the TLS key material is provided via the cloud-disk, so no customization is needed.
Tests assert that the various systemd units are active and not flapping (there is a recheck w/ a correlation id after 2s).
The ttrpc api is used to create a Sandbox and a small container payload. A container is using api-server-rest to retrieve evidence via the sample attester, hereby exercising various services in the podvm.
Currently the tests are limited to x86_64, but I think they can be adapted to other archs rather easily.