mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-31 07:19:06 +00:00
tests: k8s: k8s-shared-volume generated policy
Auto-generate policy for k8s-shared-volume.bats. Fixes: #9096 Signed-off-by: Dan Mihai <dmihai@microsoft.com>
This commit is contained in:
parent
b24758fad8
commit
c08b696d9e
@ -16,15 +16,25 @@ setup() {
|
||||
pod_name="test-shared-volume"
|
||||
first_container_name="busybox-first-container"
|
||||
second_container_name="busybox-second-container"
|
||||
cmd="cat /tmp/pod-data"
|
||||
yaml_file="${pod_config_dir}/pod-shared-volume.yaml"
|
||||
|
||||
# Add policy to the yaml file
|
||||
policy_settings_dir="$(create_tmp_policy_settings_dir "${pod_config_dir}")"
|
||||
|
||||
exec_command="sh -c ${cmd}"
|
||||
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}" "${yaml_file}"
|
||||
|
||||
# Create pod
|
||||
kubectl create -f "${pod_config_dir}/pod-shared-volume.yaml"
|
||||
kubectl create -f "${yaml_file}"
|
||||
|
||||
# Check pods
|
||||
kubectl wait --for=condition=Ready --timeout=$timeout pod $pod_name
|
||||
|
||||
# Communicate containers
|
||||
cmd="cat /tmp/pod-data"
|
||||
msg="Hello from the $second_container_name"
|
||||
kubectl exec "$pod_name" -c "$first_container_name" -- sh -c "$cmd" | grep "$msg"
|
||||
}
|
||||
@ -32,20 +42,31 @@ setup() {
|
||||
@test "initContainer with shared volume" {
|
||||
pod_name="initcontainer-shared-volume"
|
||||
last_container="last"
|
||||
cmd='test $(cat /volume/initContainer) -lt $(cat /volume/container)'
|
||||
yaml_file="${pod_config_dir}/initContainer-shared-volume.yaml"
|
||||
|
||||
# Add policy to the yaml file
|
||||
policy_settings_dir="$(create_tmp_policy_settings_dir "${pod_config_dir}")"
|
||||
|
||||
exec_command="sh -c ${cmd}"
|
||||
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}" "${yaml_file}"
|
||||
|
||||
# Create pod
|
||||
kubectl create -f "${pod_config_dir}/initContainer-shared-volume.yaml"
|
||||
kubectl create -f "${yaml_file}"
|
||||
|
||||
# Check pods
|
||||
kubectl wait --for=condition=Ready --timeout=$timeout pod $pod_name
|
||||
|
||||
cmd='test $(cat /volume/initContainer) -lt $(cat /volume/container)'
|
||||
kubectl exec "$pod_name" -c "$last_container" -- sh -c "$cmd"
|
||||
}
|
||||
|
||||
teardown() {
|
||||
# Debugging information
|
||||
kubectl describe "pod/$pod_name"
|
||||
kubectl describe "pod/$pod_name" || true
|
||||
|
||||
kubectl delete pod "$pod_name"
|
||||
kubectl delete pod "$pod_name" || true
|
||||
delete_tmp_policy_settings_dir "${policy_settings_dir}"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user