github.com/kata-containers/tests@v0.0.0-20240307153542-772105b56064/integration/kubernetes/k8s-limit-range.bats (about)

     1  #!/usr/bin/env bats
     2  #
     3  # Copyright (c) 2019 Intel Corporation
     4  #
     5  # SPDX-License-Identifier: Apache-2.0
     6  #
     7  
     8  load "${BATS_TEST_DIRNAME}/../../.ci/lib.sh"
     9  load "${BATS_TEST_DIRNAME}/tests_common.sh"
    10  
    11  setup() {
    12  	get_pod_config_dir
    13  	namespace_name="default-cpu-example"
    14  	pod_name="default-cpu-test"
    15  }
    16  
    17  @test "Limit range for storage" {
    18  	# Create namespace
    19  	kubectl create namespace "$namespace_name"
    20  
    21  	# Create the LimitRange in the namespace
    22  	kubectl create -f "${pod_config_dir}/limit-range.yaml" --namespace=${namespace_name}
    23  
    24  	# Create the pod
    25  	kubectl create -f "${pod_config_dir}/pod-cpu-defaults.yaml" --namespace=${namespace_name}
    26  
    27  	# Get pod specification
    28  	kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name" --namespace="$namespace_name"
    29  
    30  	# Check limits
    31  	# Find the 500 millicpus specified at the yaml
    32  	kubectl describe pod "$pod_name" --namespace="$namespace_name" | grep "500m"
    33  }
    34  
    35  teardown() {
    36  	# Debugging information
    37  	kubectl describe "pod/$pod_name"
    38  
    39  	kubectl delete pod "$pod_name"
    40  	kubectl delete namespaces "$namespace_name"
    41  }