mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-19 12:14:11 +00:00
tests: Add k8s-file-volume test
This imports the k8s-file-volume test from the tests repo and modifies it slightly to set up the host volume on the AKS host. Signed-off-by: Aurélien Bombo <abombo@microsoft.com>
This commit is contained in:
parent
187a72d381
commit
6222bd9103
47
tests/integration/kubernetes/k8s-file-volume.bats
Normal file
47
tests/integration/kubernetes/k8s-file-volume.bats
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
#
|
||||||
|
# Copyright (c) 2022 Ant Group
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
load "${BATS_TEST_DIRNAME}/../../common.bash"
|
||||||
|
load "${BATS_TEST_DIRNAME}/tests_common.sh"
|
||||||
|
TEST_INITRD="${TEST_INITRD:-no}"
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
[ "${KATA_HYPERVISOR}" == "firecracker" ] && skip "test not working see: ${fc_limitations}"
|
||||||
|
pod_name="test-file-volume"
|
||||||
|
container_name="busybox-file-volume-container"
|
||||||
|
tmp_file=$(exec_host mktemp /tmp/file-volume-test-foo.XXXXX)
|
||||||
|
mount_path="/tmp/foo.txt"
|
||||||
|
file_body="test"
|
||||||
|
get_pod_config_dir
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "Test readonly volume for pods" {
|
||||||
|
[ "${KATA_HYPERVISOR}" == "firecracker" ] && skip "test not working see: ${fc_limitations}"
|
||||||
|
# Write test body to temp file
|
||||||
|
exec_host "echo "$file_body" > $tmp_file"
|
||||||
|
|
||||||
|
# Create test yaml
|
||||||
|
sed -e "s|HOST_FILE|$tmp_file|" ${pod_config_dir}/pod-file-volume.yaml > ${pod_config_dir}/test-pod-file-volume.yaml
|
||||||
|
sed -i "s|MOUNT_PATH|$mount_path|" ${pod_config_dir}/test-pod-file-volume.yaml
|
||||||
|
|
||||||
|
# Create pod
|
||||||
|
kubectl create -f "${pod_config_dir}/test-pod-file-volume.yaml"
|
||||||
|
|
||||||
|
# Check pod creation
|
||||||
|
kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name"
|
||||||
|
|
||||||
|
# Validate file volume body inside the pod
|
||||||
|
file_in_container=$(kubectl exec $pod_name -- cat $mount_path)
|
||||||
|
[ "$file_body" == "$file_in_container" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
[ "${KATA_HYPERVISOR}" == "firecracker" ] && skip "test not working see: ${fc_limitations}"
|
||||||
|
kubectl delete pod "$pod_name"
|
||||||
|
exec_host rm -f $tmp_file
|
||||||
|
rm -f ${pod_config_dir}/test-pod-file-volume.yaml.yaml
|
||||||
|
}
|
@ -28,6 +28,7 @@ else
|
|||||||
"k8s-empty-dirs.bats" \
|
"k8s-empty-dirs.bats" \
|
||||||
"k8s-env.bats" \
|
"k8s-env.bats" \
|
||||||
"k8s-exec.bats" \
|
"k8s-exec.bats" \
|
||||||
|
"k8s-file-volume.bats" \
|
||||||
"k8s-inotify.bats" \
|
"k8s-inotify.bats" \
|
||||||
"k8s-job.bats" \
|
"k8s-job.bats" \
|
||||||
"k8s-kill-all-process-in-container.bats" \
|
"k8s-kill-all-process-in-container.bats" \
|
||||||
|
Loading…
Reference in New Issue
Block a user