Files
kata-containers/tests/integration/kubernetes/k8s-limit-range.bats
Dan Mihai 40209cc0b7 tests: k8s: k8s-limit-range auto-generated policy
Auto-generate policy for k8s-limit-range.bats.

Also, fix teardown() namespace.

Fixes: #9072

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2024-02-21 18:08:08 +00:00

49 lines
1.4 KiB
Bash

#!/usr/bin/env bats
#
# Copyright (c) 2019 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
load "${BATS_TEST_DIRNAME}/../../common.bash"
load "${BATS_TEST_DIRNAME}/tests_common.sh"
setup() {
get_pod_config_dir
namespace_name="default-cpu-example"
pod_name="default-cpu-test"
pod_yaml="${pod_config_dir}/pod-cpu-defaults.yaml"
policy_settings_dir="$(create_tmp_policy_settings_dir "${pod_config_dir}")"
set_namespace_to_policy_settings "${policy_settings_dir}" "${namespace_name}"
auto_generate_policy "${policy_settings_dir}" "${pod_yaml}"
}
@test "Limit range for storage" {
# Create namespace
kubectl create namespace "$namespace_name"
# Create the LimitRange in the namespace
kubectl create -f "${pod_config_dir}/limit-range.yaml" --namespace=${namespace_name}
# Create the pod
kubectl create -f "${pod_yaml}" --namespace=${namespace_name}
# Get pod specification
kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name" --namespace="$namespace_name"
# Check limits
# Find the 500 millicpus specified at the yaml
kubectl describe pod "$pod_name" --namespace="$namespace_name" | grep "500m"
}
teardown() {
# Debugging information
kubectl describe "pod/$pod_name" -n "$namespace_name"
kubectl delete pod "$pod_name" -n "$namespace_name"
kubectl delete namespaces "$namespace_name"
delete_tmp_policy_settings_dir "${policy_settings_dir}"
}