diff --git a/tests/integration/kubernetes/k8s-optional-empty-configmap.bats b/tests/integration/kubernetes/k8s-optional-empty-configmap.bats index 05c779b772..fdf3d77d73 100644 --- a/tests/integration/kubernetes/k8s-optional-empty-configmap.bats +++ b/tests/integration/kubernetes/k8s-optional-empty-configmap.bats @@ -10,6 +10,20 @@ load "${BATS_TEST_DIRNAME}/tests_common.sh" setup() { get_pod_config_dir + + pod_yaml="${pod_config_dir}/pod-optional-empty-configmap.yaml" + policy_settings_dir="$(create_tmp_policy_settings_dir "${pod_config_dir}")" + + empty_command="ls /empty-config" + exec_command="sh -c ${empty_command}" + add_exec_to_policy_settings "${policy_settings_dir}" "${exec_command}" + + optional_command="ls /optional-missing-config" + exec_command="sh -c ${optional_command}" + add_exec_to_policy_settings "${policy_settings_dir}" "${exec_command}" + + add_requests_to_policy_settings "${policy_settings_dir}" "ReadStreamRequest" + auto_generate_policy "${policy_settings_dir}" "${pod_yaml}" } @test "Optional and Empty ConfigMap Volume for a pod" { @@ -20,13 +34,13 @@ setup() { kubectl create configmap "$config_name" # Create a pod that consumes the "empty-config" and "optional-missing-config" ConfigMaps as volumes - kubectl create -f "${pod_config_dir}/pod-optional-empty-configmap.yaml" + kubectl create -f "${pod_yaml}" # Check pod creation kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name" # Check configmap folders exist - kubectl exec $pod_name -- sh -c ls /empty-config + kubectl exec $pod_name -- sh -c "${empty_command}" kubectl exec $pod_name -- sh -c ls /optional-missing-config } @@ -36,4 +50,6 @@ teardown() { kubectl delete pod "$pod_name" kubectl delete configmap "$config_name" + + delete_tmp_policy_settings_dir "${policy_settings_dir}" }