github.com/kata-containers/tests@v0.0.0-20240307153542-772105b56064/integration/kubernetes/k8s-file-volume.bats (about) 1 #!/usr/bin/env bats 2 # 3 # Copyright (c) 2022 Ant Group 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 [ "${KATA_HYPERVISOR}" == "firecracker" ] && skip "test not working see: ${fc_limitations}" 13 pod_name="test-file-volume" 14 container_name="busybox-file-volume-container" 15 tmp_file=$(mktemp /tmp/file-volume-test-foo.XXXXX) 16 mount_path="/tmp/foo.txt" 17 file_body="test" 18 get_pod_config_dir 19 } 20 21 @test "Test readonly volume for pods" { 22 [ "${KATA_HYPERVISOR}" == "firecracker" ] && skip "test not working see: ${fc_limitations}" 23 # Write test body to temp file 24 echo "$file_body" > $tmp_file 25 26 # Create test yaml 27 sed -e "s|HOST_FILE|$tmp_file|" ${pod_config_dir}/pod-file-volume.yaml > ${pod_config_dir}/test-pod-file-volume.yaml 28 sed -i "s|MOUNT_PATH|$mount_path|" ${pod_config_dir}/test-pod-file-volume.yaml 29 30 # Create pod 31 kubectl create -f "${pod_config_dir}/test-pod-file-volume.yaml" 32 33 # Check pod creation 34 kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name" 35 36 # Validate file volume body inside the pod 37 file_in_container=$(kubectl exec $pod_name -- cat $mount_path) 38 [ "$file_body" == "$file_in_container" ] 39 } 40 41 teardown() { 42 [ "${KATA_HYPERVISOR}" == "firecracker" ] && skip "test not working see: ${fc_limitations}" 43 kubectl delete pod "$pod_name" 44 rm -f $tmp_file 45 rm -f ${pod_config_dir}/test-pod-file-volume.yaml.yaml 46 }