mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-28 16:27:50 +00:00
tests: k8s-kill-all-process-in-container policy
Auto-generate policy for k8s-kill-all-process-in-container.bats. Fixes: #9072 Signed-off-by: Dan Mihai <dmihai@microsoft.com>
This commit is contained in:
parent
fad7ba0aea
commit
6e14ce93c9
@ -13,18 +13,27 @@ setup() {
|
|||||||
first_container_name="first-test-container"
|
first_container_name="first-test-container"
|
||||||
|
|
||||||
get_pod_config_dir
|
get_pod_config_dir
|
||||||
|
yaml_file="${pod_config_dir}/initcontainer-shareprocesspid.yaml"
|
||||||
|
|
||||||
|
policy_settings_dir="$(create_tmp_policy_settings_dir "${pod_config_dir}")"
|
||||||
|
|
||||||
|
command="ps"
|
||||||
|
add_exec_to_policy_settings "${policy_settings_dir}" "${command}"
|
||||||
|
|
||||||
|
add_requests_to_policy_settings "${policy_settings_dir}" "ReadStreamRequest"
|
||||||
|
auto_generate_policy "${policy_settings_dir}" "${yaml_file}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "Kill all processes in container" {
|
@test "Kill all processes in container" {
|
||||||
# Create the pod
|
# Create the pod
|
||||||
kubectl create -f "${pod_config_dir}/initcontainer-shareprocesspid.yaml"
|
kubectl create -f "${yaml_file}"
|
||||||
|
|
||||||
# Check pod creation
|
# Check pod creation
|
||||||
kubectl wait --for=condition=Ready --timeout=$timeout pod $pod_name
|
kubectl wait --for=condition=Ready --timeout=$timeout pod $pod_name
|
||||||
|
|
||||||
# Check PID from first container
|
# Check PID from first container
|
||||||
first_pid_container=$(kubectl exec $pod_name -c $first_container_name \
|
first_pid_container=$(kubectl exec $pod_name -c $first_container_name \
|
||||||
-- ps | grep "tail" || true)
|
-- $command | grep "tail" || true)
|
||||||
# Verify that the tail process didn't exist
|
# Verify that the tail process didn't exist
|
||||||
[ -z $first_pid_container ] || die "found processes pid: $first_pid_container"
|
[ -z $first_pid_container ] || die "found processes pid: $first_pid_container"
|
||||||
}
|
}
|
||||||
@ -34,4 +43,6 @@ teardown() {
|
|||||||
kubectl describe "pod/$pod_name"
|
kubectl describe "pod/$pod_name"
|
||||||
|
|
||||||
kubectl delete pod "$pod_name"
|
kubectl delete pod "$pod_name"
|
||||||
|
|
||||||
|
delete_tmp_policy_settings_dir "${policy_settings_dir}"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user