mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-04 10:24:37 +00:00
Merge pull request #11519 from wainersm/tests_teardown_common
tests/k8s: instrument some tests for debugging
This commit is contained in:
@@ -6,16 +6,19 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
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() {
|
||||||
[ "${KATA_HYPERVISOR}" == "firecracker" ] && skip "test not working see: ${fc_limitations}"
|
[ "${KATA_HYPERVISOR}" == "firecracker" ] && skip "test not working see: ${fc_limitations}"
|
||||||
[ "${KATA_HYPERVISOR}" == "fc" ] && skip "test not working see: ${fc_limitations}"
|
[ "${KATA_HYPERVISOR}" == "fc" ] && skip "test not working see: ${fc_limitations}"
|
||||||
|
|
||||||
|
setup_common
|
||||||
get_pod_config_dir
|
get_pod_config_dir
|
||||||
|
|
||||||
# Add policy to pod-secret.yaml.
|
# Add policy to pod-secret.yaml.
|
||||||
pod_yaml_file="${pod_config_dir}/pod-secret.yaml"
|
pod_yaml_file="${pod_config_dir}/pod-secret.yaml"
|
||||||
|
set_node "$pod_yaml_file" "$node"
|
||||||
pod_cmd="ls /tmp/secret-volume"
|
pod_cmd="ls /tmp/secret-volume"
|
||||||
pod_exec_command=(sh -c "${pod_cmd}")
|
pod_exec_command=(sh -c "${pod_cmd}")
|
||||||
pod_policy_settings_dir="$(create_tmp_policy_settings_dir "${pod_config_dir}")"
|
pod_policy_settings_dir="$(create_tmp_policy_settings_dir "${pod_config_dir}")"
|
||||||
@@ -28,6 +31,7 @@ setup() {
|
|||||||
# TODO: auto-generate policy for this pod YAML after solving
|
# TODO: auto-generate policy for this pod YAML after solving
|
||||||
# https://github.com/kata-containers/kata-containers/issues/10033
|
# https://github.com/kata-containers/kata-containers/issues/10033
|
||||||
pod_env_yaml_file="${pod_config_dir}/pod-secret-env.yaml"
|
pod_env_yaml_file="${pod_config_dir}/pod-secret-env.yaml"
|
||||||
|
set_node "$pod_env_yaml_file" "$node"
|
||||||
pod_env_cmd="printenv"
|
pod_env_cmd="printenv"
|
||||||
pod_env_exec_command=(sh -c "${pod_env_cmd}")
|
pod_env_exec_command=(sh -c "${pod_env_cmd}")
|
||||||
add_allow_all_policy_to_yaml "${pod_env_yaml_file}"
|
add_allow_all_policy_to_yaml "${pod_env_yaml_file}"
|
||||||
@@ -69,12 +73,9 @@ teardown() {
|
|||||||
[ "${KATA_HYPERVISOR}" == "firecracker" ] && skip "test not working see: ${fc_limitations}"
|
[ "${KATA_HYPERVISOR}" == "firecracker" ] && skip "test not working see: ${fc_limitations}"
|
||||||
[ "${KATA_HYPERVISOR}" == "fc" ] && skip "test not working see: ${fc_limitations}"
|
[ "${KATA_HYPERVISOR}" == "fc" ] && skip "test not working see: ${fc_limitations}"
|
||||||
|
|
||||||
# Debugging information
|
|
||||||
kubectl describe "pod/$pod_name"
|
|
||||||
kubectl describe "pod/$second_pod_name"
|
|
||||||
|
|
||||||
kubectl delete pod "$pod_name" "$second_pod_name"
|
|
||||||
kubectl delete secret "$secret_name"
|
kubectl delete secret "$secret_name"
|
||||||
|
|
||||||
delete_tmp_policy_settings_dir "${pod_policy_settings_dir}"
|
delete_tmp_policy_settings_dir "${pod_policy_settings_dir}"
|
||||||
|
|
||||||
|
teardown_common "${node}" "${node_start_time:-}"
|
||||||
}
|
}
|
||||||
|
@@ -6,9 +6,11 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
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() {
|
||||||
|
setup_common
|
||||||
get_pod_config_dir
|
get_pod_config_dir
|
||||||
job_name="jobtest"
|
job_name="jobtest"
|
||||||
names=( "test1" "test2" "test3" )
|
names=( "test1" "test2" "test3" )
|
||||||
@@ -21,6 +23,7 @@ setup() {
|
|||||||
for i in "${names[@]}"; do
|
for i in "${names[@]}"; do
|
||||||
yaml_file="${pod_config_dir}/job-$i.yaml"
|
yaml_file="${pod_config_dir}/job-$i.yaml"
|
||||||
sed "s/\$ITEM/$i/" ${pod_config_dir}/job-template.yaml > ${yaml_file}
|
sed "s/\$ITEM/$i/" ${pod_config_dir}/job-template.yaml > ${yaml_file}
|
||||||
|
set_node "$yaml_file" "$node"
|
||||||
auto_generate_policy "${policy_settings_dir}" "${yaml_file}"
|
auto_generate_policy "${policy_settings_dir}" "${yaml_file}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -44,13 +47,15 @@ setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
teardown() {
|
teardown() {
|
||||||
# Delete jobs
|
|
||||||
kubectl delete jobs -l jobgroup=${job_name}
|
|
||||||
|
|
||||||
# Remove generated yaml files
|
# Remove generated yaml files
|
||||||
for i in "${names[@]}"; do
|
for i in "${names[@]}"; do
|
||||||
rm -f ${pod_config_dir}/job-$i.yaml
|
rm -f ${pod_config_dir}/job-$i.yaml
|
||||||
done
|
done
|
||||||
|
|
||||||
delete_tmp_policy_settings_dir "${policy_settings_dir}"
|
delete_tmp_policy_settings_dir "${policy_settings_dir}"
|
||||||
|
|
||||||
|
teardown_common
|
||||||
|
|
||||||
|
# Delete jobs
|
||||||
|
kubectl delete jobs -l jobgroup=${job_name}
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
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() {
|
||||||
@@ -14,11 +15,13 @@ setup() {
|
|||||||
[ "${KATA_HYPERVISOR}" = "qemu-runtime-rs" ] && skip "Requires CPU hotplug which isn't supported on ${KATA_HYPERVISOR} yet"
|
[ "${KATA_HYPERVISOR}" = "qemu-runtime-rs" ] && skip "Requires CPU hotplug which isn't supported on ${KATA_HYPERVISOR} yet"
|
||||||
[ "$(uname -m)" == "aarch64" ] && skip "See: https://github.com/kata-containers/kata-containers/issues/10928"
|
[ "$(uname -m)" == "aarch64" ] && skip "See: https://github.com/kata-containers/kata-containers/issues/10928"
|
||||||
|
|
||||||
|
setup_common
|
||||||
get_pod_config_dir
|
get_pod_config_dir
|
||||||
pods=( "vcpus-less-than-one-with-no-limits" "vcpus-less-than-one-with-limits" "vcpus-more-than-one-with-limits" )
|
pods=( "vcpus-less-than-one-with-no-limits" "vcpus-less-than-one-with-limits" "vcpus-more-than-one-with-limits" )
|
||||||
expected_vcpus=( 1 1 2 )
|
expected_vcpus=( 1 1 2 )
|
||||||
|
|
||||||
yaml_file="${pod_config_dir}/pod-sandbox-vcpus-allocation.yaml"
|
yaml_file="${pod_config_dir}/pod-sandbox-vcpus-allocation.yaml"
|
||||||
|
set_node "$yaml_file" "$node"
|
||||||
add_allow_all_policy_to_yaml "${yaml_file}"
|
add_allow_all_policy_to_yaml "${yaml_file}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,5 +48,5 @@ teardown() {
|
|||||||
kubectl logs ${pod}
|
kubectl logs ${pod}
|
||||||
done
|
done
|
||||||
|
|
||||||
kubectl delete -f "${yaml_file}"
|
teardown_common "${node}" "${node_start_time:-}"
|
||||||
}
|
}
|
||||||
|
@@ -340,10 +340,19 @@ set_container_command() {
|
|||||||
set_node() {
|
set_node() {
|
||||||
local yaml="$1"
|
local yaml="$1"
|
||||||
local node="$2"
|
local node="$2"
|
||||||
|
local kind
|
||||||
|
local spec
|
||||||
[ -n "$node" ] || return 1
|
[ -n "$node" ] || return 1
|
||||||
|
|
||||||
|
kind="$(yq -r '.kind' "${yaml}")"
|
||||||
|
if [[ "${kind}" = "Job" ]]; then
|
||||||
|
spec=".spec.template.spec.nodeName"
|
||||||
|
else
|
||||||
|
spec=".spec.nodeName"
|
||||||
|
fi
|
||||||
|
|
||||||
yq -i \
|
yq -i \
|
||||||
".spec.nodeName = \"$node\"" \
|
"${spec} = \"$node\"" \
|
||||||
"${yaml}"
|
"${yaml}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user