mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-12 13:22:28 +00:00
There's absolutely no need to have the skip check as part of the test
itself when it's already done as part of the setup function.
We're only touching the files here that were touched in the previous
commit.
Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
(cherry picked from commit f6cd3930c5
)
64 lines
1.8 KiB
Bash
64 lines
1.8 KiB
Bash
#!/usr/bin/env bats
|
|
#
|
|
# Copyright (c) 2018 Intel Corporation
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
load "${BATS_TEST_DIRNAME}/../../common.bash"
|
|
load "${BATS_TEST_DIRNAME}/tests_common.sh"
|
|
|
|
setup() {
|
|
[ "${KATA_HYPERVISOR}" == "firecracker" ] && skip "test not working see: ${fc_limitations}"
|
|
[ "${KATA_HYPERVISOR}" == "fc" ] && skip "test not working see: ${fc_limitations}"
|
|
|
|
get_pod_config_dir
|
|
}
|
|
|
|
@test "Projected volume" {
|
|
password="1f2d1e2e67df"
|
|
username="admin"
|
|
pod_name="test-projected-volume"
|
|
|
|
TMP_FILE=$(mktemp username.XXXX)
|
|
SECOND_TMP_FILE=$(mktemp password.XXXX)
|
|
|
|
# Create files containing the username and password
|
|
echo "$username" > $TMP_FILE
|
|
echo "$password" > $SECOND_TMP_FILE
|
|
|
|
# Package these files into secrets
|
|
kubectl create secret generic user --from-file=$TMP_FILE
|
|
kubectl create secret generic pass --from-file=$SECOND_TMP_FILE
|
|
|
|
# Create pod
|
|
kubectl create -f "${pod_config_dir}/pod-projected-volume.yaml"
|
|
|
|
# Check pod creation
|
|
kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name"
|
|
|
|
# Check that the projected sources exists
|
|
cmd="ls /projected-volume | grep username"
|
|
kubectl exec $pod_name -- sh -c "$cmd"
|
|
sec_cmd="ls /projected-volume | grep password"
|
|
kubectl exec $pod_name -- sh -c "$sec_cmd"
|
|
|
|
# Check content of the projected sources
|
|
check_cmd="cat /projected-volume/username*"
|
|
kubectl exec $pod_name -- sh -c "$check_cmd" | grep "$username"
|
|
sec_check_cmd="cat /projected-volume/password*"
|
|
kubectl exec $pod_name -- sh -c "$sec_check_cmd" | grep "$password"
|
|
}
|
|
|
|
teardown() {
|
|
[ "${KATA_HYPERVISOR}" == "firecracker" ] && skip "test not working see: ${fc_limitations}"
|
|
[ "${KATA_HYPERVISOR}" == "fc" ] && skip "test not working see: ${fc_limitations}"
|
|
|
|
# Debugging information
|
|
kubectl describe "pod/$pod_name"
|
|
|
|
rm -f $TMP_FILE $SECOND_TMP_FILE
|
|
kubectl delete pod "$pod_name"
|
|
kubectl delete secret pass user
|
|
}
|