The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#) https://grpc.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.6 KiB

#!/bin/bash
# Copyright 2022 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cd "$(dirname "$0")"
# Shellcheck cant find the included file.
# shellcheck disable=SC1091
source common.sh
set -euxo pipefail
RUNTIME="$1"
ARTIFACT_URL="$2"
REQUEST_COUNT=20
LOG_QUIESCE_SECONDS=10
rm -f requirements.txt
cp requirements.txt.base requirements.txt
echo "${ARTIFACT_URL}" >>requirements.txt
# Generate Function name.
FUNCTION_NAME="${FUNCTION_PREFIX}-$(uuidgen)"
function cleanup() {
# Wait for logs to quiesce.
sleep "${LOG_QUIESCE_SECONDS}"
gcloud functions logs read "${FUNCTION_NAME}" || true
(yes || true) | gcloud functions delete "${FUNCTION_NAME}"
}
trap cleanup SIGINT SIGTERM EXIT
# Deploy
[Python test] Fix gcf permission denied error (#37684) `grpc_distribtests_gcp_python` test is [failing with permission error](https://fusion2.corp.google.com/ci;ids=1930537984/kokoro/prod:grpc%2Fcore%2Fmaster%2Flinux%2Fgrpc_distribtests_gcp_python/activity/2c6d57dd-f504-4834-9fd6-845db47ede01/log): ``` ERROR: (gcloud.functions.deploy) ResponseError: status=[403], code=[Ok], message=[Permission 'run.services.setIamPolicy' denied on resource 'projects/grpc-testing/locations/us-central1/services/grpc-gcf-distribtest-3cd3cc11-1a8f-4b88-9c3b-220f0bdf9fdc' (or resource may not exist).] ``` In the logs, looks like we're creating gen2 functions by default: ``` As of this Cloud SDK release, new functions will be deployed as 2nd gen functions by default. This is equivalent to currently deploying new with the --gen2 flag. Existing 1st gen functions will not be impacted and will continue to deploy as 1st gen functions. ``` Since we don't need functions provided by gen2 functions and use `--no-gen2` fixed the permission issue, we're adding `--no-gen2` flag to our test. ### Test: * Passed manually run: http://sponge/e52ffb74-5a12-4e67-9f95-4638390ef57c <!-- If you know who should review your pull request, please assign it to that person, otherwise the pull request would get assigned randomly. If your pull request is for a specific language, please add the appropriate lang label. --> Closes #37684 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/37684 from XuanWang-Amos:fix_gcf 26588c0cc3ad1663836e18028dfe2a1b22825d4d PiperOrigin-RevId: 675703636
3 months ago
DEPLOY_OUTPUT=$(gcloud functions deploy "${FUNCTION_NAME}" --entry-point test_publish --runtime "${RUNTIME}" --trigger-http --allow-unauthenticated --no-gen2)
HTTP_URL=$(echo "${DEPLOY_OUTPUT}" | grep "url: " | awk '{print $2;}')
# Send Requests
for _ in $(seq 1 "${REQUEST_COUNT}"); do
GCP_IDENTITY_TOKEN=$(gcloud auth print-identity-token 2>/dev/null);
curl -v -H "Authorization: Bearer $GCP_IDENTITY_TOKEN" "${HTTP_URL}"
done