From 9cbdce15fd9e941ceea1512a1ad478fe458468db Mon Sep 17 00:00:00 2001 From: Dan Mihai Date: Mon, 12 Feb 2024 01:37:40 +0000 Subject: [PATCH] tests: k8s: k8s-memory.bats auto-generated policy Auto-generate policy for k8s-memory.bats. Fixes: #9072 Signed-off-by: Dan Mihai --- tests/integration/kubernetes/k8s-memory.bats | 22 ++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/integration/kubernetes/k8s-memory.bats b/tests/integration/kubernetes/k8s-memory.bats index 5bcffaab44..d0811cfaa9 100644 --- a/tests/integration/kubernetes/k8s-memory.bats +++ b/tests/integration/kubernetes/k8s-memory.bats @@ -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" }