tests: Add a simple test to check the VMM vcpu allocation

As we've done some changes in the VMM vcpu allocation, let's introduce
basic tests to make sure that we're getting the expected behaviour.

The test consists in checking 3 scenarios:
* default_vcpus = 0 | no limits set
  * this should allocate 1 vcpu
* default_vcpus = 0.75 | limits set to 0.25
  * this should allocate 1 vcpu
* default_vcpus = 0.75 | limits set to 1.2
  * this should allocate 2 vcpus

The tests are very basic, but they do ensure we're rounding things up to
what the new logic is supposed to do.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
Fabiano Fidêncio
2023-11-09 21:59:59 +01:00
parent 5e9cf75937
commit 849253e55c
4 changed files with 98 additions and 1 deletions

View File

@@ -0,0 +1,54 @@
#
# Copyright (c) 2023 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
---
apiVersion: v1
kind: Pod
metadata:
name: vcpus-less-than-one-with-no-limits
annotations:
io.katacontainers.config.hypervisor.default_vcpus: "0"
spec:
runtimeClassName: kata
containers:
- name: vcpus-less-than-one-with-no-limits
image: quay.io/prometheus/busybox:latest
command: ['nproc', '--all']
restartPolicy: Never
---
apiVersion: v1
kind: Pod
metadata:
name: vcpus-less-than-one-with-limits
annotations:
io.katacontainers.config.hypervisor.default_vcpus: "0.75"
spec:
runtimeClassName: kata
containers:
- name: vcpus-less-than-one-with-limits
image: quay.io/prometheus/busybox:latest
resources:
limits:
cpu: "0.25"
command: ['nproc', '--all']
restartPolicy: Never
---
apiVersion: v1
kind: Pod
metadata:
name: vcpus-more-than-one-with-limits
annotations:
io.katacontainers.config.hypervisor.default_vcpus: "0.75"
spec:
runtimeClassName: kata
containers:
- name: vcpus-more-than-one-with-limits
image: quay.io/prometheus/busybox:latest
resources:
limits:
cpu: "1.2"
command: ['nproc', '--all']
restartPolicy: Never
---