mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 20:24:31 +00:00
tests: run k8s-volume on a given node
This test can give false-positive on a multi-node cluster. Changed it to use the new get_one_kata_node() and the modified exec_host() to run the setup commands on a given node (that has kata installed) and ensure the test pod is scheduled at that same node. Fixes #7619 Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
This commit is contained in:
parent
666993da8d
commit
c30c3ff185
@ -15,13 +15,17 @@ setup() {
|
||||
|
||||
get_pod_config_dir
|
||||
|
||||
tmp_file=$(exec_host mktemp -d /tmp/data.XXXX)
|
||||
node=$(get_one_kata_node)
|
||||
tmp_file=$(exec_host "$node" mktemp -d /tmp/data.XXXX)
|
||||
pv_yaml=$(mktemp --tmpdir pv_config.XXXXXX.yaml)
|
||||
pod_yaml=$(mktemp --tmpdir pod_config.XXXXXX.yaml)
|
||||
msg="Hello from Kubernetes"
|
||||
exec_host "echo $msg > $tmp_file/index.html"
|
||||
exec_host "$node" "echo $msg > $tmp_file/index.html"
|
||||
pod_name="pv-pod"
|
||||
# Define temporary file at yaml
|
||||
sed -e "s|tmp_data|${tmp_file}|g" ${pod_config_dir}/pv-volume.yaml > "$pod_yaml"
|
||||
sed -e "s|tmp_data|${tmp_file}|g" ${pod_config_dir}/pv-volume.yaml > "$pv_yaml"
|
||||
sed -e "s|NODE|${node}|g" "${pod_config_dir}/pv-pod.yaml" > "$pod_yaml"
|
||||
|
||||
}
|
||||
|
||||
@test "Create Persistent Volume" {
|
||||
@ -31,7 +35,7 @@ setup() {
|
||||
volume_claim="pv-claim"
|
||||
|
||||
# Create the persistent volume
|
||||
kubectl create -f "$pod_yaml"
|
||||
kubectl create -f "$pv_yaml"
|
||||
|
||||
# Check the persistent volume is Available
|
||||
cmd="kubectl get pv $volume_name | grep Available"
|
||||
@ -45,7 +49,7 @@ setup() {
|
||||
waitForProcess "$wait_time" "$sleep_time" "$cmd"
|
||||
|
||||
# Create pod
|
||||
kubectl create -f "${pod_config_dir}/pv-pod.yaml"
|
||||
kubectl create -f "$pod_yaml"
|
||||
|
||||
# Check pod creation
|
||||
kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name"
|
||||
@ -62,8 +66,9 @@ teardown() {
|
||||
kubectl describe "pod/$pod_name"
|
||||
|
||||
kubectl delete pod "$pod_name"
|
||||
rm -f "$pod_yaml"
|
||||
kubectl delete pvc "$volume_claim"
|
||||
kubectl delete pv "$volume_name"
|
||||
rm -f "$pod_yaml"
|
||||
exec_host rm -rf "$tmp_file"
|
||||
rm -f "$pv_yaml"
|
||||
exec_host "$node" rm -rf "$tmp_file"
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ metadata:
|
||||
spec:
|
||||
terminationGracePeriodSeconds: 0
|
||||
runtimeClassName: kata
|
||||
nodeName: NODE
|
||||
volumes:
|
||||
- name: pv-storage
|
||||
persistentVolumeClaim:
|
||||
|
Loading…
Reference in New Issue
Block a user