kata-containers/tests/integration/kubernetes/k8s-qos-pods.bats
Dan Mihai 56689c6800 tests: k8s: k8s-qos-pods auto-generated policy
Auto-generate policy for k8s-qos-pods.bats.

Fixes: #9096

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2024-03-07 05:57:30 +00:00

78 lines
2.2 KiB
Bash

#!/usr/bin/env bats
#
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
load "${BATS_TEST_DIRNAME}/../../common.bash"
load "${BATS_TEST_DIRNAME}/tests_common.sh"
TEST_INITRD="${TEST_INITRD:-no}"
# Not working on ARM CI see https://github.com/kata-containers/tests/issues/4727
setup() {
get_pod_config_dir
}
@test "Guaranteed QoS" {
pod_name="qos-test"
yaml_file="${pod_config_dir}/pod-guaranteed.yaml"
# Add policy to the yaml file
policy_settings_dir="$(create_tmp_policy_settings_dir "${pod_config_dir}")"
add_requests_to_policy_settings "${policy_settings_dir}" "ReadStreamRequest"
auto_generate_policy "${policy_settings_dir}" "${yaml_file}"
# Create pod
kubectl create -f "${yaml_file}"
# Check pod creation
kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name"
# Check pod class
kubectl get pod "$pod_name" --output=yaml | grep "qosClass: Guaranteed"
}
@test "Burstable QoS" {
pod_name="burstable-test"
yaml_file="${pod_config_dir}/pod-burstable.yaml"
# Add policy to the yaml file
policy_settings_dir="$(create_tmp_policy_settings_dir "${pod_config_dir}")"
add_requests_to_policy_settings "${policy_settings_dir}" "ReadStreamRequest"
auto_generate_policy "${policy_settings_dir}" "${yaml_file}"
# Create pod
kubectl create -f "${yaml_file}"
# Check pod creation
kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name"
# Check pod class
kubectl get pod "$pod_name" --output=yaml | grep "qosClass: Burstable"
}
@test "BestEffort QoS" {
pod_name="besteffort-test"
yaml_file="${pod_config_dir}/pod-besteffort.yaml"
# Add policy to the yaml file
policy_settings_dir="$(create_tmp_policy_settings_dir "${pod_config_dir}")"
add_requests_to_policy_settings "${policy_settings_dir}" "ReadStreamRequest"
auto_generate_policy "${policy_settings_dir}" "${yaml_file}"
# Create pod
kubectl create -f "${yaml_file}"
# Check pod creation
kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name"
# Check pod class
kubectl get pod "$pod_name" --output=yaml | grep "qosClass: BestEffort"
}
teardown() {
kubectl delete pod "$pod_name"
delete_tmp_policy_settings_dir "${policy_settings_dir}"
}