sigs.k8s.io/kueue@v0.6.2/hack/e2e-common.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  # Copyright 2023 The Kubernetes Authors.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  export KUSTOMIZE="$ROOT_DIR"/bin/kustomize
    18  export GINKGO="$ROOT_DIR"/bin/ginkgo
    19  export KIND="$ROOT_DIR"/bin/kind
    20  export YQ="$ROOT_DIR"/bin/yq
    21  
    22  
    23  # $1 - cluster name
    24  function cluster_cleanup {
    25  	kubectl config use-context kind-$1
    26          $KIND export logs $ARTIFACTS --name $1 || true
    27          kubectl describe pods -n kueue-system > $ARTIFACTS/$1-kueue-system-pods.log || true
    28          kubectl describe pods > $ARTIFACTS/$1-default-pods.log || true
    29          $KIND delete cluster --name $1
    30  }
    31  
    32  # $1 cluster name
    33  # $2 cluster kind config
    34  function cluster_create {
    35          $KIND create cluster --name $1 --image $E2E_KIND_VERSION --config $2 --wait 1m -v 5  > $ARTIFACTS/$1-create.log 2>&1 \
    36  		||  { echo "unable to start the $1 cluster "; cat $ARTIFACTS/$1-create.log ; }
    37  	kubectl config use-context kind-$1
    38          kubectl get nodes > $ARTIFACTS/$1-nodes.log || true
    39          kubectl describe pods -n kube-system > $ARTIFACTS/$1-system-pods.log || true
    40  }
    41  
    42  # $1 cluster
    43  function cluster_kind_load {
    44  	cluster_kind_load_image $1 $E2E_TEST_IMAGE
    45  	cluster_kind_load_image $1 $IMAGE_TAG
    46  }
    47  
    48  # $1 cluster
    49  # $2 image
    50  function cluster_kind_load_image {
    51          $KIND load docker-image $2 --name $1
    52  }
    53  
    54  # $1 cluster
    55  function cluster_kueue_deploy {
    56      kubectl config use-context kind-${1}
    57      if [[ $E2E_KIND_VERSION = *1.26* ]]; then
    58          kubectl apply --server-side -k test/e2e/config_1_26
    59      else
    60          kubectl apply --server-side -k test/e2e/config
    61      fi
    62  }
    63  
    64  export INITIAL_IMAGE=$($YQ '.images[] | select(.name == "controller") | [.newName, .newTag] | join(":")' config/components/manager/kustomization.yaml)
    65  
    66  function restore_managers_image {
    67      (cd config/components/manager && $KUSTOMIZE edit set image controller=$INITIAL_IMAGE)
    68  }