github.com/kata-containers/tests@v0.0.0-20240307153542-772105b56064/integration/kubernetes/k8s-sysctls.bats (about)

     1  #!/usr/bin/env bats
     2  #
     3  # Copyright (c) 2019 Intel 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="sysctl-test"
    13  	get_pod_config_dir
    14  }
    15  
    16  @test "Setting sysctl" {
    17  	# Create pod
    18  	kubectl apply -f "${pod_config_dir}/pod-sysctl.yaml"
    19  
    20  	# Check pod creation
    21  	kubectl wait --for=condition=Ready --timeout=$timeout pod $pod_name
    22  
    23  	# Check sysctl configuration
    24  	cmd="cat /proc/sys/kernel/shm_rmid_forced"
    25  	result=$(kubectl exec $pod_name -- sh -c "$cmd")
    26  	[ "${result}" = 0 ]
    27  }
    28  
    29  teardown() {
    30  	# Debugging information
    31  	kubectl describe "pod/$pod_name"
    32  
    33  	kubectl delete pod "$pod_name"
    34  }