github.com/kata-containers/tests@v0.0.0-20240307153542-772105b56064/integration/kubernetes/k8s-kill-all-process-in-container.bats (about)

     1  #!/usr/bin/env bats
     2  #
     3  # Copyright (c) 2022 AntGroup Corporation
     4  #
     5  # SPDX-License-Identifier: Apache-2.0
     6  #
     7  
     8  load "${BATS_TEST_DIRNAME}/../../.ci/lib.sh"
     9  load "${BATS_TEST_DIRNAME}/tests_common.sh"
    10  
    11  setup() {
    12  	pod_name="busybox"
    13  	first_container_name="first-test-container"
    14  
    15  	get_pod_config_dir
    16  }
    17  
    18  @test "Check PID namespaces" {
    19  	# Create the pod
    20  	kubectl create -f "${pod_config_dir}/initcontainer-shareprocesspid.yaml"
    21  
    22  	# Check pod creation
    23  	kubectl wait --for=condition=Ready --timeout=$timeout pod $pod_name
    24  
    25  	# Check PID from first container
    26  	first_pid_container=$(kubectl exec $pod_name -c $first_container_name \
    27  		-- ps | grep "tail" || true)
    28  	# Verify that the tail process didn't exist
    29  	[ -z $first_pid_container ] || die "found processes pid: $first_pid_container" 
    30  }
    31  
    32  teardown() {
    33  	# Debugging information
    34  	kubectl describe "pod/$pod_name"
    35  
    36  	kubectl delete pod "$pod_name"
    37  }