github.com/kata-containers/tests@v0.0.0-20240307153542-772105b56064/integration/kubernetes/k8s-env.bats (about) 1 #!/usr/bin/env bats 2 # 3 # Copyright (c) 2018 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="test-env" 13 get_pod_config_dir 14 } 15 16 @test "Environment variables" { 17 # Create pod 18 kubectl create -f "${pod_config_dir}/pod-env.yaml" 19 20 # Check pod creation 21 kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name" 22 23 # Print environment variables 24 cmd="printenv" 25 kubectl exec $pod_name -- sh -c $cmd | grep "MY_POD_NAME=$pod_name" 26 kubectl exec $pod_name -- sh -c $cmd | \ 27 grep "HOST_IP=\([0-9]\+\(\.\|$\)\)\{4\}" 28 # Requested 32Mi of memory 29 kubectl exec $pod_name -- sh -c $cmd | \ 30 grep "MEMORY_REQUESTS=$((1024 * 1024 * 32))" 31 # Memory limits allocated by the node 32 kubectl exec $pod_name -- sh -c $cmd | grep "MEMORY_LIMITS=[1-9]\+" 33 } 34 35 teardown() { 36 # Debugging information 37 kubectl describe "pod/$pod_name" 38 39 kubectl delete pod "$pod_name" 40 }