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 28RUNTIMES=$(gcloud functions runtimes list --filter name:python* --region us-west1 | grep python | awk '{print $1}') 29 30while read -r RUNTIME; do 31 BARE_VERSION=${RUNTIME//python/} 32 33 # We sort to get the latest manylinux version. 34 ARTIFACT=$(find "${ARTIFACT_DIRECTORY}" -regex '.*grpcio-[0-9\.]+.+-cp'"${BARE_VERSION}"'-cp'"${BARE_VERSION}"'m?-manylinux.+x86_64\.whl' | sort -r | head -n 1) 35 ARTIFACT_BASENAME=$(basename "${ARTIFACT}") 36 37 if [ "$ARTIFACT_BASENAME" != "" ]; then 38 # Upload artifact to GCS so GCF can access it. 39 # A 1 day retention policy is active on this bucket. 40 gsutil cp "${ARTIFACT}" "gs://${BUCKET_NAME}/${RUN_ID}/${ARTIFACT_BASENAME}" 41 42 echo "Testing runtime ${RUNTIME} with artifact ${ARTIFACT_BASENAME}" 43 ./run_single.sh "${RUNTIME}" "https://storage.googleapis.com/${BUCKET_NAME}/${RUN_ID}/${ARTIFACT_BASENAME}" || FAILED_RUNTIMES="${FAILED_RUNTIMES} ${RUNTIME}" 44 else 45 echo "Skip testing ${RUNTIME} because we no longer support this version" 46 fi 47done<<<"${RUNTIMES}" 48 49if [ "$FAILED_RUNTIMES" != "" ] 50then 51 echo "GCF Distribtest failed: Failing runtimes: ${FAILED_RUNTIMES}" 52 exit 1 53fi 54