1#!/bin/bash 2# Copyright 2022 gRPC 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 16set -euxo pipefail 17 18cd "$(dirname "$0")" 19 20ARTIFACT_DIRECTORY="$1" 21 22BUCKET_NAME="grpc-gcf-distribtests" 23 24RUN_ID=$(uuidgen) 25 26FAILED_RUNTIMES="" 27 28# This is the only programmatic way to get access to the list of runtimes. 29# While hacky, it's better than the alternative -- manually upgrading a 30# hand-curated list every few months. 31RUNTIMES=$(gcloud functions deploy --help | grep -Eo "python[0-9]+" | sort | uniq) 32 33while read -r RUNTIME; do 34 BARE_VERSION=${RUNTIME//python/} 35 36 # We sort to get the latest manylinux version. 37 ARTIFACT=$(find "${ARTIFACT_DIRECTORY}" -regex '.*grpcio-[0-9\.]+.+-cp'"${BARE_VERSION}"'-cp'"${BARE_VERSION}"'m?-manylinux.+x86_64\.whl' | sort -r | head -n 1) 38 ARTIFACT_BASENAME=$(basename "${ARTIFACT}") 39 40 # Upload artifact to GCS so GCF can access it. 41 # A 1 day retention policy is active on this bucket. 42 gsutil cp "${ARTIFACT}" "gs://${BUCKET_NAME}/${RUN_ID}/${ARTIFACT_BASENAME}" 43 44 echo "Testing runtime ${RUNTIME} with artifact ${ARTIFACT_BASENAME}" 45 ./run_single.sh "${RUNTIME}" "https://storage.googleapis.com/${BUCKET_NAME}/${RUN_ID}/${ARTIFACT_BASENAME}" || FAILED_RUNTIMES="${FAILED_RUNTIMES} ${RUNTIME}" 46done<<<"${RUNTIMES}" 47 48if [ "$FAILED_RUNTIMES" != "" ] 49then 50 echo "GCF Distribtest failed: Failing runtimes: ${FAILED_RUNTIMES}" 51 exit 1 52fi 53