tests: Re-work confidential_setup()

Let's rename it to `is_confidential_runtime_class`, and adapt all the
places where it's called.

The new name provides a better description, leading to a better
understanding of what the function really does.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
Fabiano Fidêncio 2024-05-09 11:53:39 +02:00
parent 9a6d8d8330
commit 4a04a1f2ae
No known key found for this signature in database
GPG Key ID: EE926C2BDACC177B
4 changed files with 24 additions and 12 deletions

View File

@ -52,10 +52,12 @@ function check_hypervisor_for_confidential_tests() {
fi
}
# Common setup for confidential tests.
function confidential_setup() {
# Common check for confidential tests.
function is_confidential_runtime_class() {
ensure_yq
if ! check_hypervisor_for_confidential_tests "${KATA_HYPERVISOR}"; then
return 1
fi
if check_hypervisor_for_confidential_tests "${KATA_HYPERVISOR}"; then
return 0
fi
return 1
}

View File

@ -15,7 +15,7 @@ export KATA_HYPERVISOR="${KATA_HYPERVISOR:-qemu}"
export AA_KBC="${AA_KBC:-cc_kbc}"
setup() {
confidential_setup || skip "Test not supported for ${KATA_HYPERVISOR}."
is_confidential_runtime_class || skip "Test not supported for ${KATA_HYPERVISOR}."
if [ "${KBS}" = "false" ]; then
skip "Test skipped as KBS not setup"
@ -82,7 +82,7 @@ setup() {
}
teardown() {
check_hypervisor_for_confidential_tests ${KATA_HYPERVISOR} || skip "Test not supported for ${KATA_HYPERVISOR}."
is_confidential_runtime_class || skip "Test not supported for ${KATA_HYPERVISOR}."
if [ "${KBS}" = "false" ]; then
skip "Test skipped as KBS not setup"

View File

@ -10,7 +10,9 @@ load "${BATS_TEST_DIRNAME}/confidential_common.sh"
load "${BATS_TEST_DIRNAME}/tests_common.sh"
setup() {
confidential_setup || skip "Test not supported for ${KATA_HYPERVISOR}."
if ! is_confidential_runtime_class; then
skip "Test not supported for ${KATA_HYPERVISOR}."
fi
setup_unencrypted_confidential_pod
}
@ -41,7 +43,9 @@ setup() {
}
teardown() {
check_hypervisor_for_confidential_tests ${KATA_HYPERVISOR} || skip "Test not supported for ${KATA_HYPERVISOR}."
if ! is_confidential_runtime_class; then
skip "Test not supported for ${KATA_HYPERVISOR}."
fi
kubectl describe "pod/${pod_name}" || true
kubectl delete -f "${pod_config_dir}/pod-confidential-unencrypted.yaml" || true

View File

@ -9,7 +9,9 @@ load "${BATS_TEST_DIRNAME}/lib.sh"
load "${BATS_TEST_DIRNAME}/confidential_common.sh"
setup() {
confidential_setup && skip "Due to issues related to pull-image integration skip tests for ${KATA_HYPERVISOR}."
if is_confidential_runtime_class; then
skip "Due to issues related to pull-image integration skip tests for ${KATA_HYPERVISOR}."
fi
[ "${SNAPSHOTTER:-}" = "nydus" ] || skip "None snapshotter was found but this test requires one"
@ -20,7 +22,9 @@ setup() {
}
@test "Test we can pull an unencrypted image outside the guest with runc and then inside the guest successfully" {
confidential_setup && skip "Due to issues related to pull-image integration skip tests for ${KATA_HYPERVISOR}."
if is_confidential_runtime_class; then
skip "Due to issues related to pull-image integration skip tests for ${KATA_HYPERVISOR}."
fi
# 1. Create one runc pod with the $unencrypted_image_1 image
# We want to have one runc pod, so we pass a fake runtimeclass "runc" and then delete the runtimeClassName,
@ -216,7 +220,9 @@ setup() {
}
teardown() {
confidential_setup && skip "Due to issues related to pull-image integration skip tests for ${KATA_HYPERVISOR}."
if is_confidential_runtime_class; then
skip "Due to issues related to pull-image integration skip tests for ${KATA_HYPERVISOR}."
fi
[ "${SNAPSHOTTER:-}" = "nydus" ] || skip "None snapshotter was found but this test requires one"