mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-17 08:53:26 +00:00
tests: k8s: k8s-configmap auto-generated policy
Auto-generate policy for k8s-configmap.bats. Fixes: #9072 Signed-off-by: Dan Mihai <dmihai@microsoft.com>
This commit is contained in:
parent
b318535536
commit
d3d27bbb5b
@ -10,6 +10,17 @@ load "${BATS_TEST_DIRNAME}/tests_common.sh"
|
||||
|
||||
setup() {
|
||||
get_pod_config_dir
|
||||
policy_settings_dir="$(create_tmp_policy_settings_dir "${pod_config_dir}")"
|
||||
|
||||
cmd="env"
|
||||
exec_command="sh -c ${cmd}"
|
||||
add_exec_to_policy_settings "${policy_settings_dir}" "${exec_command}"
|
||||
add_requests_to_policy_settings "${policy_settings_dir}" "ReadStreamRequest"
|
||||
|
||||
configmap_yaml_file="${pod_config_dir}/configmap.yaml"
|
||||
pod_yaml_file="${pod_config_dir}/pod-configmap.yaml"
|
||||
|
||||
auto_generate_policy "${policy_settings_dir}" "${pod_yaml_file}" "${configmap_yaml_file}"
|
||||
}
|
||||
|
||||
@test "ConfigMap for a pod" {
|
||||
@ -17,19 +28,18 @@ setup() {
|
||||
pod_name="config-env-test-pod"
|
||||
|
||||
# Create ConfigMap
|
||||
kubectl create -f "${pod_config_dir}/configmap.yaml"
|
||||
kubectl create -f "${configmap_yaml_file}"
|
||||
|
||||
# View the values of the keys
|
||||
kubectl get configmaps $config_name -o yaml | grep -q "data-"
|
||||
|
||||
# Create a pod that consumes the ConfigMap
|
||||
kubectl create -f "${pod_config_dir}/pod-configmap.yaml"
|
||||
kubectl create -f "${pod_yaml_file}"
|
||||
|
||||
# Check pod creation
|
||||
kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name"
|
||||
|
||||
# Check env
|
||||
cmd="env"
|
||||
kubectl exec $pod_name -- sh -c $cmd | grep "KUBE_CONFIG_1=value-1"
|
||||
kubectl exec $pod_name -- sh -c $cmd | grep "KUBE_CONFIG_2=value-2"
|
||||
}
|
||||
@ -40,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