mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-31 15:25:26 +00:00
tests: k8s: k8s-memory.bats auto-generated policy
Auto-generate policy for k8s-memory.bats. Fixes: #9072 Signed-off-by: Dan Mihai <dmihai@microsoft.com>
This commit is contained in:
parent
40209cc0b7
commit
9cbdce15fd
@ -24,29 +24,39 @@ setup_yaml() {
|
||||
@test "Exceeding memory constraints" {
|
||||
memory_limit_size="50Mi"
|
||||
allocated_size="250M"
|
||||
|
||||
# Create test .yaml
|
||||
setup_yaml > "${pod_config_dir}/test_exceed_memory.yaml"
|
||||
test_yaml="${pod_config_dir}/test_exceed_memory.yaml"
|
||||
setup_yaml > "${test_yaml}"
|
||||
|
||||
# Add policy to yaml file
|
||||
auto_generate_policy "${pod_config_dir}" "${test_yaml}"
|
||||
|
||||
# Create the pod exceeding memory constraints
|
||||
run kubectl create -f "${pod_config_dir}/test_exceed_memory.yaml"
|
||||
run kubectl create -f "${test_yaml}"
|
||||
[ "$status" -ne 0 ]
|
||||
|
||||
rm -f "${pod_config_dir}/test_exceed_memory.yaml"
|
||||
rm -f "${test_yaml}"
|
||||
}
|
||||
|
||||
@test "Running within memory constraints" {
|
||||
memory_limit_size="600Mi"
|
||||
allocated_size="150M"
|
||||
|
||||
# Create test .yaml
|
||||
setup_yaml > "${pod_config_dir}/test_within_memory.yaml"
|
||||
test_yaml="${pod_config_dir}/test_within_memory.yaml"
|
||||
setup_yaml > "${test_yaml}"
|
||||
|
||||
# Add policy to yaml file
|
||||
auto_generate_policy "${pod_config_dir}" "${test_yaml}"
|
||||
|
||||
# Create the pod within memory constraints
|
||||
kubectl create -f "${pod_config_dir}/test_within_memory.yaml"
|
||||
kubectl create -f "${test_yaml}"
|
||||
|
||||
# Check pod creation
|
||||
kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name"
|
||||
|
||||
rm -f "${pod_config_dir}/test_within_memory.yaml"
|
||||
rm -f "${test_yaml}"
|
||||
kubectl delete pod "$pod_name"
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user