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