mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-09 03:48:05 +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" {
|
@test "Exceeding memory constraints" {
|
||||||
memory_limit_size="50Mi"
|
memory_limit_size="50Mi"
|
||||||
allocated_size="250M"
|
allocated_size="250M"
|
||||||
|
|
||||||
# Create test .yaml
|
# 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
|
# 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 ]
|
[ "$status" -ne 0 ]
|
||||||
|
|
||||||
rm -f "${pod_config_dir}/test_exceed_memory.yaml"
|
rm -f "${test_yaml}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "Running within memory constraints" {
|
@test "Running within memory constraints" {
|
||||||
memory_limit_size="600Mi"
|
memory_limit_size="600Mi"
|
||||||
allocated_size="150M"
|
allocated_size="150M"
|
||||||
|
|
||||||
# Create test .yaml
|
# 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
|
# Create the pod within memory constraints
|
||||||
kubectl create -f "${pod_config_dir}/test_within_memory.yaml"
|
kubectl create -f "${test_yaml}"
|
||||||
|
|
||||||
# Check pod creation
|
# Check pod creation
|
||||||
kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name"
|
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"
|
kubectl delete pod "$pod_name"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user