github.com/kata-containers/tests@v0.0.0-20240307153542-772105b56064/integration/kubernetes/k8s-custom-dns.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  	pod_name="custom-dns-test"
    13  	file_name="/etc/resolv.conf"
    14  	get_pod_config_dir
    15  }
    16  
    17  @test "Check custom dns" {
    18  	# Create the pod
    19  	kubectl create -f "${pod_config_dir}/pod-custom-dns.yaml"
    20  
    21  	# Check pod creation
    22  	kubectl wait --for=condition=Ready --timeout=$timeout pod $pod_name
    23  
    24  	# Check dns config at /etc/resolv.conf
    25  	kubectl exec "$pod_name" -- cat "$file_name" | grep -q "nameserver 1.2.3.4"
    26  	kubectl exec "$pod_name" -- cat "$file_name" | grep -q "search dns.test.search"
    27  }
    28  
    29  teardown() {
    30  	# Debugging information
    31  	kubectl describe "pod/$pod_name"
    32  
    33  	kubectl delete pod "$pod_name"
    34  }