github.com/dmaizel/tests@v0.0.0-20210728163746-cae6a2d9cee8/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  	export KUBECONFIG="${KUBECONFIG:-$HOME/.kube/config}"
    13  	get_pod_config_dir
    14  	namespace_name="default-cpu-example"
    15  	pod_name="default-cpu-test"
    16  }
    17  
    18  @test "Limit range for storage" {
    19  	# Create namespace
    20  	kubectl create namespace "$namespace_name"
    21  
    22  	# Create the LimitRange in the namespace
    23  	kubectl create -f "${pod_config_dir}/limit-range.yaml" --namespace=${namespace_name}
    24  
    25  	# Create the pod
    26  	kubectl create -f "${pod_config_dir}/pod-cpu-defaults.yaml" --namespace=${namespace_name}
    27  
    28  	# Get pod specification
    29  	kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name" --namespace="$namespace_name"
    30  
    31  	# Check limits
    32  	# Find the 500 millicpus specified at the yaml
    33  	kubectl describe pod "$pod_name" --namespace="$namespace_name" | grep "500m"
    34  }
    35  
    36  teardown() {
    37  	# Debugging information
    38  	kubectl describe "pod/$pod_name"
    39  
    40  	kubectl delete pod "$pod_name"
    41  	kubectl delete namespaces "$namespace_name"
    42  }