From 666993da8d75c0c268304442bca82e33ea3e956f Mon Sep 17 00:00:00 2001 From: Wainer dos Santos Moschetta Date: Thu, 10 Aug 2023 18:42:19 -0300 Subject: [PATCH] tests: run k8s-file-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 --- tests/integration/kubernetes/k8s-file-volume.bats | 8 +++++--- .../runtimeclass_workloads/pod-file-volume.yaml | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/integration/kubernetes/k8s-file-volume.bats b/tests/integration/kubernetes/k8s-file-volume.bats index d849db2edd..37ccd85f83 100644 --- a/tests/integration/kubernetes/k8s-file-volume.bats +++ b/tests/integration/kubernetes/k8s-file-volume.bats @@ -14,7 +14,8 @@ setup() { [ "${KATA_HYPERVISOR}" == "fc" ] && 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) + node="$(get_one_kata_node)" + tmp_file=$(exec_host "$node" mktemp /tmp/file-volume-test-foo.XXXXX) mount_path="/tmp/foo.txt" file_body="test" get_pod_config_dir @@ -22,11 +23,12 @@ setup() { @test "Test readonly volume for pods" { # Write test body to temp file - exec_host "echo "$file_body" > $tmp_file" + exec_host "$node" "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 + sed -i "s|NODE|$node|" ${pod_config_dir}/test-pod-file-volume.yaml # Create pod kubectl create -f "${pod_config_dir}/test-pod-file-volume.yaml" @@ -43,6 +45,6 @@ teardown() { [ "${KATA_HYPERVISOR}" == "firecracker" ] && skip "test not working see: ${fc_limitations}" [ "${KATA_HYPERVISOR}" == "fc" ] && skip "test not working see: ${fc_limitations}" kubectl delete pod "$pod_name" - exec_host rm -f $tmp_file + exec_host "$node" rm -f $tmp_file rm -f ${pod_config_dir}/test-pod-file-volume.yaml.yaml } diff --git a/tests/integration/kubernetes/runtimeclass_workloads/pod-file-volume.yaml b/tests/integration/kubernetes/runtimeclass_workloads/pod-file-volume.yaml index 4784b1477c..e7a194f42a 100644 --- a/tests/integration/kubernetes/runtimeclass_workloads/pod-file-volume.yaml +++ b/tests/integration/kubernetes/runtimeclass_workloads/pod-file-volume.yaml @@ -11,6 +11,7 @@ spec: terminationGracePeriodSeconds: 0 runtimeClassName: kata restartPolicy: Never + nodeName: NODE volumes: - name: shared-file hostPath: