mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-01 07:47:15 +00:00
tests: k8s: k8s-optional-empty-configmap policy
Auto-generate policy for k8s-optional-empty-configmap.bats. Fixes: #9072 Signed-off-by: Dan Mihai <dmihai@microsoft.com>
This commit is contained in:
parent
74a52c6d25
commit
9c164698d3
@ -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}"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user