github.com/kata-containers/tests@v0.0.0-20240307153542-772105b56064/integration/kubernetes/tests_common.sh (about)

     1  #
     2  # Copyright (c) 2021 Red Hat, Inc.
     3  #
     4  # SPDX-License-Identifier: Apache-2.0
     5  #
     6  # This script is evoked within an OpenShift Build to product the binary image,
     7  # which will contain the Kata Containers installation into a given destination
     8  # directory.
     9  #
    10  # This contains variables and functions common to all e2e tests.
    11  
    12  # Timeout options, mainly for use with waitForProcess(). Use them unless the
    13  # operation needs to wait longer.
    14  wait_time=90
    15  sleep_time=3
    16  
    17  # Timeout for use with `kubectl wait`, unless it needs to wait longer.
    18  # Note: try to keep timeout and wait_time equal.
    19  timeout=90s
    20  
    21  # issues that can't test yet.
    22  fc_limitations="https://github.com/kata-containers/documentation/issues/351"
    23  
    24  # Path to the kubeconfig file which is used by kubectl and other tools.
    25  # Note: the init script sets that variable but if you want to run the tests in
    26  # your own provisioned cluster and you know what you are doing then you should
    27  # overwrite it.
    28  export KUBECONFIG="${KUBECONFIG:-$HOME/.kube/config}"
    29  
    30  get_pod_config_dir() {
    31  	pod_config_dir="${BATS_TEST_DIRNAME}/runtimeclass_workloads"
    32  	info "k8s configured to use runtimeclass"
    33  }
    34  
    35  # Uses crictl to pull a container image passed in $1.
    36  # If crictl is not found then it just prints a warning.
    37  crictl_pull() {
    38  	local img="${1:-}"
    39  	local cmd="crictl"
    40  	if ! command -v "$cmd" &>/dev/null; then
    41  		warn "$cmd not found. Cannot pull image $img"
    42  	else
    43  		sudo -E "$cmd" pull "$img"
    44  	fi
    45  }