github.com/dmaizel/tests@v0.0.0-20210728163746-cae6a2d9cee8/integration/kubernetes/k8s-env.bats (about)

     1  #!/usr/bin/env bats
     2  #
     3  # Copyright (c) 2018 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  	pod_name="test-env"
    14  	get_pod_config_dir
    15  }
    16  
    17  @test "Environment variables" {
    18  	# Create pod
    19  	kubectl create -f "${pod_config_dir}/pod-env.yaml"
    20  
    21  	# Check pod creation
    22  	kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name"
    23  
    24  	# Print environment variables
    25  	cmd="printenv"
    26  	kubectl exec $pod_name -- sh -c $cmd | grep "MY_POD_NAME=$pod_name"
    27  }
    28  
    29  teardown() {
    30  	# Debugging information
    31  	kubectl describe "pod/$pod_name"
    32  
    33  	kubectl delete pod "$pod_name"
    34  }