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 fi
} }
# Common setup for confidential tests. # Common check for confidential tests.
function confidential_setup() { function is_confidential_runtime_class() {
ensure_yq ensure_yq
if ! check_hypervisor_for_confidential_tests "${KATA_HYPERVISOR}"; then if check_hypervisor_for_confidential_tests "${KATA_HYPERVISOR}"; then
return 1 return 0
fi fi
return 1
} }

View File

@ -15,7 +15,7 @@ export KATA_HYPERVISOR="${KATA_HYPERVISOR:-qemu}"
export AA_KBC="${AA_KBC:-cc_kbc}" export AA_KBC="${AA_KBC:-cc_kbc}"
setup() { 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 if [ "${KBS}" = "false" ]; then
skip "Test skipped as KBS not setup" skip "Test skipped as KBS not setup"
@ -82,7 +82,7 @@ setup() {
} }
teardown() { 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 if [ "${KBS}" = "false" ]; then
skip "Test skipped as KBS not setup" 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" load "${BATS_TEST_DIRNAME}/tests_common.sh"
setup() { 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 setup_unencrypted_confidential_pod
} }
@ -41,7 +43,9 @@ setup() {
} }
teardown() { 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 describe "pod/${pod_name}" || true
kubectl delete -f "${pod_config_dir}/pod-confidential-unencrypted.yaml" || 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" load "${BATS_TEST_DIRNAME}/confidential_common.sh"
setup() { 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" [ "${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" { @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 # 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, # 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() { 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" [ "${SNAPSHOTTER:-}" = "nydus" ] || skip "None snapshotter was found but this test requires one"