kata-containers/tests/functional/kata-agent-apis/api-tests/test_vm_GuestDetails.bats
Sumedh Alok Sharma c7c811071a agent-ctl: Add option --vm to boot pod VM for testing.
This change introduces a new command line option `--vm`
to boot up a pod VM for testing. The tool connects with
kata agent running inside the VM to send the test commands.
The tool uses `hypervisor` crates from runtime-rs for VM
lifecycle management. Current implementation supports
Qemu & Cloud Hypervisor as VMMs.

In summary:
- tool parses the VMM specific runtime-rs kata config file in
/opt/kata/share/defaults/kata-containers/runtime-rs/*
- prepares and starts a VM using runtime-rs::hypervisor vm APIs
- retrieves agent's server address to setup connection
- tests the requested commands & shutdown the VM

Fixes #11566

Signed-off-by: Sumedh Alok Sharma <sumsharma@microsoft.com>
2025-08-11 11:03:18 +00:00

35 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bats
# Copyright (c) 2024 Microsoft Corporation
#
# SPDX-License-Identifier: Apache-2.0
load "${BATS_TEST_DIRNAME}/../../../common.bash"
load "${BATS_TEST_DIRNAME}/../setup_common.sh"
setup_file() {
info "setup"
sudo rm qmp.sock console.sock || echo "No existing qmp.sock/console.sock"
}
@test "Test GetGuestDetails: Boot qemu pod vm and run GetGuestDetails" {
info "Boot qemu vm, establish connection with agent inside the vm and send GetGuestDetails command"
local cmds=()
cmds+=("--vm qemu -c GetGuestDetails")
run_agent_ctl "${cmds[@]}"
sudo rm qmp.sock console.sock
}
@test "Test GetGuestDetails: Boot cloud hypervisor pod vm and run GetGuestDetails" {
info "Boot cloud hypervisor vm, establish connection with agent inside the vm and send GetGuestDetails command"
local cmds=()
cmds+=("--vm cloud-hypervisor -c GetGuestDetails")
run_agent_ctl "${cmds[@]}"
}
teardown_file() {
info "teardown"
sudo rm -r /run/kata/agent-ctl-testvm || echo "Failed to clean /run/kata/agent-ctl-testvm"
sudo rm -r /run/kata-containers/ || echo "Failed to clean /run/kata-containers"
}