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

     1  #!/usr/bin/env bats
     2  #
     3  # Copyright (c) 2021 IBM 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  	[ "${KATA_HYPERVISOR}" == "firecracker" ] && skip "test not working see: ${fc_limitations}"
    13  	
    14  	get_pod_config_dir
    15  
    16  	pod_name="nested-configmap-secret-pod"
    17  }
    18  
    19  @test "Nested mount of a secret volume in a configmap volume for a pod" {
    20  	# Creates a configmap, secret and pod that mounts the secret inside the configmap
    21  	kubectl create -f "${pod_config_dir}/pod-nested-configmap-secret.yaml"
    22  
    23  	# Check pod creation
    24  	kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name"
    25  
    26  	# Check config/secret value are correct
    27  	[ "myconfig" == $(kubectl exec $pod_name -- cat /config/config_key) ]
    28  	[ "mysecret" == $(kubectl exec $pod_name -- cat /config/secret/secret_key) ]
    29  }
    30  
    31  teardown() {
    32  	[ "${KATA_HYPERVISOR}" == "firecracker" ] && skip "test not working see: ${fc_limitations}"
    33  
    34  	# Debugging information
    35  	kubectl describe "pod/$pod_name"
    36  
    37  	# Delete the configmap, secret, and pod used for testing
    38  	kubectl delete -f "${pod_config_dir}/pod-nested-configmap-secret.yaml"
    39  }