sigs.k8s.io/cluster-api-provider-azure@v1.14.3/scripts/ci-conformance.sh (about)

     1  #!/bin/bash
     2  
     3  # Copyright 2020 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  ###############################################################################
    18  
    19  # This script is executed by presubmit `pull-cluster-api-provider-azure-e2e`
    20  # To run locally, set AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_SUBSCRIPTION_ID, AZURE_TENANT_ID
    21  
    22  set -o errexit
    23  set -o nounset
    24  set -o pipefail
    25  
    26  # Install kubectl
    27  REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
    28  KUBECTL="${REPO_ROOT}/hack/tools/bin/kubectl"
    29  KIND="${REPO_ROOT}/hack/tools/bin/kind"
    30  KUSTOMIZE="${REPO_ROOT}/hack/tools/bin/kustomize"
    31  make --directory="${REPO_ROOT}" "${KUBECTL##*/}" "${KIND##*/}" "${KUSTOMIZE##*/}"
    32  
    33  # shellcheck source=hack/ensure-go.sh
    34  source "${REPO_ROOT}/hack/ensure-go.sh"
    35  # shellcheck source=hack/ensure-tags.sh
    36  source "${REPO_ROOT}/hack/ensure-tags.sh"
    37  # shellcheck source=hack/parse-prow-creds.sh
    38  source "${REPO_ROOT}/hack/parse-prow-creds.sh"
    39  # shellcheck source=hack/util.sh
    40  source "${REPO_ROOT}/hack/util.sh"
    41  
    42  # Verify the required Environment Variables are present.
    43  capz::util::ensure_azure_envs
    44  
    45  export LOCAL_ONLY=${LOCAL_ONLY:-"true"}
    46  export USE_LOCAL_KIND_REGISTRY=${USE_LOCAL_KIND_REGISTRY:-${LOCAL_ONLY}} 
    47  
    48  if [[ "${USE_LOCAL_KIND_REGISTRY}" == "true" ]]; then
    49    export REGISTRY="localhost:5000/ci-e2e"
    50  else
    51    : "${REGISTRY:?Environment variable empty or not defined.}"
    52    "${REPO_ROOT}"/hack/ensure-acr-login.sh
    53    if [[ "$(capz::util::should_build_kubernetes)" == "true" ]]; then
    54      export E2E_ARGS="-kubetest.use-pr-artifacts"
    55      export KUBE_BUILD_CONFORMANCE="y"
    56      source "${REPO_ROOT}/scripts/ci-build-kubernetes.sh"
    57    fi
    58  
    59    if [[ "$(capz::util::should_build_ccm)" == "true" ]]; then
    60      # shellcheck source=scripts/ci-build-azure-ccm.sh
    61      source "${REPO_ROOT}/scripts/ci-build-azure-ccm.sh"
    62      echo "Will use the ${IMAGE_REGISTRY}/${CCM_IMAGE_NAME}:${IMAGE_TAG_CCM} cloud-controller-manager image for external cloud-provider-cluster"
    63      echo "Will use the ${IMAGE_REGISTRY}/${CNM_IMAGE_NAME}:${IMAGE_TAG_CNM} cloud-node-manager image for external cloud-provider-azure cluster"
    64    fi
    65  fi
    66  
    67  defaultTag=$(date -u '+%Y%m%d%H%M%S')
    68  export TAG="${defaultTag:-dev}"
    69  export GINKGO_NODES=1
    70  
    71  export AZURE_LOCATION="${AZURE_LOCATION:-$(capz::util::get_random_region)}"
    72  export AZURE_LOCATION_GPU="${AZURE_LOCATION_GPU:-$(capz::util::get_random_region_gpu)}"
    73  export AZURE_LOCATION_EDGEZONE="${AZURE_LOCATION_EDGEZONE:-$(capz::util::get_random_region_edgezone)}"
    74  export AZURE_CONTROL_PLANE_MACHINE_TYPE="${AZURE_CONTROL_PLANE_MACHINE_TYPE:-"Standard_B2s"}"
    75  export AZURE_NODE_MACHINE_TYPE="${AZURE_NODE_MACHINE_TYPE:-"Standard_B2s"}"
    76  export WINDOWS="${WINDOWS:-false}"
    77  
    78  # Generate SSH key.
    79  capz::util::generate_ssh_key
    80  
    81  capz::ci-conformance::cleanup() {
    82      "${REPO_ROOT}/hack/log/redact.sh" || true
    83  }
    84  
    85  trap capz::ci-conformance::cleanup EXIT
    86  
    87  if [[ "${WINDOWS}" == "true" ]]; then
    88    make test-windows-upstream
    89  else
    90    make test-conformance
    91  fi