github.com/dmaizel/tests@v0.0.0-20210728163746-cae6a2d9cee8/integration/kubernetes/k8s-projected-volume.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 fc_limitations="https://github.com/kata-containers/documentation/issues/351" 11 12 setup() { 13 [ "${KATA_HYPERVISOR}" == "firecracker" ] && skip "test not working see: ${fc_limitations}" 14 15 export KUBECONFIG="${KUBECONFIG:-$HOME/.kube/config}" 16 get_pod_config_dir 17 } 18 19 @test "Projected volume" { 20 [ "${KATA_HYPERVISOR}" == "firecracker" ] && skip "test not working see: ${fc_limitations}" 21 22 password="1f2d1e2e67df" 23 username="admin" 24 pod_name="test-projected-volume" 25 26 TMP_FILE=$(mktemp username.XXXX) 27 SECOND_TMP_FILE=$(mktemp password.XXXX) 28 29 # Create files containing the username and password 30 echo "$username" > $TMP_FILE 31 echo "$password" > $SECOND_TMP_FILE 32 33 # Package these files into secrets 34 kubectl create secret generic user --from-file=$TMP_FILE 35 kubectl create secret generic pass --from-file=$SECOND_TMP_FILE 36 37 # Create pod 38 kubectl create -f "${pod_config_dir}/pod-projected-volume.yaml" 39 40 # Check pod creation 41 kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name" 42 43 # Check that the projected sources exists 44 cmd="ls /projected-volume | grep username" 45 kubectl exec $pod_name -- sh -c "$cmd" 46 sec_cmd="ls /projected-volume | grep password" 47 kubectl exec $pod_name -- sh -c "$sec_cmd" 48 49 # Check content of the projected sources 50 check_cmd="cat /projected-volume/username*" 51 kubectl exec $pod_name -- sh -c "$check_cmd" | grep "$username" 52 sec_check_cmd="cat /projected-volume/password*" 53 kubectl exec $pod_name -- sh -c "$sec_check_cmd" | grep "$password" 54 } 55 56 teardown() { 57 [ "${KATA_HYPERVISOR}" == "firecracker" ] && skip "test not working see: ${fc_limitations}" 58 59 # Debugging information 60 kubectl describe "pod/$pod_name" 61 62 rm -f $TMP_FILE $SECOND_TMP_FILE 63 kubectl delete pod "$pod_name" 64 kubectl delete secret pass user 65 }