1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
|
#!/bin/bash
# Copyright 2021 The 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.
# This script generates a set of load test examples from templates.
LOADTEST_CONFIG=tools/run_tests/performance/loadtest_config.py
if (( $# < 1 )); then
echo "Usage: ${0} <output directory>" >&2
exit 1
fi
if [[ ! -x "${LOADTEST_CONFIG}" ]]; then
echo "${LOADTEST_CONFIG} not found." >&2
exit 1
fi
outputbasedir="${1}"
mkdir -p "${outputbasedir}/templates/psm/prebuilt"
example_file() {
local scenario="${1}"
local suffix="${2}"
if [[ "${scenario#cpp_}" != "${scenario}" ]]; then
echo "cxx${suffix}"
return
fi
if [[ "${scenario#python_asyncio_}" != "${scenario}" ]]; then
echo "python_asyncio${suffix}"
return
fi
if [[ "${scenario#php7_protobuf_c_}" != "${scenario}" ]]; then
echo "php7_protobuf_c${suffix}"
return
fi
echo "${scenario%%_*}${suffix}"
}
example_language() {
local filename="${1}"
if [[ "${filename#cxx_}" != "${filename}" ]]; then
echo "c++"
return
fi
if [[ "${filename#python_asyncio_}" != "${filename}" ]]; then
echo "python_asyncio"
return
fi
if [[ "${filename#php7_protobuf_c_}" != "${filename}" ]]; then
echo "php7_protobuf_c"
return
fi
echo "${filename%%_*}"
}
scenarios=(
"cpp_generic_async_streaming_ping_pong_secure"
"csharp_protobuf_async_unary_ping_pong"
"dotnet_protobuf_async_unary_ping_pong"
"go_generic_sync_streaming_ping_pong_secure"
"java_generic_async_streaming_ping_pong_secure"
"node_to_node_generic_async_streaming_ping_pong_secure"
"php7_protobuf_php_extension_to_cpp_protobuf_sync_unary_ping_pong"
"php7_protobuf_c_extension_to_cpp_protobuf_sync_unary_ping_pong"
"python_generic_sync_streaming_ping_pong"
"python_asyncio_generic_async_streaming_ping_pong"
"ruby_protobuf_sync_streaming_ping_pong"
)
psm_scenarios=(
"cpp_protobuf_async_unary_5000rpcs_1KB_psm"
"go_protobuf_async_unary_5000rpcs_1KB_psm"
"java_protobuf_async_unary_5000rpcs_1KB_psm"
"node_to_node_protobuf_async_unary_5000rpcs_1KB_psm"
"php7_protobuf_php_extension_to_cpp_protobuf_async_unary_5000rpcs_1KB_psm"
"php7_protobuf_c_extension_to_cpp_protobuf_async_unary_5000rpcs_1KB_psm"
"python_protobuf_async_unary_5000rpcs_1KB_psm"
"python_asyncio_protobuf_async_unary_5000rpcs_1KB_psm"
)
# Basic examples are intended to be runnable _as is_, so substitution keys
# are stripped. Fields can be inserted manually following the pattern of the
# prebuilt examples.
basic_example() {
local -r scenario="${1}"
local -r outputdir="${2}"
local -r outputfile="$(example_file "${scenario}" _example_loadtest.yaml)"
local -r language="$(example_language "${outputfile}")"
${LOADTEST_CONFIG} \
-l "${language}" \
-t ./tools/run_tests/performance/templates/loadtest_template_basic_all_languages.yaml \
-s client_pool= -s server_pool= -s big_query_table= \
-s timeout_seconds=900 --prefix=examples -u basic -r "^${scenario}$" \
--allow_client_language=c++ --allow_server_language=c++ \
--allow_server_language=node \
-o "${outputdir}/${outputfile}"
echo "Created example: ${outputdir}/${outputfile}"
}
# Prebuilt examples contain substitution keys, so must be processed before
# running.
prebuilt_example() {
local -r scenario="${1}"
local -r outputdir="${2}"
local -r outputfile="$(example_file "${scenario}" _example_loadtest_with_prebuilt_workers.yaml)"
local -r language="$(example_language "${outputfile}")"
${LOADTEST_CONFIG} \
-l "${language}" \
-t ./tools/run_tests/performance/templates/loadtest_template_prebuilt_all_languages.yaml \
-s driver_pool="\${driver_pool}" -s driver_image="\${driver_image}" \
-s client_pool="\${workers_pool}" -s server_pool="\${workers_pool}" \
-s big_query_table="\${big_query_table}" -s timeout_seconds=900 \
-s prebuilt_image_prefix="\${prebuilt_image_prefix}" \
-s prebuilt_image_tag="\${prebuilt_image_tag}" --prefix=examples -u prebuilt \
-a pool="\${workers_pool}" -r "^${scenario}$" \
--allow_client_language=c++ --allow_server_language=c++ \
--allow_server_language=node \
-o "${outputdir}/${outputfile}"
echo "Created example: ${outputdir}/${outputfile}"
}
# PSM basic examples are intended to be runnable with only subsituding the
# xds-server and sidecar images, so substitution keys for xds-server and
# sidecar images are kept.
psm_basic_example() {
local -r scenario="${1}"
local -r outputdir="${2}"
local -r uniquifier="${3}"
local -r outputfile="$(example_file "${scenario}" _example_loadtest_"${uniquifier}".yaml)"
local -r language="$(example_language "${outputfile}")"
${LOADTEST_CONFIG} \
-l "${language}" \
-t ./tools/run_tests/performance/templates/loadtest_template_psm_"${uniquifier}"_basic_all_languages.yaml \
-s client_pool= -s server_pool= -s big_query_table= \
-s psm_image_prefix="\${psm_image_prefix}" \
-s psm_image_tag="\${psm_image_tag}" \
-s timeout_seconds=900 --prefix=psm-examples -u "${uniquifier}" -r "^${scenario}$" \
-a enablePrometheus=true \
--allow_client_language=c++ --allow_server_language=c++ \
--allow_server_language=node \
--client_channels=8 \
--category=psm \
--server_threads=16 \
--offered_loads 5000 \
-o "${outputdir}/${outputfile}"
echo "Created example: ${outputdir}/${outputfile}"
}
# PSM prebuilt examples contain substitution keys, so must be processed before
# running.
psm_prebuilt_example() {
local -r scenario="${1}"
local -r outputdir="${2}"
local -r uniquifier="${3}"
local -r outputfile="$(example_file "${scenario}" _example_loadtest_"${uniquifier}"_with_prebuilt_workers.yaml)"
local -r language="$(example_language "${outputfile}")"
${LOADTEST_CONFIG} \
-l "${language}" \
-t ./tools/run_tests/performance/templates/loadtest_template_psm_"${uniquifier}"_prebuilt_all_languages.yaml \
-s driver_pool="\${driver_pool}" -s driver_image="\${driver_image}" \
-s client_pool="\${workers_pool}" -s server_pool="\${workers_pool}" \
-s big_query_table="\${big_query_table}" -s timeout_seconds=900 \
-s prebuilt_image_prefix="\${prebuilt_image_prefix}" \
-s prebuilt_image_tag="\${prebuilt_image_tag}" \
-s psm_image_prefix="\${psm_image_prefix}" \
-s psm_image_tag="\${psm_image_tag}" \
--prefix=psm-examples -u prebuilt-"${uniquifier}" -r "^${scenario}$" \
-a pool="\${workers_pool}" \
-a enablePrometheus=true \
--allow_client_language=c++ --allow_server_language=c++ \
--allow_server_language=node \
--client_channels=8 \
--category=psm \
--server_threads=16 \
--offered_loads 5000 \
-o "${outputdir}/${outputfile}"
echo "Created example: ${outputdir}/${outputfile}"
}
for scenario in "${scenarios[@]}"; do
basic_example "${scenario}" "${outputbasedir}"
done
for scenario in "${scenarios[@]}"; do
prebuilt_example "${scenario}" "${outputbasedir}/templates"
done
for scenario in "${psm_scenarios[@]}"; do
psm_basic_example "${scenario}" "${outputbasedir}/templates/psm" "proxied"
psm_basic_example "${scenario}" "${outputbasedir}/templates/psm" "proxyless"
done
for scenario in "${psm_scenarios[@]}"; do
psm_prebuilt_example "${scenario}" "${outputbasedir}/templates/psm/prebuilt" "proxied"
psm_prebuilt_example "${scenario}" "${outputbasedir}/templates/psm/prebuilt" "proxyless"
done
|