2 # Copyright 2021 The gRPC Authors
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 # Enter the gRPC repo root.
18 cd "$(dirname "$0")/../../.."
20 source tools/internal_ci/helper_scripts/prepare_build_linux_rc
22 # This is to ensure we can push and pull images from gcr.io. We do not
23 # necessarily need it to run load tests, but will need it when we employ
24 # pre-built images in the optimization.
25 gcloud auth configure-docker
27 # Connect to benchmarks-prod2 cluster.
28 gcloud config set project grpc-testing
29 gcloud container clusters get-credentials benchmarks-prod2 \
30 --zone us-central1-b --project grpc-testing
32 # Set up environment variables.
33 LOAD_TEST_PREFIX="${KOKORO_BUILD_INITIATOR}"
34 # BEGIN differentiate experimental configuration from master configuration.
35 # Use the "official" BQ tables so that the measurements will show up in the
36 # "official" public dashboard.
37 BIGQUERY_TABLE_8CORE=e2e_benchmarks.ci_master_results_8core
38 BIGQUERY_TABLE_32CORE=e2e_benchmarks.ci_master_results_32core
39 # END differentiate experimental configuration from master configuration.
40 CLOUD_LOGGING_URL="https://source.cloud.google.com/results/invocations/${KOKORO_BUILD_ID}"
41 PREBUILT_IMAGE_PREFIX="gcr.io/grpc-testing/e2etesting/pre_built_workers/${LOAD_TEST_PREFIX}"
42 UNIQUE_IDENTIFIER="$(date +%Y%m%d%H%M%S)"
43 ROOT_DIRECTORY_OF_DOCKERFILES="../test-infra/containers/pre_built_workers/"
44 # Head of the workspace checked out by Kokoro.
45 GRPC_GITREF="$(git show --format="%H" --no-patch)"
46 # Prebuilt workers for core languages are always built from grpc/grpc.
47 if [[ "${KOKORO_GITHUB_COMMIT_URL%/*}" == "https://github.com/grpc/grpc/commit" ]]; then
48 GRPC_CORE_GITREF="${KOKORO_GIT_COMMIT}"
50 GRPC_CORE_GITREF="$(git ls-remote https://github.com/grpc/grpc.git master | cut -f1)"
52 GRPC_GO_GITREF="$(git ls-remote https://github.com/grpc/grpc-go.git master | cut -f1)"
53 GRPC_JAVA_GITREF="$(git ls-remote https://github.com/grpc/grpc-java.git master | cut -f1)"
54 # Kokoro jobs run on dedicated pools.
55 DRIVER_POOL=drivers-ci
56 WORKER_POOL_8CORE=workers-8core-ci
57 WORKER_POOL_32CORE=workers-32core-ci
60 TEST_INFRA_GOVERSION=go1.17
61 go get "golang.org/dl/${TEST_INFRA_GOVERSION}"
62 "${TEST_INFRA_GOVERSION}" download
64 # Clone test-infra repository to one upper level directory than grpc.
66 git clone --recursive https://github.com/grpc/test-infra.git
68 make GOCMD="${TEST_INFRA_GOVERSION}" all-tools
71 # Build test configurations.
76 tools/run_tests/performance/loadtest_config.py "$@" \
77 -t ./tools/run_tests/performance/templates/loadtest_template_prebuilt_all_languages.yaml \
78 -s driver_pool="${DRIVER_POOL}" -s driver_image= \
79 -s client_pool="${pool}" -s server_pool="${pool}" \
80 -s big_query_table="${table}" -s timeout_seconds=900 \
81 -s prebuilt_image_prefix="${PREBUILT_IMAGE_PREFIX}" \
82 -a ci_buildNumber="${KOKORO_BUILD_NUMBER}" \
83 -a ci_buildUrl="${CLOUD_LOGGING_URL}" \
84 -a ci_jobName="${KOKORO_JOB_NAME}" \
85 -a ci_gitCommit="${GRPC_GITREF}" \
86 -a ci_gitActualCommit="${KOKORO_GIT_COMMIT}" \
87 -s prebuilt_image_tag="${UNIQUE_IDENTIFIER}" \
88 --prefix="${LOAD_TEST_PREFIX}" -u "${UNIQUE_IDENTIFIER}" -u "${pool}" \
89 -a pool="${pool}" --category=scalable \
90 --allow_client_language=c++ --allow_server_language=c++ \
91 -o "./loadtest_with_prebuilt_workers_${pool}.yaml"
94 buildConfigs "${WORKER_POOL_8CORE}" "${BIGQUERY_TABLE_8CORE}" -l c++ -l csharp -l go -l java -l php7 -l php7_protobuf_c -l python -l ruby
95 buildConfigs "${WORKER_POOL_32CORE}" "${BIGQUERY_TABLE_32CORE}" -l c++ -l csharp -l go -l java
97 # Delete prebuilt images on exit.
99 echo "deleting images on exit"
100 ../test-infra/bin/delete_prebuilt_workers \
101 -p "${PREBUILT_IMAGE_PREFIX}" \
102 -t "${UNIQUE_IDENTIFIER}"
104 trap deleteImages EXIT
106 # Build and push prebuilt images for running tests.
107 time ../test-infra/bin/prepare_prebuilt_workers \
108 -l "cxx:${GRPC_CORE_GITREF}" \
109 -l "csharp:${GRPC_CORE_GITREF}" \
110 -l "go:${GRPC_GO_GITREF}" \
111 -l "java:${GRPC_JAVA_GITREF}" \
112 -l "php7:${GRPC_CORE_GITREF}" \
113 -l "python:${GRPC_CORE_GITREF}" \
114 -l "ruby:${GRPC_CORE_GITREF}" \
115 -p "${PREBUILT_IMAGE_PREFIX}" \
116 -t "${UNIQUE_IDENTIFIER}" \
117 -r "${ROOT_DIRECTORY_OF_DOCKERFILES}"
119 # Create reports directories.
120 mkdir -p "runner/${WORKER_POOL_8CORE}" "runner/${WORKER_POOL_32CORE}"
124 time ../test-infra/bin/runner \
125 -i "../grpc/loadtest_with_prebuilt_workers_${WORKER_POOL_8CORE}.yaml" \
126 -i "../grpc/loadtest_with_prebuilt_workers_${WORKER_POOL_32CORE}.yaml" \
127 -c "${WORKER_POOL_8CORE}:2" -c "${WORKER_POOL_32CORE}:2" \
128 -o "runner/sponge_log.xml"