github.com/kata-containers/tests@v0.0.0-20240307153542-772105b56064/integration/kubernetes/k8s-shared-volume.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 get_pod_config_dir 13 } 14 15 @test "Containers with shared volume" { 16 pod_name="test-shared-volume" 17 first_container_name="busybox-first-container" 18 second_container_name="busybox-second-container" 19 20 # Create pod 21 kubectl create -f "${pod_config_dir}/pod-shared-volume.yaml" 22 23 # Check pods 24 kubectl wait --for=condition=Ready --timeout=$timeout pod $pod_name 25 26 # Communicate containers 27 cmd="cat /tmp/pod-data" 28 msg="Hello from the $second_container_name" 29 kubectl exec "$pod_name" -c "$first_container_name" -- sh -c "$cmd" | grep "$msg" 30 } 31 32 @test "initContainer with shared volume" { 33 pod_name="initcontainer-shared-volume" 34 last_container="last" 35 36 # Create pod 37 kubectl create -f "${pod_config_dir}/initContainer-shared-volume.yaml" 38 39 # Check pods 40 kubectl wait --for=condition=Ready --timeout=$timeout pod $pod_name 41 42 cmd='test $(cat /volume/initContainer) -lt $(cat /volume/container)' 43 kubectl exec "$pod_name" -c "$last_container" -- sh -c "$cmd" 44 } 45 46 teardown() { 47 # Debugging information 48 kubectl describe "pod/$pod_name" 49 50 kubectl delete pod "$pod_name" 51 }