k8s.io/kubernetes@v1.31.0-alpha.0.0.20240520171757-56147500dadc/test/conformance/image/run_e2e.sh (about)

     1  #!/usr/bin/env bash
     2  # Copyright 2018 The Kubernetes Authors.
     3  #
     4  # Licensed under the Apache License, Version 2.0 (the "License");
     5  # you may not use this file except in compliance with the License.
     6  # You may obtain a copy of the License at
     7  #
     8  #     http://www.apache.org/licenses/LICENSE-2.0
     9  #
    10  # Unless required by applicable law or agreed to in writing, software
    11  # distributed under the License is distributed on an "AS IS" BASIS,
    12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  # See the License for the specific language governing permissions and
    14  # limitations under the License.
    15  
    16  set -o errexit
    17  set -o nounset
    18  set -o pipefail
    19  
    20  # Shutdown the tests gracefully then save the results
    21  # shellcheck disable=SC2317 # false positive
    22  shutdown () {
    23      E2E_SUITE_PID=$(pgrep e2e.test)
    24      echo "sending TERM to ${E2E_SUITE_PID}"
    25      kill -s TERM "${E2E_SUITE_PID}"
    26  
    27      # Kind of a hack to wait for this pid to finish.
    28      # Since it's not a child of this shell we cannot use wait.
    29      tail --pid "${E2E_SUITE_PID}" -f /dev/null
    30      saveResults
    31  }
    32  
    33  saveResults() {
    34      cd "${RESULTS_DIR}" || exit
    35      tar -czf e2e.tar.gz ./*
    36      # mark the done file as a termination notice.
    37      echo -n "${RESULTS_DIR}/e2e.tar.gz" > "${RESULTS_DIR}/done"
    38  }
    39  
    40  # Optional Golang runner alternative to the bash script.
    41  # Entry provided via env var to simplify invocation.
    42  if [[ -n ${E2E_USE_GO_RUNNER:-} ]]; then
    43      set -x
    44      /gorunner && ret=0 || ret=$?
    45      exit "${ret}"
    46  fi
    47  
    48  # We get the TERM from kubernetes and handle it gracefully
    49  trap shutdown TERM
    50  
    51  ginkgo_args=()
    52  if [[ -n ${E2E_DRYRUN:-} ]]; then
    53      ginkgo_args+=("--dry-run=true")
    54  fi
    55  
    56  # NOTE: Ginkgo's default timeout has been reduced from 24h to 1h in V2, set it manually here as "24h"
    57  # for backward compatibility purpose.
    58  ginkgo_args+=("--timeout=24h")
    59  
    60  case ${E2E_PARALLEL} in
    61      'y'|'Y'|'true')
    62          # The flag '--p' will automatically detect the optimal number of ginkgo nodes.
    63          ginkgo_args+=("--p")
    64          # Skip serial tests if parallel mode is enabled.
    65          E2E_SKIP="\\[Serial\\]|${E2E_SKIP}" ;;
    66  esac
    67  
    68  ginkgo_args+=(
    69      "--focus=${E2E_FOCUS}"
    70      "--skip=${E2E_SKIP}"
    71      "--no-color=true"
    72  )
    73  
    74  set -x
    75  /usr/local/bin/ginkgo "${ginkgo_args[@]}" /usr/local/bin/e2e.test -- --disable-log-dump --repo-root=/kubernetes --provider="${E2E_PROVIDER}" --report-dir="${RESULTS_DIR}" --kubeconfig="${KUBECONFIG}" -v="${E2E_VERBOSITY}" > >(tee "${RESULTS_DIR}"/e2e.log) && ret=0 || ret=$?
    76  set +x
    77  saveResults
    78  exit "${ret}"