WIP: tests/k8s: call teardown_common in some policy tests

The teardown_common will print the description of the running pods, kill
them all and print the system's syslogs afterwards.

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
This commit is contained in:
stevenhorsman 2025-08-12 11:29:34 +01:00
parent 872a6b30a9
commit 5fbf345544
2 changed files with 13 additions and 6 deletions

View File

@ -6,17 +6,18 @@
# #
load "${BATS_TEST_DIRNAME}/../../common.bash" load "${BATS_TEST_DIRNAME}/../../common.bash"
load "${BATS_TEST_DIRNAME}/lib.sh"
load "${BATS_TEST_DIRNAME}/tests_common.sh" load "${BATS_TEST_DIRNAME}/tests_common.sh"
setup() { setup() {
auto_generate_policy_enabled || skip "Auto-generated policy tests are disabled." auto_generate_policy_enabled || skip "Auto-generated policy tests are disabled."
setup_common
get_pod_config_dir get_pod_config_dir
job_name="policy-job" job_name="policy-job"
correct_yaml="${pod_config_dir}/k8s-policy-job.yaml" correct_yaml="${pod_config_dir}/k8s-policy-job.yaml"
incorrect_yaml="${pod_config_dir}/k8s-policy-job-incorrect.yaml" incorrect_yaml="${pod_config_dir}/k8s-policy-job-incorrect.yaml"
set_node "${correct_yaml}" "${node}"
# Save some time by executing genpolicy a single time. # Save some time by executing genpolicy a single time.
if [ "${BATS_TEST_NUMBER}" == "1" ]; then if [ "${BATS_TEST_NUMBER}" == "1" ]; then
# Add an appropriate policy to the correct YAML file. # Add an appropriate policy to the correct YAML file.
@ -163,4 +164,6 @@ teardown() {
if [ "${BATS_TEST_NUMBER}" == "1" ]; then if [ "${BATS_TEST_NUMBER}" == "1" ]; then
delete_tmp_policy_settings_dir "${policy_settings_dir}" delete_tmp_policy_settings_dir "${policy_settings_dir}"
fi fi
teardown_common "${node}" "${node_start_time:-}"
} }

View File

@ -6,13 +6,14 @@
# #
load "${BATS_TEST_DIRNAME}/../../common.bash" load "${BATS_TEST_DIRNAME}/../../common.bash"
load "${BATS_TEST_DIRNAME}/lib.sh"
load "${BATS_TEST_DIRNAME}/tests_common.sh" load "${BATS_TEST_DIRNAME}/tests_common.sh"
issue="https://github.com/kata-containers/kata-containers/issues/10297" issue="https://github.com/kata-containers/kata-containers/issues/10297"
setup() { setup() {
auto_generate_policy_enabled || skip "Auto-generated policy tests are disabled." auto_generate_policy_enabled || skip "Auto-generated policy tests are disabled."
setup_common
configmap_name="policy-configmap" configmap_name="policy-configmap"
pod_name="policy-pod" pod_name="policy-pod"
priority_class_name="test-high-priority" priority_class_name="test-high-priority"
@ -57,6 +58,9 @@ setup() {
# Also give each testcase a copy of the pre-generated yaml files. # Also give each testcase a copy of the pre-generated yaml files.
cp "${pre_generate_configmap_yaml}" "${testcase_pre_generate_configmap_yaml}" cp "${pre_generate_configmap_yaml}" "${testcase_pre_generate_configmap_yaml}"
cp "${pre_generate_pod_yaml}" "${testcase_pre_generate_pod_yaml}" cp "${pre_generate_pod_yaml}" "${testcase_pre_generate_pod_yaml}"
set_node "${testcase_pre_generate_pod_yaml}" "${node}"
set_node "${correct_pod_yaml}" "${node}"
} }
prometheus_image_supported() { prometheus_image_supported() {