From fa07e9fa44f172a7ad3363c69adbaf230dda85dd Mon Sep 17 00:00:00 2001 From: Takahiro Itazuri Date: Wed, 4 Dec 2024 07:49:40 +0000 Subject: [PATCH] test: Check all vCPUs are oneline As seen in #4925, a bad CPU template made secondary CPUs not come up. To catch similar bugs of CPU templates, check all the vCPUs are online from guests' perspective. Signed-off-by: Takahiro Itazuri --- tests/framework/microvm.py | 1 + .../functional/test_cpu_multiple.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 tests/integration_tests/functional/test_cpu_multiple.py diff --git a/tests/framework/microvm.py b/tests/framework/microvm.py index 300764fae3c..345ef8e11ad 100644 --- a/tests/framework/microvm.py +++ b/tests/framework/microvm.py @@ -938,6 +938,7 @@ def make_snapshot( ssh_key=self.ssh_key, snapshot_type=snapshot_type, meta={ + "vcpus_count": self.vcpus_count, "kernel_file": self.kernel_file, }, ) diff --git a/tests/integration_tests/functional/test_cpu_multiple.py b/tests/integration_tests/functional/test_cpu_multiple.py new file mode 100644 index 00000000000..60b52cd2f9c --- /dev/null +++ b/tests/integration_tests/functional/test_cpu_multiple.py @@ -0,0 +1,19 @@ +# Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +""" +Test all vCPUs are configured correctly and work properly. + +This test suite aims to catch bugs of Firecracker's vCPU configuration and +CPU templates especially under multi-vCPU setup, by checking that all vCPUs +are operating identically, except for the expected differences. +""" + +import pytest + + +def test_all_vcpus_online(uvm_any): + """Check all vCPUs are online inside guest""" + vm = uvm_any + for idx in range(vm.vcpus_count): + assert vm.ssh.check_output(f"cat /sys/devices/system/cpu/cpu{idx}/online").stdout == "1\n"